:root {
  /* Brand Colors */
  --primary: #cc785c;                /* Brand voltage (coral) */
  --primary-active: #a9583e;         /* Press state on coral */
  --accent-teal: #5db8a6;            /* Status indicators */
  --accent-amber: #e8a55a;           /* Category badges */

  /* Surface Colors */
  --canvas: #faf9f5;                 /* Default page floor (cream) */
  --surface-soft: #f5f0e8;           /* Section dividers / soft bands */
  --surface-card: #efe9de;           /* Content / feature cards */
  --surface-dark: #181715;           /* Code editor mockups & footer background */
  --surface-dark-elevated: #252320;  /* Elevated cards inside dark bands */
  --hairline: #e6dfd8;               /* 1px borders on cream */

  /* Text Colors */
  --text-ink: #141413;               /* Headlines and primary text */
  --text-body: #3d3d3a;              /* Default running-text */
  --text-muted-light: #6c6a64;       /* Sub-headings, breadcrumbs, footer in light */
  --text-muted-soft-light: #8e8b82;  /* Captions, copyright, fine-print in light */
  --text-on-dark: #faf9f5;           /* Cream-tinted white on dark */
  --text-on-dark-soft: #a09d96;      /* Slightly muted text on dark */

  /* Functional Theme Mapping (Default Dark Mode) */
  --bg-color: var(--surface-dark);
  --toolbar-bg: var(--surface-dark-elevated);
  --editor-bg: var(--surface-dark);
  --text-color: var(--text-on-dark);
  --text-muted: var(--text-on-dark-soft);
  --accent-color: var(--primary);
  --accent-active: var(--primary-active);
  --border-color: #2a2825;           /* Distinct dark hairline border */
  --card-bg: var(--surface-dark-elevated);
  
  /* Additional layout variables */
  --font-mono: "ui-monospace", "SFMono-Regular", "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", monospace;
  --marker-size: 14px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --square-border-color: var(--text-on-dark);
}

body.light-mode {
  /* Functional Theme Mapping (Light Mode Override) */
  --bg-color: var(--canvas);
  --toolbar-bg: var(--surface-soft);
  --editor-bg: var(--canvas);
  --text-color: var(--text-ink);
  --text-muted: var(--text-muted-light);
  --accent-color: var(--primary);
  --accent-active: var(--primary-active);
  --border-color: var(--hairline);
  --card-bg: var(--surface-card);
  --square-border-color: var(--text-ink);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-mono);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    height: 64px;
    background-color: var(--toolbar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    z-index: 100;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    flex: 0 0 auto; /* side areas hug their content; the middle belongs to the tab bar */
}

.header-right {
    justify-content: flex-end;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    color: var(--text-color);
    margin-right: 12px;
    user-select: none;
}

.logo-svg {
    height: 15px;
    width: auto;
    display: block;
}

.logo-primary {
    fill: currentColor;
}

.logo-accent {
    fill: #e8613d;
}

/* Toolbar Controls */
.contrast-base-control {
    display: flex;
    align-items: center;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 8px;
    gap: 8px;
    transition: all 0.2s;
}

.contrast-base-control:hover {
    border-color: var(--accent-color);
}

.control-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#baseColorInput {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    width: 70px;
    outline: none;
}

#baseColorPicker {
    width: 20px;
    height: 20px;
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
}

/* Buttons */
.action-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-color);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 4px;
}

.icon-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    box-shadow: none;
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.icon-btn:hover {
    background-color: var(--toolbar-bg);
    color: var(--accent-color);
    border-color: var(--border-color);
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: translateY(0);
}

.icon-btn.highlight {
    color: var(--accent-color);
}

.icon-btn.highlight:hover {
    background-color: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.icon-btn.highlight:active {
    background-color: var(--accent-active);
    border-color: var(--accent-active);
}

.icon-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none !important;
}

.lang-btn {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Main Layout */
.container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.editor-section {
    flex: 1;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-right: 1px solid var(--border-color);
    background-color: var(--editor-bg);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.preview-section {
    width: 400px;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-color: var(--bg-color);
    border-left: 1px solid var(--border-color);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebars */
.sidebar {
    width: 0;
    height: 100%;
    background-color: var(--editor-bg);
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    width: 280px;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#saveSnippetBtn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--accent-color);
    color: white;
    border: none;
    font-size: 1.2rem;
    font-weight: 400;
}

.sidebar-header h3 {
    font-size: 0.9rem;
    color: var(--accent-color);
}

.sidebar-search {
    padding: 10px 10px 4px;
    border-bottom: 1px solid var(--border-color);
}

#snippetSearchInput {
    width: 100%;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    padding: 6px 10px;
    border-radius: 6px;
    outline: none;
    margin-bottom: 6px;
    transition: border-color 0.15s;
}

#snippetSearchInput:focus {
    border-color: var(--accent-color);
}

#snippetSearchInput::placeholder {
    color: var(--text-muted);
}

.snippet-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.snippet-item {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 10px;
    cursor: pointer;
    background: var(--bg-color);
    font-size: 0.75rem;
    transition: all 0.2s;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.snippet-item.active {
    border-color: var(--accent-color);
    background: rgba(204, 120, 92, 0.1);
    box-shadow: 0 0 0 1px var(--accent-color);
}

.snippet-item:hover {
    border-color: var(--accent-color);
}

.snippet-name-input {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--text-color);
    font-size: 0.75rem;
    padding: 2px 4px;
    border-radius: 4px;
    width: 80%;
    outline: none;
}

.snippet-actions {
    display: flex;
    gap: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.snippet-item:hover .snippet-actions {
    opacity: 1;
}

.snippet-action-btn {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    box-shadow: none;
    min-width: unset;
}

.snippet-action-btn:hover {
    color: var(--accent-color);
    transform: none;
}

.snippet-action-btn.delete:hover {
    color: #ef4444;
}

/* Notification Toast */
#notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--toolbar-bg);
    color: var(--accent-color);
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid var(--accent-color);
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    transform: translateY(100px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 12px;
}

#notification.show {
    transform: translateY(0);
}

.notification-undo {
    background: var(--accent-color);
    color: #fff;
    border: none;
    padding: 3px 10px;
    border-radius: 5px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.notification-undo:hover {
    background: var(--accent-active);
}

.notification-undo[hidden] {
    display: none;
}

/* Contrast Indicator */
.contrast-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-top: 4px;
    display: inline-block;
}

.contrast-pass {
    background: #10b981;
    color: white;
}

.contrast-large {
    background: #d97706;
    color: white;
}

.contrast-fail {
    background: #ef4444;
    color: white;
}

/* Harmony Panel */
.harmony-panel {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.harmony-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.1);
    cursor: copy;
}

.harmony-swatch:hover {
    transform: scale(1.2);
}

/* Editor Wrapper */
.editor-wrapper {
    position: relative;
    height: 100%;
    width: 100%;
}

#editor, #overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 24px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 24px; /* Strict pixel height */
    letter-spacing: 0;
    word-spacing: 0;
    white-space: pre-wrap; /* Re-enable wrap but we must ensure height matches */
    word-wrap: break-word;
    border: none;
    outline: none;
    overflow-y: scroll; /* Match scrollbars exactly */
    overflow-x: hidden;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: auto;
    tab-size: 4;
    font-variant-ligatures: none;
}

/* Scrollbar customization for a pro look */
#editor::-webkit-scrollbar, #overlay::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#editor::-webkit-scrollbar-track, #overlay::-webkit-scrollbar-track {
    background: transparent;
}

#editor::-webkit-scrollbar-thumb, #overlay::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

#editor::-webkit-scrollbar-thumb:hover, #overlay::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

#editor {
    background: transparent;
    color: transparent;
    -webkit-text-fill-color: transparent;
    caret-color: var(--text-color);
    z-index: 2; /* On top for interaction */
    resize: none;
}

#overlay {
    background: transparent;
    color: var(--text-color);
    z-index: 1; /* Behind but visible */
    pointer-events: none;
}

#overlay span {
    pointer-events: none; /* Inherit non-blocking */
}

/* Visual Highlights */
.hl-color {
    position: relative;
    border-bottom: 4px solid var(--token-color, currentColor);
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    /* Removed inline-flex and ::before to prevent text shift */
}

.hl-color.hl-highlight {
    background-color: rgba(204, 120, 92, 0.25) !important;
    box-shadow: 0 0 0 1px var(--accent-color);
}

/* Visual Output (Right Side) */
.visual-output {
    padding: 1.5rem;
    overflow-y: auto;
    height: 100%;
    /* flex column instead of grid: grid froze every row at the card's
       min-height (110px), so taller card content bled onto the next card */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    margin-top: 50px;
    font-size: 0.9rem;
}

.preview-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    flex-direction: row;
    gap: 1.25rem;
    position: relative;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    min-height: 110px;
    align-items: flex-start; /* let tall content grow the card instead of overflowing */
    flex-shrink: 0; /* never compress cards inside the scrolling column */
}

.preview-card:hover {
    border-color: var(--accent-color);
    /* translate instead of scale: no more overlapping the neighbor cards */
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    z-index: 5;
}

.preview-card.selected {
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 0 2px var(--accent-color) !important;
    transform: none;
}

.preview-swatch {
    width: 90px;
    height: 90px;
    flex-shrink: 0;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
    position: relative;
    overflow: hidden;
}

/* Subtle checkerboard for transparency */
.preview-swatch::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: linear-gradient(45deg, #222 25%, transparent 25%), 
                      linear-gradient(-45deg, #222 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #222 75%), 
                      linear-gradient(-45deg, transparent 75%, #222 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
    background-color: #111;
}

.preview-swatch {
    align-self: center;
}

.preview-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
    min-width: 0;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.preview-type {
    font-weight: 800;
    color: var(--accent-color);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.usage-badge {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    border: 1px solid var(--border-color);
}

.preview-value {
    color: var(--text-color);
    font-weight: 600;
    overflow-wrap: anywhere;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin: 0.5rem 0;
}

.multi-formats {
    display: flex;
    gap: 6px;
    margin-top: auto;
}

.fmt-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 6px;
    box-shadow: none;
    transition: all 0.15s;
}

.fmt-btn:hover {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.gradient-stops {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: auto;
}

.stop-dot {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Tooltip */
.tooltip {
    position: fixed;
    background: var(--toolbar-bg);
    color: var(--text-color);
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    z-index: 1000;
    display: none;
    pointer-events: auto; /* Clickable */
    border: 1px solid var(--border-color);
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
}

.tooltip.visible {
    transform: scale(1);
    opacity: 1;
}

.tooltip-swatch {
    width: 100px;
    height: 60px;
    border-radius: 4px;
    margin-bottom: 8px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip-swatch[style*="cursor: pointer"]:hover {
    transform: scale(1.04);
    box-shadow: 0 0 12px var(--accent-color);
}

.tooltip-formats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #1e1e1e;
}

::-webkit-scrollbar-thumb {
    background: #333;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Syntax Highlighting Colors - Dark Mode (Default) */
.hl-syntax.hl-comment {
    color: #a09d96; /* Muted soft grey on dark */
    font-style: italic;
}

.hl-syntax.hl-class_sel {
    color: #cc785c; /* Coral brand voltage */
    font-weight: 600;
}

.hl-syntax.hl-id_sel {
    color: #a9583e; /* Press state on coral (primary-active) */
    font-weight: 600;
}

.hl-syntax.hl-var_name {
    color: #5db8a6; /* Accent teal */
    font-weight: 600;
}

.hl-syntax.hl-property {
    color: #e8a55a; /* Accent amber */
}

/* Syntax Highlighting Colors - Light Mode Override */
body.light-mode .hl-syntax.hl-comment {
    color: #8e8b82; /* Muted soft grey on light */
}

body.light-mode .hl-syntax.hl-class_sel {
    color: #a9583e; /* Darker coral for light mode (accessibility pass) */
}

body.light-mode .hl-syntax.hl-id_sel {
    color: #cc785c; /* Coral brand voltage */
}

body.light-mode .hl-syntax.hl-var_name {
    color: #3b8a7c; /* Darker teal for light mode (accessibility pass) */
}

body.light-mode .hl-syntax.hl-property {
    color: #ad6d2a; /* Darker amber/orange for light mode (accessibility pass) */
}

/* ===== Tab Bar (lives inside the 64px header, between sidebar toggle and BASE control) ===== */
.tab-bar {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0; /* allow the tab list to shrink and scroll instead of pushing the header apart */
    gap: 6px;
    margin: 0 16px;
}

.tab-list {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    max-width: 100%;
    /* browser-tab feel: no visible scrollbar, mouse wheel scrolls horizontally (see app.js) */
    scrollbar-width: none;
}

.tab-list::-webkit-scrollbar {
    display: none;
}

.tab {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 6px 6px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.72rem;
    color: var(--text-muted);
    max-width: 200px;
    white-space: nowrap;
    user-select: none;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.tab:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.tab.active {
    background: var(--bg-color);
    color: var(--accent-color);
    border-color: var(--border-color);
    font-weight: 700;
}

.tab.comparing .tab-name::after {
    content: ' ⇆';
    color: var(--accent-teal);
}

.tab-name {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    line-height: 1;
    box-shadow: none;
}

.tab-btn svg {
    width: 12px;
    height: 12px;
}

.tab-btn:hover {
    color: var(--accent-color);
    background: rgba(128, 128, 128, 0.15);
}

.tab-btn.tab-close:hover {
    color: #ef4444;
}

.tab-new {
    background: none;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
    padding: 0;
}

.tab-new:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.tab-close-all {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: all 0.15s;
}

.tab-close-all[hidden] {
    display: none;
}

.tab-close-all svg {
    width: 13px;
    height: 13px;
}

.tab-close-all:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

/* ===== Compare (Split View) Pane ===== */
.compare-pane {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--editor-bg);
    border-left: 1px solid var(--border-color);
}

.compare-pane[hidden] {
    display: none;
}

.compare-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--toolbar-bg);
    font-size: 0.75rem;
    color: var(--accent-color);
    font-weight: 700;
    flex-shrink: 0;
}

.compare-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
}

.compare-close:hover {
    color: #ef4444;
}

.compare-content {
    flex: 1;
    overflow: auto;
    margin: 0;
    padding: 24px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 24px;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-color);
    tab-size: 4;
}

/* ===== AI Trace Cleaner ===== */
.ai-clean-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.ai-trace-popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 260px;
    background: var(--toolbar-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
    z-index: 1500;
    font-size: 0.72rem;
    color: var(--text-color);
    pointer-events: none;
}

.ai-trace-popover[hidden] {
    display: none;
}

.ai-popover-title {
    font-weight: 800;
    color: #ef4444;
    margin-bottom: 6px;
    font-size: 0.74rem;
}

.ai-popover-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 180px;
    overflow-y: auto;
}

.ai-popover-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
}

.ai-popover-count {
    background: rgba(239, 68, 68, 0.16);
    color: #ef4444;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.68rem;
    flex-shrink: 0;
}

.ai-popover-hint {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.66rem;
}

#aiCleanBtn.ai-clean {
    color: #10b981;
}

#aiCleanBtn.ai-clean:hover {
    color: #10b981;
    border-color: #10b981;
    background-color: rgba(16, 185, 129, 0.1);
}

#aiCleanBtn.ai-dirty {
    color: #ef4444;
    animation: aiBlink 1s ease-in-out infinite;
}

#aiCleanBtn.ai-dirty:hover {
    color: #ef4444;
    border-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.12);
    animation: none;
}

@keyframes aiBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Detected trace highlight inside the editor overlay.
   Inline background + thin border only: zero layout shift (see CHANGELOG 1.2.0). */
.hl-trace {
    background-color: rgba(239, 68, 68, 0.32);
    border-bottom: 2px solid #ef4444;
    border-radius: 2px;
}

/* ===== Sidebar Header Actions (Export / Import / + / Clear All) ===== */
.sidebar-header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.sidebar-icon-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-icon-btn svg {
    width: 14px;
    height: 14px;
}

.sidebar-icon-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

#clearAllBtn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: #ef4444;
    cursor: pointer;
    transition: all 0.2s;
}

#clearAllBtn svg {
    width: 14px;
    height: 14px;
}

#clearAllBtn:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

/* ===== Confirmation Modal ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(2px);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    background: var(--toolbar-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    width: 340px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.modal h4 {
    color: #ef4444;
    font-size: 1rem;
    margin-bottom: 8px;
}

.modal p {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 14px;
    line-height: 1.5;
}

.modal input {
    width: 100%;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 8px 10px;
    border-radius: 8px;
    outline: none;
    margin-bottom: 16px;
}

.modal input:focus {
    border-color: #ef4444;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
}

.modal-btn:hover {
    border-color: var(--accent-color);
}

.modal-btn.danger {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}

.modal-btn.danger:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.modal-btn.danger:not(:disabled):hover {
    background: #dc2626;
}

/* ===== Drag & Drop Import Overlay ===== */
.drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(24, 23, 21, 0.72);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
    pointer-events: none;
}

body.light-mode .drop-overlay {
    background: rgba(250, 249, 245, 0.78);
}

.drop-overlay[hidden] {
    display: none;
}

.drop-overlay-box {
    border: 2px dashed var(--accent-color);
    background: var(--toolbar-bg);
    padding: 32px 48px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.drop-overlay-title {
    color: var(--accent-color);
    font-size: 1.05rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.drop-overlay-sub {
    color: var(--text-muted);
    font-size: 0.78rem;
}
