* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    background-color: #f5f5f5;
    color: #333;
}

.wrapper {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.version {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

.theme-toggle {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: none;
}

.theme-toggle:hover {
    color: #334155;
    background-color: #e2e8f0;
}

h1 {
    font-size: 1.8rem;
    color: #2c3e50;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #dc3545;
    transition: background-color 0.3s ease;
}

#status-indicator.connected {
    background-color: #28a745;
}

.error-message {
    background-color: #fff3cd;
    color: #856404;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-message.hidden {
    display: none;
}

.control-panel {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    background-color: #fff;
    padding: 1rem;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.connect-button {
    background-color: #007bff;
    color: white;
}

.connect-button:hover {
    background-color: #0056b3;
}

.connect-button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.copy-button {
    background-color: #64748b;
    color: white;
}

.copy-button:hover {
    background-color: #475569;
    transform: translateY(-1px);
}

.download-button {
    background-color: #10b981;
    color: white;
}

.download-button:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

.clear-button {
    background-color: #ef4444;
    color: white;
}

.clear-button:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
}

.auto-scroll {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.baud-rate-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.baud-rate-selector select {
    padding: 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.95rem;
    background-color: white;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.baud-rate-selector select:hover {
    border-color: #94a3b8;
}

.baud-rate-selector select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.log-container {
    background-color: #1e293b;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    height: 500px;
    overflow-y: auto;
    border: 1px solid #334155;
}

.log-container pre {
    color: #e2e8f0;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.95rem;
    line-height: 1.5;
}

#log {
    height: 100%;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #d4d4d4;
    white-space: pre;
    word-wrap: normal;
    overflow-x: auto;
}

#log .key {
    color: #9cdcfe;
}

#log .number {
    color: #b5cea8;
}

#log .string {
    color: #ce9178;
}

#log .boolean {
    color: #569cd6;
}

#log .null {
    color: #569cd6;
}

#log .separator {
    color: #d4d4d4;
}

#log::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#log::-webkit-scrollbar-track {
    background: #2d2d2d;
}

#log::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 4px;
}

#log::-webkit-scrollbar-thumb:hover {
    background: #888;
}

/* Dark mode styles */
html[data-theme="dark"] body {
    background-color: #0f172a;
    color: #e2e8f0;
}

html[data-theme="dark"] .wrapper {
    background-color: #1e293b;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

html[data-theme="dark"] header {
    border-bottom-color: #334155;
}

html[data-theme="dark"] h1 {
    color: #e2e8f0;
}

html[data-theme="dark"] .version {
    color: #94a3b8;
}

html[data-theme="dark"] .theme-toggle {
    color: #94a3b8;
}

html[data-theme="dark"] .theme-toggle:hover {
    color: #e2e8f0;
    background-color: #334155;
}

html[data-theme="dark"] .control-panel {
    background-color: #0f172a;
    border-color: #334155;
}

html[data-theme="dark"] .baud-rate-selector select {
    background-color: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

html[data-theme="dark"] .baud-rate-selector select:hover {
    border-color: #475569;
}

html[data-theme="dark"] .error-message {
    background-color: #451a03;
    color: #fef3c7;
}

html[data-theme="dark"] .log-container {
    background-color: #0f172a;
    border-color: #334155;
}

html[data-theme="dark"] .option-item label {
    color: #e2e8f0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.option-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.option-item label {
    font-size: 0.9rem;
    cursor: pointer;
}

#log .key {
    color: #9cdcfe;
}

#log .number {
    color: #b5cea8;
}

#log .string {
    color: #ce9178;
}

#log .boolean {
    color: #569cd6;
}

#log .null {
    color: #569cd6;
}

#log .separator {
    color: #d4d4d4;
}

#log::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#log::-webkit-scrollbar-track {
    background: #2d2d2d;
}

#log::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 4px;
}

#log::-webkit-scrollbar-thumb:hover {
    background: #888;
}

/* Dark mode styles */
html[data-theme="dark"] body {
    background-color: #0f172a;
    color: #e2e8f0;
}

html[data-theme="dark"] .wrapper {
    background-color: #1e293b;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

html[data-theme="dark"] header {
    border-bottom-color: #334155;
}

html[data-theme="dark"] h1 {
    color: #e2e8f0;
}

html[data-theme="dark"] .version {
    color: #94a3b8;
}

html[data-theme="dark"] .theme-toggle {
    color: #94a3b8;
}

html[data-theme="dark"] .theme-toggle:hover {
    color: #e2e8f0;
    background-color: #334155;
}

html[data-theme="dark"] .control-panel {
    background-color: #0f172a;
    border-color: #334155;
}

html[data-theme="dark"] .baud-rate-selector select {
    background-color: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

html[data-theme="dark"] .baud-rate-selector select:hover {
    border-color: #475569;
}

html[data-theme="dark"] .error-message {
    background-color: #451a03;
    color: #fef3c7;
}

html[data-theme="dark"] .log-container {
    background-color: #0f172a;
    border-color: #334155;
}

html[data-theme="dark"] .option-item label {
    color: #e2e8f0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.option-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.option-item label {
    font-size: 0.9rem;
    cursor: pointer;
}

/* Additional styles for the improved serial monitor */

/* Additional styles for the improved serial monitor */

/* Search container */
.search-container {
    margin-bottom: 1rem;
}

.search-box {
    display: flex;
    align-items: center;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

html[data-theme="dark"] .search-box {
    background-color: #1e293b;
    border-color: #334155;
}

.search-box i {
    color: #64748b;
    margin-right: 0.5rem;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.95rem;
    color: #1e293b;
}

html[data-theme="dark"] .search-box input {
    color: #e2e8f0;
}

.search-box input::placeholder {
    color: #94a3b8;
}

.clear-search-button {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    font-size: 0.9rem;
}

.clear-search-button:hover {
    color: #334155;
}

/* Send command panel */
.send-panel {
    margin-top: 1rem;
    background-color: #fff;
    padding: 1rem;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

html[data-theme="dark"] .send-panel {
    background-color: #0f172a;
    border-color: #334155;
}

.send-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.send-input-container {
    display: flex;
    flex: 1;
    align-items: center;
}

.send-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px 0 0 6px;
    font-size: 0.95rem;
    font-family: 'Consolas', monospace;
}

html[data-theme="dark"] .send-input {
    background-color: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

#lineEnding {
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-left: none;
    border-radius: 0 6px 6px 0;
    background-color: #f8fafc;
    color: #1e293b;
    font-size: 0.9rem;
}

html[data-theme="dark"] #lineEnding {
    background-color: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

.send-button {
    background-color: #3b82f6;
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.send-button:hover {
    background-color: #2563eb;
    transform: translateY(-1px);
}

/* Notification styles */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: slide-in 0.3s ease-out;
}

.notification.info {
    background-color: #3b82f6;
}

.notification.success {
    background-color: #10b981;
}

.notification.error {
    background-color: #ef4444;
}

.notification.fade-out {
    animation: fade-out 0.3s ease-in forwards;
}

@keyframes slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Connected button style */
.connect-button.connected {
    background-color: #ef4444;
}

.connect-button.connected:hover {
    background-color: #dc2626;
}

/* Highlight for searched text */
.highlight {
    background-color: rgba(255, 255, 0, 0.3);
}

/* Log entry styles */
.log-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-entry:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

/* New json viewer styles */
.json-object {
    padding-left: 1rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0.2rem 0;
}

.json-key {
    color: #9cdcfe;
    margin-right: 0.5rem;
}

.json-collapse-marker {
    cursor: pointer;
    color: #999;
    margin-right: 0.25rem;
    user-select: none;
}

.json-array {
    padding-left: 1rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0.2rem 0;
}

/* Adjustments for small screens */
@media (max-width: 768px) {
    .control-panel {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .control-group {
        width: 100%;
        justify-content: space-between;
    }
    
    .send-form {
        flex-direction: column;
    }
    
    .send-input-container {
        width: 100%;
    }
}