:root {
    --bg: #090c0b;
    --bg-grid: rgba(255, 255, 255, 0.03);
    --surface: #0f1412;
    --surface-soft: #121916;
    --surface-strong: #171e1a;
    --line: #253129;
    --line-strong: #334239;
    --ink: #d9e3dc;
    --muted: #8b968f;
    --accent: #8bf7a8;
    --accent-soft: rgba(139, 247, 168, 0.12);
    --accent-strong: #d5ffe1;
    --success: #7ee49a;
    --focus: #8db2ff;
    --scout: #f0c96b;
    --danger: #ff8c86;
    --danger-soft: rgba(255, 140, 134, 0.12);
    --success-soft: rgba(126, 228, 154, 0.12);
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
    --radius: 10px;
    --page-width: 1520px;
    --font-ui: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background:
        radial-gradient(circle at 12% 8%, rgba(139, 247, 168, 0.08), transparent 24%),
        linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px),
        linear-gradient(180deg, #0b0e0d 0%, #090c0b 100%);
    background-size: auto, 24px 24px, 24px 24px, auto;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.58;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.hide-on-print {
    display: initial;
}

.shell {
    width: min(var(--page-width), calc(100% - 1rem));
    margin: 0 auto;
    padding: 0.9rem 0 2rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    padding-bottom: 0.85rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.topbar h1,
.hero-panel h2,
.detail-hero h2,
.idea-card h3,
.panel h3,
.print-header h1,
.auth-card h2,
.related-idea-card h4,
.print-related-header h3 {
    margin: 0;
    font-family: var(--font-ui);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.topbar h1 {
    font-size: clamp(1.4rem, 2vw, 2rem);
}

.eyebrow,
.summary-label,
.metric-label,
.status-lozenge,
.tag,
.score-pill,
.top-badge,
.field label,
dt,
.button,
.topnav a {
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.eyebrow {
    margin: 0 0 0.25rem;
    color: var(--accent);
    font-size: 0.72rem;
}

.topnav {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.nav-inline {
    margin: 0;
    display: flex;
}

.topnav a,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font-size: 0.8rem;
    font-weight: 600;
    transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.topnav a:hover,
.button:hover {
    border-color: var(--line-strong);
    background: var(--surface-strong);
}

.topnav a.is-active {
    border-color: rgba(139, 247, 168, 0.4);
    background: rgba(139, 247, 168, 0.08);
    color: var(--accent-strong);
}

.button-primary {
    border-color: rgba(139, 247, 168, 0.42);
    background: rgba(139, 247, 168, 0.08);
    color: var(--accent-strong);
}

.button-secondary {
    background: transparent;
}

.button-quiet {
    min-height: auto;
    padding: 0.1rem 0;
    border: 0;
    background: transparent;
    color: var(--muted);
}

.button-quiet:hover {
    background: transparent;
    color: var(--accent-strong);
}

.button-danger {
    border-color: rgba(255, 140, 134, 0.28);
    background: var(--danger-soft);
    color: #ffc1bc;
}

.button-danger:hover {
    border-color: rgba(255, 140, 134, 0.42);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid rgba(139, 247, 168, 0.55);
    outline-offset: 2px;
}

.flash,
.panel,
.summary-card,
.idea-card,
.print-sheet {
    background: rgba(15, 20, 18, 0.96);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.flash {
    padding: 0.8rem 0.9rem;
    margin-bottom: 1rem;
}

.flash-success {
    border-color: rgba(126, 228, 154, 0.22);
    background: var(--success-soft);
    color: #cffff1;
}

.flash-error {
    border-color: rgba(255, 140, 134, 0.24);
    background: var(--danger-soft);
    color: #ffc7c3;
}

.flash-info {
    background: var(--surface-soft);
}

.main-content {
    display: grid;
    gap: 0.9rem;
}

.auth-page .shell {
    width: min(520px, calc(100% - 1rem));
    padding-top: clamp(2rem, 8vh, 5rem);
}

.auth-page .topbar {
    justify-content: center;
    text-align: center;
}

.auth-shell {
    display: grid;
}

.auth-card {
    padding: 1.2rem;
}

.auth-card h2 {
    font-size: clamp(1.5rem, 5vw, 2rem);
}

.auth-form .actions {
    justify-content: stretch;
}

.auth-form .button {
    width: 100%;
}

.panel,
.summary-card,
.idea-card {
    padding: 1rem;
}

.hero-panel {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
    border-left: 2px solid var(--accent);
}

.hero-actions,
.actions,
.card-actions,
.panel-head,
.print-toolbar {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.lead {
    margin: 0.45rem 0 0;
    max-width: 70ch;
    color: var(--muted);
    font-size: 0.93rem;
}

.filters,
.grid-2,
.summary-grid,
.detail-grid,
.print-grid {
    display: grid;
    gap: 0.9rem;
}

.filters {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    align-items: end;
}

.summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.detail-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.92fr);
    align-items: start;
}

.detail-grid > *,
.detail-column,
.detail-panel {
    min-width: 0;
}

.grid-2,
.print-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field {
    display: grid;
    gap: 0.35rem;
}

.field label,
.summary-label,
dt {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 0.75rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0a0e0c;
    color: var(--ink);
}

input::placeholder,
textarea::placeholder {
    color: rgba(217, 227, 220, 0.34);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

.prompt-textarea {
    min-height: 430px;
    background: #080b09;
    color: #c6d2ca;
    line-height: 1.55;
    font-size: 0.84rem;
}

.prompt-textarea-compact {
    min-height: 300px;
}

.help,
.muted {
    color: var(--muted);
    font-size: 0.88rem;
}

.stack-lg,
.stack-md {
    display: grid;
    gap: 0.9rem;
}

.stack-md {
    gap: 0.65rem;
}

.summary-card strong {
    display: block;
    margin-top: 0.35rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 0.9rem;
}

.idea-card {
    position: relative;
    display: grid;
    gap: 0.8rem;
    min-width: 0;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(16, 21, 19, 0.98), rgba(12, 16, 14, 0.98));
}

.idea-card.surface-live {
    box-shadow: inset 3px 0 0 0 rgba(126, 228, 154, 0.54), var(--shadow);
}

.idea-card.surface-focus {
    box-shadow: inset 3px 0 0 0 rgba(141, 178, 255, 0.45), var(--shadow);
}

.idea-card.surface-scout {
    box-shadow: inset 3px 0 0 0 rgba(240, 201, 107, 0.45), var(--shadow);
}

.idea-card.surface-neutral {
    box-shadow: inset 3px 0 0 0 rgba(255, 255, 255, 0.1), var(--shadow);
}

.idea-card.is-scored::before {
    content: "";
    position: absolute;
    inset: -1px;
    border: 1px solid rgba(139, 247, 168, var(--score-border-opacity, 0.18));
    border-radius: calc(var(--radius) + 1px);
    pointer-events: none;
}

.idea-card.is-top::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(139, 247, 168, 0.75) 50%, transparent 100%);
    pointer-events: none;
}

.idea-card-topline {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 0.8rem;
}

.idea-card-header {
    display: grid;
    gap: 0.4rem;
}

.idea-card h3 {
    font-size: 1.12rem;
    line-height: 1.25;
}

.idea-summary {
    margin: 0;
    color: var(--ink);
    font-size: 0.93rem;
}

.clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.status-lozenge,
.tag,
.score-pill,
.top-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0.26rem 0.5rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.tone-live {
    border-color: rgba(126, 228, 154, 0.25);
    background: rgba(126, 228, 154, 0.08);
    color: #cffff1;
}

.tone-focus {
    border-color: rgba(141, 178, 255, 0.25);
    background: rgba(141, 178, 255, 0.08);
    color: #d8e5ff;
}

.tone-scout {
    border-color: rgba(240, 201, 107, 0.24);
    background: rgba(240, 201, 107, 0.08);
    color: #ffe9b9;
}

.tone-neutral {
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
}

.metric-block {
    display: grid;
    justify-items: end;
    gap: 0.1rem;
    min-width: 56px;
}

.metric-value {
    font-size: 1.12rem;
    line-height: 1;
    font-weight: 700;
    color: var(--ink);
}

.metric-block.is-top .metric-value,
.metric-block.is-top .metric-label {
    color: var(--accent-strong);
}

.metric-label {
    font-size: 0.66rem;
    color: var(--muted);
}

.tag {
    background: rgba(255, 255, 255, 0.03);
    color: var(--ink);
}

.tag-soft,
.score-pill.is-strong,
.top-badge {
    border-color: rgba(139, 247, 168, 0.25);
    background: rgba(139, 247, 168, 0.08);
    color: var(--accent-strong);
}

.detail-hero {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
}

.detail-hero-copy {
    display: grid;
    gap: 0.7rem;
    min-width: 0;
}

.detail-hero h2 {
    font-size: clamp(1.5rem, 3.4vw, 2.3rem);
    line-height: 1.1;
    max-width: 18ch;
}

.detail-chip-row,
.detail-panel h3,
.metadata-stack,
.meta-list,
.related-idea-meta,
.imported-score-grid,
.related-idea-list,
.print-related-list,
.print-list {
    min-width: 0;
}

.detail-chip-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.panel-head {
    justify-content: space-between;
}

.panel h3,
.detail-panel h3,
.panel-head h3 {
    font-size: 0.95rem;
}

.metadata-stack,
.meta-list,
.related-idea-meta {
    display: grid;
    gap: 0.6rem;
    margin: 0;
}

.metadata-stack div,
.meta-list div,
.related-idea-meta div {
    display: grid;
    gap: 0.2rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.metadata-stack dd,
.meta-list dd,
.related-idea-meta dd {
    margin: 0;
}

.metadata-stack dd p,
.meta-list dd p,
.related-idea-meta dd p {
    margin: 0;
}

.imported-score-grid {
    display: grid;
    gap: 0.65rem;
}

.imported-score-card {
    display: grid;
    gap: 0.3rem;
    padding: 0.75rem;
    border: 1px dashed var(--line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.015);
}

.imported-score-topline {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    align-items: baseline;
    font-size: 0.82rem;
}

.imported-score-topline strong {
    color: var(--accent-strong);
    font-size: 0.9rem;
}

.related-idea-list {
    display: grid;
    gap: 0.7rem;
}

.related-idea-card {
    display: grid;
    gap: 0.6rem;
    padding: 0.85rem;
    border: 1px dashed var(--line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.015);
}

.related-idea-topline {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
    align-items: start;
    flex-wrap: wrap;
}

.related-idea-card h4 {
    font-size: 0.96rem;
    line-height: 1.35;
}

.code-block {
    margin: 0;
    padding: 0.9rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: auto;
    background: #080b09;
    color: #c6d2ca;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.85rem;
    line-height: 1.55;
}

.feature-list {
    margin: 0;
    padding-left: 1rem;
    display: grid;
    gap: 0.4rem;
}

.empty-state {
    text-align: center;
    padding: 1.5rem 1rem;
}

.print-page .shell {
    width: min(980px, calc(100% - 1rem));
}

.print-toolbar {
    justify-content: flex-end;
}

.print-sheet {
    padding: 1.25rem;
    background: #fff;
    color: #111;
    box-shadow: none;
}

.print-header {
    padding-bottom: 0.9rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #cfcfcf;
}

.print-header .eyebrow {
    color: #555;
}

.print-header .lead {
    color: #444;
}

.print-grid {
    margin-bottom: 1.2rem;
}

.print-related-list,
.print-list {
    display: grid;
    gap: 1rem;
}

.print-related-item,
.print-list-item {
    padding-top: 0.9rem;
    border-top: 1px solid #d9d9d9;
}

.print-related-item:first-child,
.print-list-item:first-child {
    padding-top: 0;
    border-top: 0;
}

.print-related-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
    margin-bottom: 0.65rem;
}

@media (max-width: 980px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-hero h2 {
        max-width: none;
    }
}

@media (max-width: 760px) {
    .topbar,
    .hero-panel,
    .detail-hero {
        flex-direction: column;
        align-items: start;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .print-related-header {
        flex-direction: column;
    }
}

@media (max-width: 620px) {
    .shell,
    .auth-page .shell {
        width: calc(100% - 0.75rem);
    }

    .panel,
    .summary-card,
    .idea-card,
    .print-sheet {
        padding: 0.85rem;
    }

    .filters,
    .summary-grid,
    .grid-2,
    .print-grid {
        grid-template-columns: 1fr;
    }

    .hero-actions,
    .actions,
    .card-actions,
    .print-toolbar {
        width: 100%;
    }

    .hero-actions .button,
    .actions .button,
    .card-actions .button,
    .print-toolbar .button {
        width: 100%;
    }

    .topnav {
        width: 100%;
    }

    .topnav a,
    .nav-inline,
    .nav-inline .button {
        flex: 1 1 auto;
    }

    .idea-card-topline {
        flex-direction: column;
    }

    .metric-block {
        justify-items: start;
    }
}

@media print {
    html,
    body {
        background: #fff !important;
        color: #111;
    }

    .hide-on-print,
    .topbar,
    .flash {
        display: none !important;
    }

    .shell,
    .print-page .shell {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .panel,
    .summary-card,
    .idea-card,
    .print-sheet {
        border: 0;
        box-shadow: none;
        background: #fff;
        color: #111;
    }

    .print-sheet {
        padding: 0;
    }

    .code-block {
        border-color: #d0d0d0;
        background: #fafafa;
        color: #111;
    }
}
