/* ============================================================
   JSON Workbench — Futuristic Dark Theme
   Design system: deep space bg, cyan/violet accent gradient
   ============================================================ */

/* ── CSS Variables ───────────────────────────────────────── */
:root {
    --bg:        #07070f;
    --surface:   #0e0e1a;
    --surface-2: #13131f;
    --border:    rgba(255,255,255,0.07);
    --accent:    #00d4ff;
    --accent-2:  #7c3aed;
    --grad:      linear-gradient(135deg, #00d4ff, #7c3aed);
    --text:      #e2e8f0;
    --muted:     #64748b;
    --success:   #10b981;
    --error:     #ef4444;
    --warning:   #f5a623;
    --font:      'Inter', system-ui, sans-serif;
    --radius:    12px;
    --radius-lg: 18px;
}

/* ── Light Theme Override ────────────────────────────────── */
body.theme-light {
    --bg:        #f5f7fa;
    --surface:   #ffffff;
    --surface-2: #f0f2f5;
    --border:    rgba(0,0,0,0.09);
    --accent:    #0099cc;
    --accent-2:  #6d28d9;
    --grad:      linear-gradient(135deg, #0099cc, #6d28d9);
    --text:      #1a1a2e;
    --muted:     #64748b;
    --success:   #059669;
    --error:     #dc2626;
    --warning:   #b45309;
}
body.theme-light a:hover { color: var(--accent-2); }
body.theme-light *::-webkit-scrollbar-track { background: var(--surface-2); }
body.theme-light *::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); }
body.theme-light *::-webkit-scrollbar-thumb:hover { background: var(--accent); }
body.theme-light .logo {
    background: var(--grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
body.theme-light .logo .mark { -webkit-text-fill-color: #fff; }
body.theme-light .btn,
body.theme-light .toolbar button,
body.theme-light .ignore-presets button { color: #fff !important; }
body.theme-light .json-tree { color: var(--text); }
body.theme-light .json-tree .row:hover { background: rgba(0,153,204,0.06); }
body.theme-light .site-nav { background: var(--surface); border-bottom: 1px solid var(--border); }

/* ── Theme Toggle Button ─────────────────────────────────── */
.theme-toggle {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle .toggle-icon { font-size: 1rem; line-height: 1; }

/* ── Reset / Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}
html, body {
    height: 100%;
    max-width: 100%;
}
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #fff; }

/* ── Scrollbars ──────────────────────────────────────────── */
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: var(--surface); }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(0,212,255,0.4); }

/* ── Header ──────────────────────────────────────────────── */
#pma_header {
    position: relative;
    width: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    height: 56px;
    flex-shrink: 0;
    z-index: 100;
}
/* Thin animated gradient top border */
#pma_header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--grad);
}

/* Logo */
.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    background: var(--grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.logo .mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--grad);
    -webkit-text-fill-color: #000;
    font-weight: 900;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.logo em {
    font-style: normal;
    -webkit-text-fill-color: var(--accent);
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
}

/* ── Module Nav ──────────────────────────────────────────── */
#pma_modules {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    position: relative;
    z-index: 90;
    flex-shrink: 0;
}

.mod-home {
    display: inline-flex;
    align-items: center;
    padding: 0 1rem;
    height: 44px;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    transition: color 0.15s;
    white-space: nowrap;
    border: 0;
    background: transparent;
    cursor: pointer;
}
.mod-home:hover { color: var(--accent); }

.mod-item {
    position: relative;
}
.mod-btn {
    display: inline-flex;
    align-items: center;
    padding: 0 1rem;
    height: 44px;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.875rem;
    border: 0;
    background: transparent;
    cursor: pointer;
    transition: color 0.15s;
    white-space: nowrap;
}
.mod-btn:hover,
.mod-item.current .mod-btn { color: var(--accent); }

.mod-drop {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    padding: 0.5rem;
    min-width: 200px;
    list-style: none;
    margin: 0;
    z-index: 200;
}
.mod-item:hover .mod-drop,
.mod-item:focus-within .mod-drop { display: block; }

.mod-drop li a {
    display: block;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.875rem;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}
.mod-drop li a:hover {
    background: rgba(0,212,255,0.08);
    color: var(--accent);
}
.mod-drop li.active a {
    color: var(--accent);
    font-weight: 700;
}

/* ── Breadcrumb / Nav Bar ────────────────────────────────── */
#pma_nav {
    padding: 0.5rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.crumbs {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--muted);
    flex-wrap: wrap;
}
.crumbs a { color: var(--accent); font-weight: 600; }
.crumbs a:hover { color: #fff; }
.sep { color: var(--border); }

/* ── Page Layout ─────────────────────────────────────────── */
#page {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
}

/* ── Sidebar Navigation ──────────────────────────────────── */
#pma_navigation {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.nav-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 1rem 0.5rem;
}

.nav-home { list-style: none; margin: 0; padding: 0; }
.nav-home li a,
.nav-group ul li a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    font-size: 0.875rem;
    color: var(--text);
    text-decoration: none;
    border-right: 2px solid transparent;
    transition: background 0.15s, color 0.15s;
}
.nav-home li a:hover,
.nav-group ul li a:hover {
    background: rgba(0,212,255,0.06);
    color: var(--accent);
}
.nav-home li.active a,
.nav-group ul li.active a {
    background: rgba(0,212,255,0.1);
    color: var(--accent);
    font-weight: 600;
    border-right-color: var(--accent);
}

.nav-group { margin-top: 0.25rem; }

.nav-group-label {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: color 0.15s;
}
.nav-group-label:hover { color: var(--text); }
.nav-group-label::after {
    content: '›';
    transition: transform 0.2s;
    font-size: 1rem;
    line-height: 1;
}
.nav-group.is-current .nav-group-label::after {
    transform: rotate(90deg);
}

.nav-group ul {
    display: none;
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav-group.is-current ul { display: block; }

.nav-hint {
    font-size: 0.7rem;
    color: var(--muted);
    padding: 1rem;
    margin-top: 1rem;
    line-height: 1.5;
}

/* ── Main Content ────────────────────────────────────────── */
#pma_main {
    flex: 1;
    padding: 1.5rem;
    min-width: 0;
    overflow-x: hidden;
}

/* ── Tool Surface / h1 ───────────────────────────────────── */
#pma_main h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
    border-left: 3px solid var(--accent);
    padding-left: 0.75rem;
    line-height: 1.3;
}
#pma_main h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin: 1.25rem 0 0.5rem;
}

/* ── Notice ──────────────────────────────────────────────── */
.notice {
    background: rgba(0,212,255,0.06);
    border: 1px solid rgba(0,212,255,0.2);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    color: var(--text);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* ── Toolbar ─────────────────────────────────────────────── */
.toolbar {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn,
.toolbar button,
.ignore-presets button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    font-family: var(--font);
    background: var(--grad);
    color: #000 !important;
    border: 0;
    padding: 0.4rem 0.9rem;
    cursor: pointer;
    border-radius: 8px;
    text-decoration: none !important;
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: 0.02em;
    line-height: 1.4;
    white-space: nowrap;
}
.btn:hover,
.toolbar button:hover,
.ignore-presets button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0,212,255,0.35);
}
.ignore-presets button.on {
    background: var(--surface-2);
    color: var(--accent) !important;
    box-shadow: inset 0 0 0 1.5px var(--accent);
}
.ignore-presets button.on:hover {
    transform: translateY(-1px);
    box-shadow: inset 0 0 0 1.5px var(--accent), 0 4px 20px rgba(0,212,255,0.2);
}

/* ── Inputs / Selects ────────────────────────────────────── */
.toolbar input[type="search"],
.toolbar input[type="text"],
.toolbar input[type="number"],
.toolbar select,
.calc-box input,
.calc-box select,
.date-field input,
.flag-list input[type="text"],
.field-grow {
    font: inherit;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    color: var(--text);
    max-width: 100%;
    min-width: 0;
    transition: border-color 0.15s;
}
.toolbar input:focus,
.toolbar select:focus,
.calc-box input:focus,
.calc-box select:focus,
.date-field input:focus,
.flag-list input:focus,
.field-grow:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,212,255,0.1);
}
.field-grow { width: 100%; box-sizing: border-box; }

/* ── Action / Op Rows ────────────────────────────────────── */
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.action-row .field-grow { flex: 1 1 160px; }
.op-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 8px 0 4px;
}
.op-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text);
    font-size: 0.875rem;
}

/* ── Table scroll ────────────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* ── Editors / Textareas ─────────────────────────────────── */
textarea.editor,
.uuid-list {
    width: 100%;
    min-height: 280px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font: 13px/1.5 Consolas, 'Courier New', monospace;
    resize: vertical;
    color: var(--text);
    caret-color: var(--accent);
    transition: border-color 0.15s;
}
textarea.editor:focus,
.uuid-list:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,212,255,0.1);
}
.uuid-list { min-height: 240px; }

/* ── Status ──────────────────────────────────────────────── */
.status { margin-top: 8px; color: var(--muted); font-size: 0.875rem; }
.status.ok { color: var(--success); }
.status.err { color: var(--error); }

/* ── Image tools ─────────────────────────────────────────── */
.img-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    padding: 1.75rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    margin-bottom: 0.75rem;
}
.img-drop:hover { border-color: var(--accent); }
.img-drop.is-drag {
    border-color: var(--accent);
    background: rgba(0,212,255,0.08);
}
.img-drop p { margin: 0.15rem 0; color: var(--text); font-size: 0.95rem; }
.img-drop .img-meta { color: var(--muted); }
.img-drop input[type="file"] { display: none; }

.img-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
}
.img-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid var(--border);
    vertical-align: middle;
    margin: 0 4px;
    background: transparent;
}

.img-stage { margin: 0.75rem 0; }
.img-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem 1.15rem;
}
.img-card h3 { font-size: 1rem; font-weight: 800; margin: 0 0 0.6rem; color: var(--text); }
.img-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    max-height: 520px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
}
.img-frame img {
    display: block;
    max-width: 100%;
    max-height: 480px;
    height: auto;
}
.img-frame img.is-picking { cursor: crosshair; }
.img-checker {
    background-color: #23232b;
    background-image:
        linear-gradient(45deg, rgba(255,255,255,0.07) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.07) 75%),
        linear-gradient(45deg, rgba(255,255,255,0.07) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.07) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
}
.img-meta { margin: 0.6rem 0 0; color: var(--muted); font-size: 0.82rem; }

/* Batch queue (Image Converter) */
.img-list { display: flex; flex-direction: column; gap: 0.5rem; }
.img-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.7rem;
}
.img-row-thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.img-row-thumb img { max-width: 100%; max-height: 100%; display: block; }
.img-row-info { flex: 1 1 auto; min-width: 0; }
.img-row-name {
    margin: 0;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}
.img-row-info .img-meta { margin: 0.15rem 0 0; }
.img-row-state { margin: 0.2rem 0 0; font-size: 0.8rem; color: var(--muted); }
.img-row-state.is-ok  { color: var(--success); }
.img-row-state.is-err { color: var(--error); }
.img-row-state.is-warn { color: var(--warning, #f5a623); }
.img-row-actions { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: flex-end; }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
@media (max-width: 575.98px) {
    .img-row { flex-wrap: wrap; }
    .img-row-actions { width: 100%; justify-content: flex-start; }
}
h3 .img-meta { display: inline; font-weight: 400; margin: 0; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tabs button {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    padding: 0.45rem 0.9rem;
    color: var(--muted);
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    font-family: var(--font);
    transition: color 0.15s, background 0.15s;
}
.tabs button:hover { color: var(--text); }
.tabs button.active {
    background: var(--surface-2);
    color: var(--accent);
    border-color: var(--border);
    border-bottom-color: var(--surface-2);
    position: relative;
    top: 1px;
}

/* ── Panels ──────────────────────────────────────────────── */
.panel {
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    min-height: 420px;
    background: var(--surface);
}
.panel.hidden,
.yaml-preview.hidden,
.hidden { display: none !important; }

/* ── Calc Grid ───────────────────────────────────────────── */
.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 10px;
}
.calc-box {
    border: 1px solid var(--border);
    padding: 1rem;
    background: var(--surface-2);
    border-radius: var(--radius);
}
.calc-box h2 { margin-top: 0; font-size: 1rem; color: var(--text); }
.calc-box label { display: block; margin: 6px 0 4px; color: var(--muted); font-size: 0.875rem; }
.calc-box input,
.calc-box select { width: 100%; max-width: 100%; min-width: 0; }
.calc-result {
    margin-top: 8px;
    font: 16px/1.4 Consolas, 'Courier New', monospace;
    color: var(--accent);
}
.calc-box .op-check { display: inline-flex; margin: 0; }
.calc-box .op-check input,
.calc-box .date-field span input[type="checkbox"] { min-width: 0; width: auto; }

/* ── Calc Stack / Date ───────────────────────────────────── */
.calc-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 720px;
}
.date-pair {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: end;
    margin: 8px 0 12px;
}
.date-pair.date-offsets { grid-template-columns: 1fr 1fr 1fr; }
.date-arrow { padding-bottom: 6px; font-size: 18px; color: var(--muted); }
.date-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    min-width: 0;
}
.calc-box .date-field { display: flex; }
.date-field span { font-weight: bold; color: var(--text); font-size: 0.875rem; }
.date-field span input[type="checkbox"] { margin-right: 4px; }
.date-field input[type="date"],
.date-field input[type="number"] {
    width: 100%;
    min-width: 0;
    min-height: 38px;
}

/* ── Related Panel ───────────────────────────────────────── */
.related-panel { margin-top: 2rem; }
.related-panel h2 { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 0.5rem; }
.related-panel .char-meta { margin-bottom: 0.75rem; }
.content-page { max-width: 850px; }
.content-page h1 { margin-bottom: 0.75rem; }
.content-page h2 { margin-top: 2rem; font-size: 1.2rem; }
.content-page p { color: var(--muted); line-height: 1.75; }
.content-page .lead { font-size: 1.05rem; }
.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}
.related-card {
    display: block;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    text-decoration: none;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.related-card:hover {
    border-color: rgba(0,212,255,0.4);
    background: rgba(0,212,255,0.05);
    transform: translateY(-2px);
}
.related-card strong {
    display: block;
    color: var(--text);
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}
.related-card span { color: var(--muted); font-size: 0.8rem; }

/* ── Tables ──────────────────────────────────────────────── */
table.pma { border-collapse: collapse; width: 100%; max-width: 100%; }
table.pma th,
table.pma td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: left;
    color: var(--text);
}
table.pma th {
    background: var(--surface-2);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}
table.pma tr.cmp-match,
table.pma tr.cmp-unchanged   { background: rgba(16,185,129,0.08); }
table.pma tr.cmp-differ,
table.pma tr.cmp-changed     { background: rgba(239,68,68,0.08); }
table.pma tr.cmp-only-left,
table.pma tr.cmp-removed     { background: rgba(245,158,11,0.08); }
table.pma tr.cmp-only-right,
table.pma tr.cmp-added       { background: rgba(0,212,255,0.08); }
table.pma td.path,
table.pma td.snip {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
}
table.pma td.snip {
    max-width: 360px;
    word-break: break-word;
}

/* ── Split 2 ─────────────────────────────────────────────── */
.split-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.split-2 textarea.editor { min-height: 220px; }

/* ── Legend ──────────────────────────────────────────────── */
.legend { margin: 8px 0; }
.legend span {
    display: inline-block;
    margin-right: 12px;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text);
}
.legend .cmp-match,
.legend .cmp-unchanged  { background: rgba(16,185,129,0.08); }
.legend .cmp-differ,
.legend .cmp-changed    { background: rgba(239,68,68,0.08); }
.legend .cmp-only-left,
.legend .cmp-removed    { background: rgba(245,158,11,0.08); }
.legend .cmp-only-right,
.legend .cmp-added      { background: rgba(0,212,255,0.08); }

/* ── Epoch Output ────────────────────────────────────────── */
.epoch-out {
    font: 22px/1.3 Consolas, 'Courier New', monospace;
    padding: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--radius);
    margin: 8px 0;
    color: var(--accent);
}

/* ── Regex ───────────────────────────────────────────────── */
.regex-hits {
    background: rgba(245,158,11,0.25);
    color: #fbbf24;
}

/* ── Flag List ───────────────────────────────────────────── */
.flag-list {
    margin: 10px 0;
    padding: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--radius);
    max-width: 720px;
}
.flag-list-title { font-weight: bold; margin: 0 0 8px; color: var(--text); }
.flag-opt {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 6px 0;
    cursor: pointer;
    color: var(--text);
    font-size: 0.875rem;
}
.flag-opt input { margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); }

/* ── Badge ───────────────────────────────────────────────── */
.badge {
    display: inline-block;
    min-width: 52px;
    text-align: center;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 0.8rem;
}

/* ── Char Meta ───────────────────────────────────────────── */
.char-meta { margin: 0 0 4px; color: var(--muted); font-size: 0.85rem; }

/* ── Ignore Panel ────────────────────────────────────────── */
.ignore-panel {
    border: 1px solid var(--border);
    background: var(--surface-2);
    padding: 12px;
    margin-top: 8px;
    border-radius: var(--radius);
}
.ignore-panel h2 { margin-top: 0; font-size: 1rem; color: var(--text); }
.ignore-panel label { display: block; margin: 4px 0; color: var(--text); font-size: 0.875rem; }
.ignore-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    align-items: center;
    margin: 6px 0;
}
.ignore-presets { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
#ign-chars { min-width: 220px; font: 12px Consolas, monospace; }

/* ── YAML ────────────────────────────────────────────────── */
.yaml-issue {
    margin: 12px 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
}
.yaml-issue.ok {
    background: rgba(16,185,129,0.1);
    border-color: rgba(16,185,129,0.3);
}
.yaml-issue.err {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.3);
}
.yaml-preview {
    border: 1px solid var(--border);
    font: 12px/1.45 Consolas, monospace;
    max-height: 280px;
    overflow: auto;
    margin-bottom: 16px;
    border-radius: 10px;
    color: var(--text);
}
.yaml-line { display: flex; white-space: pre; }
.yaml-line .n {
    width: 36px;
    flex-shrink: 0;
    text-align: right;
    padding: 0 8px 0 4px;
    color: var(--muted);
    background: var(--surface-2);
    border-right: 1px solid var(--border);
}
.yaml-line.err { background: rgba(239,68,68,0.1); }
.yaml-line.err .n { background: rgba(239,68,68,0.2); color: #ef4444; }

/* ── JSON Tree ───────────────────────────────────────────── */
.json-tree {
    font: 13px/1.5 Consolas, monospace;
    padding: 8px 12px;
    overflow: auto;
    max-height: 70vh;
    color: var(--text);
}
.json-tree .key   { color: #e879f9; }
.json-tree .str   { color: #34d399; }
.json-tree .num   { color: #60a5fa; }
.json-tree .bool  { color: #f59e0b; }
.json-tree .null  { color: var(--muted); }
.json-tree .punct { color: var(--muted); }
.json-tree .coll  { margin-left: 16px; }
.json-tree .collapsed > .coll { display: none; }
.json-tree .toggle {
    cursor: pointer;
    color: var(--muted);
    display: inline-block;
    width: 12px;
    transition: color 0.1s;
}
.json-tree .toggle:hover { color: var(--accent); }
.json-tree .row:hover { background: rgba(0,212,255,0.05); }

/* ── Sidebar icon badges ─────────────────────────────────── */
.ico {
    display: inline-block;
    min-width: 18px;
    text-align: center;
    font-size: 9px;
    font-weight: bold;
    color: #000;
    background: var(--grad);
    border-radius: 4px;
    padding: 1px 3px;
}

/* ── Home page category cards ────────────────────────────── */
.cards.cat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}
article.card.cat-card,
.card.cat-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
    color: var(--text);
}
article.card.cat-card::before,
.card.cat-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    background: var(--grad);
    opacity: 0.06;
    border-radius: 0 var(--radius-lg) 0 80px;
    pointer-events: none;
}
article.card.cat-card:hover,
.card.cat-card:hover {
    border-color: rgba(0,212,255,0.35);
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
article.card.cat-card h3,
.card.cat-card h3 {
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    margin-top: 0;
}
article.card.cat-card p,
.card.cat-card p {
    color: var(--muted);
    font-size: 0.8rem;
    margin: 0;
    line-height: 1.5;
}
.cat-drop { display: none; }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer,
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1.25rem;
    color: var(--muted);
    text-align: center;
    font-size: 0.8rem;
    margin-top: auto;
}

/* ── Legacy Bootstrap-style nav (kept for compatibility) ─── */
.site-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.35rem 0;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 800;
    background: var(--grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}
.brand-mark { font-size: 1.35rem; line-height: 1; }
.brand-name { font-size: 1.15rem; }
.site-nav .nav-link {
    color: var(--muted);
    font-weight: 600;
    padding: 0.7rem 0.85rem;
    transition: color 0.15s;
}
.site-nav .nav-link:hover,
.site-nav .nav-link.active { color: var(--accent); }
.site-nav .dropdown-menu {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    padding: 0.4rem;
}
.site-nav .dropdown-item {
    color: var(--text);
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
}
.site-nav .dropdown-item:hover {
    background: rgba(0,212,255,0.08);
    color: var(--accent);
}
.nav-split { display: flex; align-items: center; }
.nav-split .nav-link { padding-right: 0.25rem; }
.nav-caret {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0.7rem 0.55rem 0.7rem 0.2rem;
    cursor: pointer;
    transition: color 0.15s;
}
.nav-caret:hover,
.nav-split .nav-link.active + .nav-caret { color: var(--accent); }
.nav-node { position: relative; }
.nav-menu-toggle {
    border: 0;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    text-align: left;
}
.nav-menu-arrow { font-size: 0.7rem; transition: transform 0.15s; }
.nav-node.is-open > .nav-menu-toggle .nav-menu-arrow { transform: rotate(180deg); }
.nav-submenu {
    display: none;
    position: absolute;
    top: calc(100% + 0.15rem);
    left: 0;
    z-index: 210;
    min-width: 210px;
    margin: 0;
    padding: 0.4rem;
    list-style: none;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.nav-node.is-open > .nav-submenu { display: block; }
.nav-submenu .nav-link,
.nav-submenu .nav-menu-toggle { padding: 0.45rem 0.75rem; border-radius: 8px; color: var(--text); font-size: 0.9rem; font-weight: 500; }
.nav-submenu .nav-link:hover,
.nav-submenu .nav-menu-toggle:hover,
.nav-submenu .nav-link.active { background: rgba(0,212,255,0.08); color: var(--accent); }
.nav-submenu-level-2 { top: -0.4rem; left: calc(100% - 0.2rem); }

/* ── Breadcrumb (Bootstrap) ──────────────────────────────── */
.breadcrumb { --bs-breadcrumb-divider: "/"; flex-wrap: wrap; row-gap: 0.2rem; }
.crumb-bar a { font-weight: 600; }
.crumb-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 0;
    font-size: 0.9rem;
}
.breadcrumb-item + .breadcrumb-item::before { color: var(--muted); }
.breadcrumb-item.active { color: var(--muted); }

/* ── Home / Tool surface legacy ──────────────────────────── */
.home-main { flex: 1; }
.tool-main  { flex: 1; }

.hero {
    background: var(--surface);
    text-align: center;
    padding: 3.2rem 1rem 2.2rem;
    border-bottom: 1px solid var(--border);
}
.hero h1 {
    font-size: clamp(1.8rem, 3.2vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 0.75rem;
    background: var(--grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero p {
    max-width: 640px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 1.05rem;
}

.home-tools { padding: 1.5rem 0 3rem; }

/* Filter pills */
.filter-pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.75rem;
}
.filter-pill {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-weight: 700;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    text-decoration: none !important;
    text-align: center;
    line-height: 1.3;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    cursor: pointer;
}
.filter-pill:hover { color: var(--accent); border-color: rgba(0,212,255,0.3); }
.filter-pill.active {
    background: var(--grad);
    color: #000 !important;
    border-color: transparent;
}

/* Tool grid / tiles */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
    gap: 1.1rem;
}
.tool-tile {
    display: block;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.1rem 1.15rem;
    text-decoration: none !important;
    color: var(--text);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s;
    min-height: 170px;
}
.tool-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    border-color: rgba(0,212,255,0.35);
    color: var(--text);
}
@media (hover: none) { .tool-tile:hover { transform: none; } }
.tool-tile-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: 800;
    font-size: 0.85rem;
    margin-bottom: 0.85rem;
    background: var(--grad);
}
.theme-red    { background: #e5322d; }
.theme-orange { background: #f5a623; }
.theme-blue   { background: #3b82f6; }
.theme-teal   { background: #14b8a6; }
.theme-purple { background: #8b5cf6; }
.theme-green  { background: #22c55e; }
.theme-pink   { background: #ec4899; }
.theme-indigo { background: #6366f1; }
.tool-tile h3 { font-size: 1.05rem; font-weight: 800; margin: 0 0 0.35rem; color: var(--text); }
.tool-tile p  { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.4; }
.tool-tile.is-hidden { display: none; }

/* Tool surface (legacy) */
.tool-surface {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.5rem 2rem;
}
.tool-surface > h1 {
    font-size: 1.65rem;
    font-weight: 800;
    margin: 0 0 0.75rem;
    border-left: 3px solid var(--accent);
    padding-left: 0.75rem;
}
.tool-surface > h2,
.related-panel h2 {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 1.4rem 0 0.5rem;
    color: var(--text);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .site-nav .navbar-brand { max-width: calc(100% - 4rem); }
    .brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .site-nav .dropdown-menu {
        position: static !important;
        float: none;
        transform: none !important;
        width: 100%;
        box-shadow: none;
        border: 0;
        padding-left: 0.75rem;
    }
    .nav-submenu,
    .nav-submenu-level-2 {
        position: static;
        width: 100%;
        min-width: 0;
        box-shadow: none;
        border: 0;
        border-radius: 0;
        padding-left: 0.75rem;
    }
    .nav-menu-toggle { justify-content: space-between; }
    .nav-split { width: 100%; }
    .nav-split .nav-link { flex: 1; }
    .filter-pills {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: stretch;
        overflow: visible;
        flex-wrap: wrap;
        margin-left: 0;
        margin-right: 0;
    }
    .filter-pill {
        width: 100%;
        flex: none;
        padding: 0.55rem 0.5rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 800px) {
    #pma_navigation { display: none; }
    #pma_main { padding: 1rem; }
    .hero { padding: 1.75rem 0.75rem 1.25rem; }
    .hero p { font-size: 0.98rem; }
    .home-tools { padding: 1rem 0 2rem; }
    .tool-main { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .tool-surface { padding: 1rem; overflow-x: auto; }
    .tool-surface > h1 { font-size: 1.35rem; }
    .split-2 { grid-template-columns: 1fr; }
    .date-pair,
    .date-pair.date-offsets { grid-template-columns: 1fr; }
    .date-arrow { display: none; }
    .toolbar { align-items: stretch; }
    .toolbar .btn,
    .toolbar button,
    .toolbar label { max-width: 100%; }
    textarea.editor { min-height: 200px; }
    table.pma { width: max-content; min-width: 100%; }
    .epoch-out { font-size: 1.1rem; word-break: break-word; }
    .breadcrumb { flex-wrap: wrap; row-gap: 0.15rem; }
    .calc-grid { grid-template-columns: 1fr; }
    .related-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 576px) {
    input, select, textarea.editor, .uuid-list {
        font-size: 16px !important;
    }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar .btn,
    .toolbar button { width: 100%; }
    .action-row .btn { width: 100%; }
    .calc-stack { max-width: 100%; }
    #pma_header { padding: 0 1rem; }
    #pma_nav { padding: 0.5rem 1rem; }
}
