:root {
    --paper: #fbfaf7;
    --ink: #1b1b1b;
    --line: #3e3e3e;
    --soft: #6d6d6d;
    --panel: rgba(255, 253, 249, 0.94);
    --shadow: rgba(0, 0, 0, 0.09);
    --accent: #202020;
    --good: #2d6d2d;
    --warn: #8a5d19;
    --bad: #8b2d2d;
    --grid: rgba(92, 136, 206, 0.18);
    --margin-line: rgba(206, 80, 80, 0.22);
    --build-orange: #f6821f;
    --build-orange-soft: #ffb15b;
    --build-bg: #111314;
    --build-panel: #181b1d;
    --build-panel-alt: #202427;
    --build-line: #34393d;
    --build-text: #f4f3ee;
    --build-soft: #a8b0b8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: "Comic Sans MS", "Segoe Print", "Bradley Hand", cursive;
    background:
        linear-gradient(90deg, transparent 0, transparent 52px, var(--margin-line) 52px, var(--margin-line) 54px, transparent 54px),
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px),
        radial-gradient(circle at top left, rgba(0, 0, 0, 0.03), transparent 32%),
        linear-gradient(180deg, #f8f6ef 0%, #efe9db 100%);
    background-size: 100% 100%, 24px 24px, 24px 24px, 100% 100%, 100% 100%;
    background-attachment: fixed;
}

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

.paper {
    max-width: 1480px;
    margin: 0 auto;
    padding: 28px;
    position: relative;
}

.hero,
.panel,
.side-card,
.product-card,
.order-card,
.detail-card,
.flash {
    background: var(--panel);
    border: 3px solid var(--line);
    box-shadow: 6px 6px 0 var(--shadow);
}

.hero {
    display: grid;
    grid-template-columns: 1.9fr 0.9fr;
    gap: 20px;
    padding: 24px;
    margin-bottom: 24px;
    transform: rotate(-0.3deg);
}

.eyebrow,
.section-kicker,
.mini-title,
.summary-label {
    margin: 0;
    text-transform: lowercase;
    letter-spacing: 0.08em;
    color: var(--soft);
}

.hero h1,
.view-head h2 {
    margin: 0 0 8px;
    line-height: 1.05;
}

.hero h1 {
    font-size: clamp(2rem, 4vw, 3.8rem);
}

.lede,
.section-note,
.scribble-note,
.session-meta {
    margin: 0;
    color: #2f2f2f;
}

.session-card {
    display: grid;
    gap: 10px;
    align-content: start;
    padding: 18px;
    border: 2px dashed var(--line);
    background: rgba(255, 255, 255, 0.68);
}

.shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
}

.sidebar {
    display: grid;
    gap: 18px;
    align-content: start;
}

.sidebar-nav,
.sub-nav,
.pager,
.row,
.view-head,
.view-actions,
.summary-strip,
.filter-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-strip {
    justify-content: space-between;
    margin-bottom: 12px;
}

.filter-field {
    display: grid;
    gap: 6px;
    min-width: min(420px, 100%);
    flex: 1 1 320px;
}

.filter-field input {
    min-height: 44px;
    padding: 10px 12px;
    border: 2px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
    font: inherit;
}

.sidebar-nav {
    flex-direction: column;
}

.nav-link,
.button-link,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 14px;
    border: 2px solid var(--line);
    background: #f7f5ef;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.12);
    cursor: pointer;
    font: inherit;
}

.nav-link.active,
.button-link.active {
    background: #ece6d9;
    transform: translate(-1px, -1px);
}

.side-card {
    padding: 16px;
}

.activity-details {
    display: grid;
    gap: 12px;
}

.activity-toggle {
    cursor: pointer;
    user-select: none;
}

.activity-toggle::marker {
    color: var(--soft);
}

.activity-log-output {
    min-height: 140px;
    max-height: 320px;
    overflow: auto;
}

.workspace {
    display: grid;
    gap: 18px;
}

.portal-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    margin-top: 22px;
}

.order-path-note {
    padding: 14px 16px;
    border-left: 4px solid var(--line);
    background: rgba(255, 253, 249, 0.78);
}

.order-path-note p {
    margin: 6px 0 0;
    line-height: 1.65;
}

.order-path-note .mini-title {
    margin: 0;
}

.order-path-note a {
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.order-path-note a:hover {
    background: #ece6d9;
}

.emdash-studio-form {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1.18fr) minmax(340px, 0.82fr);
    align-items: start;
}

.emdash-stage,
.emdash-rail {
    background:
        radial-gradient(circle at top right, rgba(246, 130, 31, 0.15), transparent 28%),
        linear-gradient(180deg, #191c1f 0%, #121416 100%);
    border-color: #252a2d;
    color: var(--build-text);
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.24);
}

.emdash-stage .section-note,
.emdash-stage .section-kicker,
.emdash-rail .field-note,
.emdash-stage .muted-text,
.emdash-rail .muted-text,
.emdash-stage .summary-label,
.emdash-rail .summary-label,
.emdash-stage .mini-title,
.emdash-rail .mini-title {
    color: var(--build-soft);
}

.emdash-stage-head,
.emdash-composer-head {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
}

.emdash-stage-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.emdash-stage .pill,
.emdash-rail .pill {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--build-line);
    color: var(--build-text);
}

.emdash-chat-thread {
    display: grid;
    gap: 12px;
    min-height: 430px;
    max-height: 620px;
    overflow: auto;
    padding: 18px;
    border: 1px solid var(--build-line);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)),
        linear-gradient(180deg, rgba(246, 130, 31, 0.06), transparent 16%);
}

.emdash-bubble {
    display: grid;
    gap: 6px;
    max-width: 84%;
    padding: 14px 16px;
    border: 1px solid var(--build-line);
    background: rgba(255, 255, 255, 0.03);
}

.emdash-bubble.assistant,
.emdash-bubble.system {
    justify-self: start;
}

.emdash-bubble.user {
    justify-self: end;
    border-color: rgba(246, 130, 31, 0.42);
    background: linear-gradient(180deg, rgba(246, 130, 31, 0.16), rgba(246, 130, 31, 0.08));
}

.emdash-bubble.system {
    background: rgba(246, 130, 31, 0.1);
}

.emdash-bubble-role {
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--build-orange-soft);
}

.emdash-bubble-body {
    color: var(--build-text);
    line-height: 1.55;
}

.emdash-composer {
    display: grid;
    gap: 12px;
    padding: 18px;
    border: 1px solid var(--build-line);
    background: rgba(255, 255, 255, 0.03);
}

.emdash-suggestion-strip,
.emdash-choice-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.emdash-suggestion,
.emdash-choice {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--build-line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--build-text);
    box-shadow: none;
}

.emdash-choice {
    min-width: 170px;
}

.emdash-choice.active,
.emdash-suggestion:hover,
.emdash-choice:hover {
    border-color: rgba(246, 130, 31, 0.48);
    background: rgba(246, 130, 31, 0.14);
    transform: none;
}

.emdash-text-wrap {
    display: grid;
    gap: 8px;
}

.emdash-text-wrap textarea {
    min-height: 110px;
    border-color: var(--build-line);
    background: rgba(0, 0, 0, 0.18);
    color: var(--build-text);
    box-shadow: none;
}

.emdash-text-wrap textarea::placeholder {
    color: rgba(244, 243, 238, 0.42);
}

.emdash-composer-actions,
.emdash-rail-actions {
    align-items: stretch;
}

.emdash-composer-actions button,
.emdash-rail-actions button {
    background: #22272a;
    color: var(--build-text);
    border-color: var(--build-line);
    box-shadow: none;
}

.emdash-composer-actions button:not(.secondary),
.emdash-rail-actions button:not(.secondary) {
    background: linear-gradient(180deg, var(--build-orange) 0%, #dc6b12 100%);
    color: #141414;
    border-color: #d56a14;
}

.emdash-composer-actions button:hover,
.emdash-rail-actions button:hover {
    transform: none;
    filter: brightness(1.05);
}

.emdash-composer-actions button:disabled,
.emdash-rail-actions button:disabled {
    opacity: 0.52;
    cursor: not-allowed;
    filter: none;
}

.emdash-rail {
    display: grid;
    gap: 14px;
}

.emdash-rail-card {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--build-line);
    background: rgba(255, 255, 255, 0.03);
}

.emdash-readiness-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.emdash-readiness-card {
    display: grid;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--build-line);
    background: rgba(255, 255, 255, 0.03);
}

.emdash-readiness-card.good {
    border-color: rgba(72, 184, 110, 0.5);
}

.emdash-readiness-card.bad {
    border-color: rgba(219, 86, 86, 0.5);
}

.emdash-readiness-card p {
    margin: 0;
    color: var(--build-soft);
}

.emdash-stage .muted-block,
.emdash-rail .muted-block,
.emdash-stage .output,
.emdash-rail .output {
    border-color: var(--build-line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--build-text);
}

.emdash-stage .output,
.emdash-rail .output {
    font-family: "Courier New", monospace;
}

.emdash-phase-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 8px;
    color: var(--build-text);
}

.emdash-tuner-grid .choice-chip span {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--build-line);
    color: var(--build-text);
    box-shadow: none;
}

.emdash-tuner-grid .choice-chip input:checked + span {
    background: rgba(246, 130, 31, 0.16);
    border-color: rgba(246, 130, 31, 0.48);
    transform: none;
}

.ai-hidden-fields {
    display: none !important;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(40, 36, 30, 0.42);
}

.modal-card {
    width: min(720px, 100%);
    max-height: min(88vh, 900px);
    display: grid;
    gap: 16px;
    padding: 20px;
    overflow: auto;
    background: var(--panel);
    border: 3px solid var(--line);
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.16);
}

.modal-head {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
}

.modal-body {
    display: grid;
    gap: 16px;
}

.view {
    display: grid;
    gap: 18px;
}

.hidden {
    display: none !important;
}

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

.panel,
.detail-card {
    padding: 18px;
}

.question-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 2px dashed var(--line);
    background: rgba(255, 255, 255, 0.62);
}

.question-card h3 {
    margin: 0;
    font-size: 1.1rem;
}

.content-grid,
.detail-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stack {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 6px;
    font-size: 1rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--line);
    background: #fff;
    box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.04);
    font: inherit;
}

textarea {
    resize: vertical;
}

button.secondary,
.button-link.secondary-link {
    background: #ece8df;
}

.disabled-link {
    opacity: 0.55;
    cursor: default;
    pointer-events: none;
}

.choice-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.choice-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.choice-chip input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.choice-chip span {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 9px 12px;
    border: 2px solid var(--line);
    background: #f7f5ef;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.08);
}

.choice-chip input:checked + span {
    background: #ece6d9;
    transform: translate(-1px, -1px);
}

.choice-chip input:focus-visible + span {
    outline: 2px solid #1f4f96;
    outline-offset: 2px;
}

button:hover,
.button-link:hover,
.nav-link:hover {
    transform: translate(-1px, -1px);
}

.status-chip,
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 2px solid var(--line);
    background: #f5f5f0;
    font-size: 0.95rem;
}

.pill.good,
.status-chip.good {
    border-color: var(--good);
    color: var(--good);
}

.pill.warn,
.status-chip.warn {
    border-color: var(--warn);
    color: var(--warn);
}

.pill.bad,
.status-chip.bad {
    border-color: var(--bad);
    color: var(--bad);
}

.flash {
    padding: 14px 16px;
}

.flash.success {
    border-color: var(--good);
    color: var(--good);
}

.flash.error {
    border-color: var(--bad);
    color: var(--bad);
}

.summary-strip {
    align-items: stretch;
}

.summary-box {
    min-width: 180px;
    padding: 14px;
    border: 2px dashed var(--line);
    background: rgba(255, 255, 255, 0.72);
}

.summary-box strong {
    display: block;
    margin-top: 6px;
    font-size: 1.15rem;
}

.card-list {
    display: grid;
    gap: 14px;
}

.product-card,
.order-card {
    display: grid;
    gap: 12px;
    padding: 16px;
}

.product-list-row {
    grid-template-columns: 132px minmax(0, 1fr);
    align-items: stretch;
    gap: 18px;
    padding: 14px;
}

.product-thumbnail-link {
    display: block;
    min-width: 0;
}

.product-list-content {
    min-width: 0;
    display: grid;
    gap: 10px;
}

.screenshot-panel {
    display: grid;
    gap: 10px;
}

.site-shot {
    display: block;
    width: 100%;
    border: 2px solid var(--line);
    background:
        linear-gradient(90deg, transparent 0, transparent 52px, rgba(206, 80, 80, 0.18) 52px, rgba(206, 80, 80, 0.18) 54px, transparent 54px),
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px),
        linear-gradient(180deg, rgba(255, 255, 255, 0.88) 0%, rgba(236, 231, 218, 0.88) 100%);
    background-size: 100% 100%, 24px 24px, 24px 24px, 100% 100%;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
    object-fit: cover;
}

.site-shot-thumb {
    width: 132px;
    height: 132px;
    aspect-ratio: 1;
    min-height: 0;
    max-height: none;
}

.site-shot-large {
    aspect-ratio: 3 / 2;
    min-height: 280px;
    max-height: 460px;
}

.site-shot.loading {
    opacity: 0.62;
    filter: grayscale(0.28) contrast(0.9);
}

.site-shot-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.screenshot-refresh-button {
    min-width: 170px;
}

.card-head,
.card-actions,
.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    margin: 0;
    font-size: 1.3rem;
}

.card-subtitle,
.muted-text {
    color: var(--soft);
}

.metric-grid,
.detail-table {
    display: grid;
    gap: 10px;
}

.metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.product-list-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.product-list-metrics .metric {
    min-width: 0;
    padding: 8px 10px;
    border-width: 1px;
}

.product-list-metrics .metric-value {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric {
    padding: 12px;
    border: 2px dashed var(--line);
    background: rgba(255, 255, 255, 0.7);
}

.metric-label {
    display: block;
    margin-bottom: 4px;
    color: var(--soft);
    font-size: 0.92rem;
}

.metric-value {
    font-weight: 700;
}

.pager {
    justify-content: flex-end;
}

.pager-note {
    margin-right: auto;
    color: var(--soft);
}

.breadcrumbs {
    color: var(--soft);
}

.sub-nav {
    padding: 4px 0;
}

.sub-link {
    padding: 10px 12px;
    border: 2px solid var(--line);
    background: #f7f4ed;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
}

.sub-link.active {
    background: #ece6d9;
}

.detail-card h3 {
    margin: 0 0 14px;
    font-size: 1.2rem;
}

.info-table,
.table-list {
    width: 100%;
    border-collapse: collapse;
}

.info-table th,
.info-table td,
.table-list th,
.table-list td {
    padding: 10px 8px;
    border-bottom: 1px dashed var(--line);
    text-align: left;
    vertical-align: top;
}

.info-table th,
.table-list th {
    width: 34%;
    color: var(--soft);
    font-weight: 400;
}

.table-list th {
    width: auto;
}

.muted-block,
.output,
.empty-state {
    padding: 14px;
    border: 2px dashed var(--line);
    background: rgba(255, 255, 255, 0.75);
}

.output {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
    font-family: "Courier New", monospace;
}

.field-note {
    margin: -2px 0 0;
    color: var(--soft);
    font-size: 0.92rem;
}

.brief-preview {
    display: grid;
    gap: 14px;
}

.brief-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.brief-item {
    display: grid;
    gap: 6px;
    padding: 12px;
    border: 2px dashed var(--line);
    background: rgba(255, 255, 255, 0.72);
}

.brief-text {
    margin: 6px 0 0;
}

.brief-output {
    margin-top: 6px;
    max-height: 320px;
    overflow: auto;
}

.warn-output {
    border-color: var(--warn);
    color: var(--warn);
}

.top-gap {
    margin-top: 18px;
}

@media (max-width: 1120px) {
    .emdash-studio-form,
    .shell,
    .hero,
    .portal-footer,
    .content-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .emdash-readiness-grid {
        grid-template-columns: 1fr;
    }

    .emdash-bubble {
        max-width: 100%;
    }
}

@media (max-width: 720px) {
    .paper {
        padding: 16px;
    }

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

    .product-list-row {
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 12px;
        padding: 10px;
    }

    .site-shot-thumb {
        width: 92px;
        height: 92px;
    }

    .product-list-metrics {
        grid-template-columns: 1fr;
    }

    .product-list-metrics .metric:nth-child(n + 2) {
        display: none;
    }

    .view-head,
    .card-head,
    .card-actions,
    .detail-actions {
        align-items: flex-start;
    }
}
