/* ------------------------------------------
   CSS Variables & Theme Overrides
   ------------------------------------------ */
:root {
    --app-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", "Noto Sans", "Helvetica Neue", Arial, sans-serif, var(--pico-font-family-emoji);
    --pico-font-family: var(--app-font-family);
    --pico-font-family-sans-serif: var(--app-font-family);
    --pico-font-size: 93.75%;
    --pico-line-height: 1.4;
    --pico-form-element-spacing-vertical: 0.5rem;
    --pico-form-element-spacing-horizontal: 1rem;
    --pico-border-radius: 0.5rem;
    
    /* Custom colors */
    --color-success: #22c55e;
    --color-error: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;
    --color-muted: #6b7280;

    --workspace-edge: #1a2233;
    --workspace-edge-strong: #2f3b52;
    --workspace-canvas: #0f1728;
    --workspace-canvas-soft: #121d32;
    --workspace-accent: #60a5fa;
}

html,
body {
    font-family: var(--app-font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Responsive font sizes */
@media (min-width: 576px) {
    :root { --pico-font-size: 93.75%; }
}
@media (min-width: 768px) {
    :root { --pico-font-size: 100%; }
}
@media (min-width: 1024px) {
    :root { --pico-font-size: 100%; }
}
@media (min-width: 1280px) {
    :root { --pico-font-size: 106.25%; }
}

/* ------------------------------------------
   Navigation
   ------------------------------------------ */
.navbar {
    padding: 0.75rem 1rem;
    background: var(--pico-card-background-color);
    border-bottom: 1px solid var(--pico-muted-border-color);
    margin-bottom: 0;
}

.navbar ul {
    margin-bottom: 0;
}

.navbar a {
    text-decoration: none;
}

.navbar a.active {
    color: var(--pico-primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.nav-brand {
    font-size: 1.1rem;
}

.origin-display {
    color: var(--color-muted);
    font-family: monospace;
    font-size: 0.75rem;
}

/* ------------------------------------------
   Main Layout
   ------------------------------------------ */
.workspace-page {
    padding: 0.75rem;
}

.workspace-shell {
    --left-sidebar-width: 500px;
    --workspace-header-height: 56px;
    --workspace-header-padding-inline: 0.9rem;
    display: grid;
    grid-template-columns: var(--left-sidebar-width) minmax(0, 1fr);
    min-height: calc(100vh - 5.5rem);
    border: 1px solid var(--workspace-edge-strong);
    border-radius: 0.75rem;
    overflow: hidden;
    background:
        radial-gradient(120% 120% at 20% 0%, rgba(59, 130, 246, 0.12), rgba(15, 23, 40, 0) 50%),
        linear-gradient(180deg, var(--workspace-canvas-soft), var(--workspace-canvas));
    position: relative;
}

.workspace-sidebar {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: rgba(10, 16, 29, 0.7);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: var(--workspace-header-height);
    box-sizing: border-box;
    padding: 0 var(--workspace-header-padding-inline);
    border-bottom: 1px solid var(--workspace-edge-strong);
    background: linear-gradient(180deg, rgba(44, 63, 92, 0.32), rgba(18, 29, 50, 0.24));
}

.sidebar-header h2 {
    margin: 0;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.sidebar-eyebrow {
    margin: 0;
    color: #8ca3c7;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-scroll {
    overflow: auto;
    padding: 0.8rem;
}

.workspace-main {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(9, 13, 23, 0.62);
}

.workspace-main-toolbar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: var(--workspace-header-height);
    box-sizing: border-box;
    padding: 0 var(--workspace-header-padding-inline);
    border-bottom: 1px solid var(--workspace-edge-strong);
    background: linear-gradient(180deg, rgba(34, 50, 73, 0.4), rgba(19, 30, 47, 0.26));
}

.workspace-main-title {
    flex: 1 1 auto;
    text-align: left;
    color: #b9cbe8;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.workspace-sidebar-toggle {
    display: none;
}

.workspace-tablist {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
}

.workspace-tab {
    border: 1px solid var(--workspace-edge-strong);
    background: rgba(17, 26, 42, 0.7);
    color: #b9cbe8;
    border-radius: 999px;
    padding: 0.18rem 0.62rem;
    font-size: 0.72rem;
    line-height: 1.35;
    margin: 0;
    white-space: nowrap;
}

.workspace-tab:hover {
    border-color: #4d6186;
    background: rgba(27, 41, 66, 0.72);
}

.workspace-tab.active {
    border-color: var(--workspace-accent);
    background: rgba(67, 116, 185, 0.28);
    color: #e9f1ff;
}

.workspace-main-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable both-edges;
    padding: 0.8rem 1rem 0.8rem 0.85rem;
}

.workspace-tab-panel {
    display: none;
}

.workspace-tab-panel.active {
    display: block;
}

.workspace-backdrop {
    display: none;
}

.icon-only {
    min-width: 2rem;
    width: 2rem;
    min-height: 2rem;
    height: 2rem;
    padding-left: 0;
    padding-right: 0;
    text-align: center;
}

/* ------------------------------------------
   Section Cards
   ------------------------------------------ */
.section-card {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.section-card h3 {
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-card h3 .badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    background: var(--pico-primary);
    color: white;
    font-weight: 500;
}

.section-card h4 {
    margin: 1rem 0 0.5rem 0;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-muted);
}

/* ------------------------------------------
   Button Groups
   ------------------------------------------ */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-group button,
.btn-group [role="button"] {
    margin: 0;
    min-height: 2rem;
    padding: 0.32rem 0.72rem;
    font-size: 0.82rem;
    line-height: 1.15;
}

.btn-group-vertical {
    flex-direction: column;
}

.btn-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
}

/* Smaller buttons for compact areas */
button.sm, [role="button"].sm {
    min-height: 1.85rem;
    padding: 0.22rem 0.58rem;
    font-size: 0.77rem;
    line-height: 1.12;
}

/* ------------------------------------------
   Test Selector
   ------------------------------------------ */
.test-selector-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.test-search input {
    margin-bottom: 0;
}

.test-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    background: rgba(6, 11, 20, 0.5);
}

.test-list-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    border-bottom: 1px solid var(--pico-muted-border-color);
}

.test-list-item label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    padding: 0.42rem 0.75rem;
    margin: 0;
    cursor: pointer;
    font-size: 0.85rem;
}

.test-list-item:last-child {
    border-bottom: none;
}

.test-list-item:hover {
    background: rgba(59, 130, 246, 0.08);
}

.test-list-item label input[type="checkbox"] {
    margin: 0;
    width: auto;
}

.test-list-item .test-code-btn {
    margin: 0 0.5rem 0 0;
    padding: 0.2rem 0.45rem;
    font-size: 0.7rem;
}

.test-list-item.hidden {
    display: none;
}

.test-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.test-actions .selection-info {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-left: auto;
}

.compact-group > * {
    flex: 1 1 auto;
}

/* Legacy dropdown support (fallback) */
select#request_methods_dropdown {
    min-height: 200px;
    height: auto;
    resize: vertical;
    overflow: auto;
}

/* ------------------------------------------
   Status & Raw Request Panel
   ------------------------------------------ */
.sidebar-panel {
    position: sticky;
    top: 1rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: var(--pico-border-radius);
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    margin-bottom: 1rem;
}

.compact-status-card {
    padding: 0.75rem 0.9rem;
}

.compact-status-card h3 {
    margin-bottom: 0.55rem;
}

.compact-status-card .status-indicator {
    margin-bottom: 0.65rem;
    padding: 0.45rem 0.62rem;
}

.compact-status-card .status-info {
    gap: 0.3rem;
    font-size: 0.74rem;
}

.compact-status-card .status-row {
    grid-template-columns: 54px minmax(0, 1fr);
}

.compact-status-card .status-label {
    min-width: 0;
}

.compact-status-actions {
    margin-top: 0.55rem;
}

.compact-status-actions button {
    flex: 1 1 48%;
    font-size: 0.72rem;
    padding: 0.22rem 0.45rem;
}

.status-indicator.busy {
    border-color: var(--color-info);
}

.status-indicator.success {
    border-color: var(--color-success);
}

.status-indicator.error {
    border-color: var(--color-error);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-muted);
}

.status-indicator.busy .status-dot {
    background: var(--color-info);
    animation: pulse 1.5s infinite;
}

.status-indicator.success .status-dot {
    background: var(--color-success);
}

.status-indicator.error .status-dot {
    background: var(--color-error);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status-info {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.8rem;
}

.status-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: start;
    column-gap: 0.45rem;
}

.status-label {
    color: var(--color-muted);
    min-width: 0;
}

.status-info code {
    font-size: 0.75rem;
    padding: 0.1rem 0.3rem;
    background: var(--pico-background-color);
    border-radius: 3px;
}

.status-value {
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
    font-size: 0.75rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.status-true {
    color: var(--color-success);
    font-weight: 600;
}

.status-false {
    color: var(--color-error);
    font-weight: 600;
}

.status-muted {
    color: var(--color-muted);
}

.status-link {
    display: block;
    min-width: 0;
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--pico-primary);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.status-link:hover {
    text-decoration: underline;
}

#latest_raw {
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
    padding: 0.75rem;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
    background: var(--pico-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
}

.request_method_code_pre {
    margin: 0;
    max-height: 360px;
    overflow-y: auto;
    padding: 0;
    background: #0b1324;
    border: 1px solid #2d3f61;
    border-radius: var(--pico-border-radius);
}

#request_method_code_preview {
    display: block;
    margin: 0;
    padding: 0.75rem;
    min-height: 220px;
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
    font-size: 0.74rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    color: #d8e3ff;
}

#request_method_code_preview .hljs-keyword,
#request_method_code_preview .hljs-selector-tag,
#request_method_code_preview .hljs-literal,
#request_method_code_preview .hljs-built_in,
#request_method_code_preview .hljs-type {
    color: #7ab3ff;
}

#request_method_code_preview .hljs-string,
#request_method_code_preview .hljs-template-string,
#request_method_code_preview .hljs-symbol,
#request_method_code_preview .hljs-regexp {
    color: #8bd28b;
}

#request_method_code_preview .hljs-comment,
#request_method_code_preview .hljs-quote {
    color: #6f8a6f;
    font-style: italic;
}

#request_method_code_preview .hljs-number,
#request_method_code_preview .hljs-attr {
    color: #f5cb7e;
}

#request_method_code_preview .hljs-function,
#request_method_code_preview .hljs-title,
#request_method_code_preview .hljs-variable,
#request_method_code_preview .hljs-property,
#request_method_code_preview .hljs-title.function_ {
    color: #cddcff;
}

#request_method_code_preview .hljs-operator,
#request_method_code_preview .hljs-punctuation {
    color: #a5b9df;
}

.request-method-code-meta {
    margin-bottom: 0.45rem;
}

.request-method-code-name {
    font-size: 0.82rem;
    color: #c8daff;
}

/* ------------------------------------------
   Results Table
   ------------------------------------------ */
.results-section {
    margin-top: 2rem;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.results-header h3 {
    margin: 0;
}

.results-header .btn-group {
    margin-left: auto;
}

.results-header .btn-group button {
    height: 1.62rem;
    min-height: 1.62rem;
}

.timeline-compare-form {
    margin-bottom: 0.5rem;
}

.timeline-compare-grid {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.4rem;
    align-items: stretch;
}

.timeline-compare-form input {
    height: 1.62rem;
    min-height: 1.62rem;
    padding: 0.12rem 0.58rem;
    font-size: 0.77rem;
    line-height: 1;
    margin: 0;
}

.timeline-compare-form .compare-submit-btn {
    height: 1.62rem;
    min-height: 1.62rem;
    padding: 0.12rem 0.62rem;
    font-size: 0.76rem;
    white-space: nowrap;
    line-height: 1;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#latest_table {
    width: 100%;
    min-width: 760px;
    table-layout: fixed;
    font-size: 0.75rem;
    margin-bottom: 0;
}

#latest_table th {
    font-weight: 600;
    white-space: nowrap;
    font-size: 0.68rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #9fb4d8;
}

#latest_table td {
    vertical-align: middle;
}

#latest_table th,
#latest_table td {
    padding: 0.28rem 0.42rem;
    white-space: nowrap;
}

#latest_table .col-time,
#latest_table .col-browser,
#latest_table .col-request,
#latest_table .col-http,
#latest_table .col-dest,
#latest_table .col-site,
#latest_table .col-cookies {
    overflow: hidden;
    text-overflow: ellipsis;
}

#latest_table .col-time {
    width: 72px;
}

#latest_table .col-browser {
    width: 120px;
}

#latest_table .col-request {
    width: 195px;
}

#latest_table .col-http {
    width: 58px;
    text-align: center;
}

#latest_table .col-dest {
    width: 92px;
}

#latest_table .col-site {
    width: 84px;
}

#latest_table .col-cookies {
    width: 128px;
}

#latest_table .col-inspect {
    width: 156px;
    overflow: visible;
}

#latest_table button {
    min-height: 1.72rem;
    padding: 0.12rem 0.42rem;
    font-size: 0.7rem;
    margin: 0;
}

.table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.28rem;
    flex-wrap: nowrap;
}

.cookie-pill-list {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    min-height: 1.2rem;
}

.cookie-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 1.1rem;
    min-width: 1.1rem;
    padding: 0 0.28rem;
    border-radius: 999px;
    border: 2px solid transparent;
    font-size: 0.61rem;
    line-height: 1;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.cookie-default {
    background: rgba(148, 163, 184, 0.18);
    border-color: rgba(148, 163, 184, 0.9);
    color: #dbe6f6;
}

.cookie-none {
    background: rgba(45, 212, 191, 0.18);
    border-color: rgba(45, 212, 191, 0.9);
    color: #a7f3d0;
}

.cookie-none-secure {
    background: rgba(96, 165, 250, 0.18);
    border-color: rgba(96, 165, 250, 0.9);
    color: #bfdbfe;
}

.cookie-lax {
    background: rgba(250, 204, 21, 0.16);
    border-color: rgba(250, 204, 21, 0.9);
    color: #fef08a;
}

.cookie-strict {
    background: rgba(248, 113, 113, 0.18);
    border-color: rgba(248, 113, 113, 0.9);
    color: #fecaca;
}

.cookie-empty,
.cookie-unknown {
    background: rgba(100, 116, 139, 0.2);
    border-color: rgba(148, 163, 184, 0.75);
    color: #b8c4d9;
}

.workspace-main .results-section {
    margin-top: 0;
}

.workspace-main figure {
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding-right: 0.45rem;
    padding-bottom: 0.25rem;
}

.workspace-panel-card {
    margin-bottom: 0;
}

#workspace_panel_raw.workspace-tab-panel.active,
#workspace_panel_code.workspace-tab-panel.active {
    min-height: calc(100vh - 16rem);
}

#workspace_panel_raw .workspace-panel-card,
#workspace_panel_code .workspace-panel-card {
    display: flex;
    flex-direction: column;
    min-height: inherit;
}

#workspace_panel_raw #latest_raw {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

#workspace_panel_code .request_method_code_pre {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

/* ------------------------------------------
   Comparison Page
   ------------------------------------------ */
.comp_item {
    margin: 0 1rem;
}

#comp {
    font-size: 0.8rem;
}

#comp td {
    text-align: center;
    padding: 0.3rem 0.5rem;
}

#comp thead {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--pico-card-background-color);
}

#comp th .badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    background: var(--pico-primary);
    color: white;
    font-weight: 500;
}

#comp > tbody > tr > th {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--pico-card-background-color);
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}

#comp th {
    border-bottom: none;
}

#comp th:not(:first-child) {
    max-width: 6vw;
    font-size: 0.75rem;
}

/* ------------------------------------------
   Color Indicators
   ------------------------------------------ */
.result td {
    color: #000;
    font-weight: 500;
}

.box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 22px;
    width: 22px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    color: #0b1324;
}

.green {
    background-color: var(--color-success);
}

.red {
    background-color: var(--color-error);
}

.yellow {
    background-color: var(--color-warning);
}

.white {
    background-color: #f3f4f6;
}

.blue {
    background-color: var(--color-info);
}

#comp td.hc-cell {
    position: relative;
    text-align: left;
    background: rgba(18, 29, 50, 0.78);
    color: #dbe6f6;
    padding-left: 0.65rem;
}

#comp td.hc-cell::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: var(--hc-rail-color, transparent);
}

#comp td.hc-cell .hc-content {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.4rem;
    min-height: 1.2rem;
}

#comp td.hc-cell .hc-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0.9rem;
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
    font-size: 0.72rem;
    font-weight: 700;
}

#comp td.hc-state-good {
    --hc-rail-color: var(--color-success);
}

#comp td.hc-state-bad {
    --hc-rail-color: var(--color-error);
}

#comp td.hc-state-empty {
    --hc-rail-color: var(--color-warning);
}

#comp td.hc-state-special {
    --hc-rail-color: var(--color-info);
}

#comp td.hc-state-good .hc-icon {
    color: #4ade80;
}

#comp td.hc-state-bad .hc-icon {
    color: #f87171;
}

#comp td.hc-state-empty .hc-icon {
    color: #fbbf24;
}

#comp td.hc-state-special .hc-icon {
    color: #60a5fa;
}

#comp td.hc-cell .cookie-pill-list {
    justify-content: flex-start;
}

#comp td.hc-cell.hc-muted {
    opacity: 0.5;
}

#comp td.hc-cell.hc-muted::before {
    opacity: 0.25;
}

#comp td.hc-cell.hc-muted .hc-icon {
    color: #94a3b8;
}

/* ------------------------------------------
   Legend
   ------------------------------------------ */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--pico-card-background-color);
    border-radius: var(--pico-border-radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

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

/* ------------------------------------------
   Empty States
   ------------------------------------------ */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--color-muted);
}

.empty-state h3 {
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

/* ------------------------------------------
   Utilities
   ------------------------------------------ */
a.disabled {
    opacity: 0.5;
    pointer-events: none;
}

input:not([type=checkbox], [type=radio]),
select,
textarea {
    margin-bottom: 0;
}

h1, h2, h3, h4, h5, h6 {
    --pico-font-weight: 600;
}

/* Grid spacing fix */
.grid {
    margin-bottom: 0;
}

/* Comparison page action buttons */
.comparison-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.comparison-actions form {
    margin: 0;
}

.comparison-actions input[type="submit"] {
    margin: 0;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}


/* Responsive helpers */
@media (max-width: 1200px) {
    .workspace-page {
        padding: 0.5rem;
    }

    .workspace-shell {
        display: block;
        min-height: calc(100vh - 5.3rem);
    }

    .workspace-main {
        min-height: calc(100vh - 5.3rem);
        border-radius: 0.6rem;
    }

    .workspace-main-toolbar {
        position: sticky;
        top: 0;
        z-index: 5;
        display: grid;
        grid-template-columns: 2rem minmax(0, 1fr);
        grid-template-areas:
            "title title"
            "toggle tabs";
        align-items: center;
        column-gap: 0.45rem;
        row-gap: 0.35rem;
        padding: 0.45rem 0.7rem 0.4rem;
    }

    .workspace-sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        grid-area: toggle;
        justify-self: start;
        margin: 0;
    }

    .workspace-main-title {
        font-size: 0.72rem;
        grid-area: title;
        text-align: center;
        margin: 0;
        justify-self: center;
    }

    .workspace-tablist {
        grid-area: tabs;
        width: 100%;
        min-width: 0;
        margin: 0;
        padding: 0.05rem 0;
        justify-content: flex-start;
        overflow-x: auto;
    }

    .workspace-tab {
        margin: 0 0.12rem 0.08rem 0;
    }

    #workspace_panel_raw.workspace-tab-panel.active,
    #workspace_panel_code.workspace-tab-panel.active {
        min-height: calc(100vh - 14.3rem);
    }

    .workspace-sidebar {
        position: fixed;
        top: 4.6rem;
        bottom: 0.5rem;
        width: min(86vw, 390px);
        border: 1px solid var(--workspace-edge-strong);
        border-radius: 0.65rem;
        z-index: 1110;
        box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
        transition: transform 160ms ease;
        visibility: visible;
        pointer-events: auto;
    }

    .left-sidebar {
        left: 0.5rem;
        transform: translateX(-110%);
    }

    .workspace-shell[data-left-open="true"] .left-sidebar {
        transform: translateX(0);
    }

    .workspace-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1100;
        opacity: 0;
        pointer-events: none;
        background: rgba(2, 6, 14, 0.58);
        transition: opacity 120ms ease;
    }

    .workspace-backdrop.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .compact-group > * {
        flex: 1 1 calc(50% - 0.5rem);
    }
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .navbar ul {
        flex-wrap: wrap;
        justify-content: center;
    }

    .btn-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .timeline-compare-grid {
        grid-template-columns: 1fr !important;
    }

    .timeline-compare-form .compare-submit-btn {
        width: max-content;
    }
}

/* Scrollbar styling for dark theme */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--pico-background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--pico-muted-border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-muted);
}

/* ------------------------------------------
   SSA Modal
   ------------------------------------------ */
.ssa-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ssa-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.ssa-modal-content {
    position: relative;
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    width: 90%;
    max-width: 420px;
    height: 280px;
    overflow: hidden;
}

.ssa-modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.ssa-modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.ssa-modal-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}
