:root {
    --page: #e9eef3;
    --page-soft: #f1f4f7;
    --sidebar: #26323d;
    --sidebar-panel: #303d49;
    --sidebar-muted: #b7c4d1;
    --surface: #fbfcfd;
    --surface-plain: #ffffff;
    --surface-soft: #f2f6f8;
    --surface-muted: #eaf0f4;
    --surface-tint: #e6f4f1;
    --text: #182330;
    --muted: #657386;
    --line: rgba(88, 107, 128, 0.2);
    --line-strong: rgba(88, 107, 128, 0.34);
    --primary: #0f766e;
    --primary-dark: #0b5f59;
    --accent: #2563eb;
    --warning: #b45309;
    --danger: #b91c1c;
    --success: #15803d;
    --shadow-sm: 0 8px 24px rgba(31, 42, 52, 0.07);
    --shadow-md: 0 18px 46px rgba(31, 42, 52, 0.1);
    --shadow-hover: 0 24px 54px rgba(31, 42, 52, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: linear-gradient(180deg, #e3e9ee 0%, var(--page) 360px, #edf1f4 100%);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

body.nav-open {
    overflow: hidden;
}

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

button,
input {
    font: inherit;
}

button {
    touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
.upload-area:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.28);
    outline-offset: 3px;
}

img {
    display: block;
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 24px 18px;
    background: var(--sidebar);
    color: #f7fafc;
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
}

.brand {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #e7f4f1;
    color: var(--primary-dark);
    font-weight: 850;
    letter-spacing: 0;
}

.brand strong,
.brand small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand strong {
    font-size: 0.98rem;
    font-weight: 780;
}

.brand small {
    color: var(--sidebar-muted);
    font-size: 0.78rem;
}

.side-nav,
.mobile-nav {
    display: grid;
    gap: 5px;
}

.side-nav a,
.mobile-nav a {
    min-height: 42px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    font-weight: 760;
}

.side-nav a {
    padding: 0 12px;
    color: #d5dee7;
}

.side-nav a:hover,
.side-nav a.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar-note {
    display: grid;
    gap: 4px;
    margin-top: auto;
    padding: 15px;
    border-radius: 8px;
    background: var(--sidebar-panel);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.sidebar-note strong,
.sidebar-note small,
.note-kicker {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-kicker {
    color: #9de3da;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.sidebar-note small {
    color: var(--sidebar-muted);
}

.main-column {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 72px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 0 34px;
    background: rgba(233, 238, 243, 0.9);
    backdrop-filter: blur(14px);
    box-shadow: 0 1px 0 rgba(88, 107, 128, 0.16);
}

.topbar-title {
    min-width: 0;
}

.topbar-title span,
.topbar-title strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-title span {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 760;
    text-transform: uppercase;
    letter-spacing: 0;
}

.topbar-title strong {
    font-size: 1rem;
    font-weight: 760;
}

.nav-toggle {
    width: 42px;
    height: 42px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 0;
    border-radius: 8px;
    background: var(--surface-plain);
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.nav-toggle span:not(.sr-only) {
    width: 18px;
    height: 2px;
    background: currentColor;
}

.mobile-nav {
    display: none;
}

.mobile-nav a {
    padding: 0 14px;
    color: var(--muted);
}

.mobile-nav a.active {
    background: var(--surface-tint);
    color: var(--primary-dark);
}

.status-pill {
    max-width: min(420px, 42vw);
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 13px;
    border-radius: 999px;
    background: var(--surface-plain);
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 760;
    box-shadow: var(--shadow-sm);
}

.status-pill span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--warning);
}

.status-pill[data-state="ready"] .status-dot {
    background: var(--success);
}

.status-pill[data-state="error"] .status-dot {
    background: var(--danger);
}

main {
    width: min(1400px, calc(100% - 64px));
    margin: 0 auto;
    padding: 34px 0 60px;
}

.workspace-section,
.content-section {
    scroll-margin-top: 92px;
}

.content-section {
    padding-top: 60px;
}

.workspace-header {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(420px, 0.85fr);
    gap: 28px;
    align-items: end;
    margin-bottom: 24px;
    transition: max-width 240ms ease, transform 240ms ease;
}

.workspace-section[data-stage="empty"] .workspace-header {
    max-width: 860px;
    grid-template-columns: minmax(0, 1fr);
    margin-inline: auto;
}

.workspace-section[data-stage="empty"] .case-meta {
    display: none;
}

.eyebrow,
.section-heading .eyebrow {
    margin: 0 0 8px;
    color: var(--primary-dark);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: 3rem;
    font-weight: 740;
    line-height: 1.05;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 0;
    font-size: 1.72rem;
    font-weight: 720;
    line-height: 1.14;
    letter-spacing: 0;
}

h3 {
    margin-bottom: 6px;
    font-size: 1rem;
    font-weight: 740;
}

.workspace-header p,
.section-heading p,
.guardrail-copy p {
    max-width: 700px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.98rem;
}

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

.case-meta div {
    min-height: 74px;
    display: grid;
    align-content: center;
    gap: 5px;
    padding: 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.case-meta span,
.case-meta strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.case-meta span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 790;
    text-transform: uppercase;
}

.case-meta strong {
    color: var(--text);
    font-size: 1rem;
    font-weight: 760;
}

.workbench-grid {
    display: grid;
    grid-template-columns: minmax(340px, 0.78fr) minmax(0, 1fr);
    gap: 20px;
    align-items: stretch;
    transition: max-width 260ms ease;
}

.workspace-section[data-stage="empty"] .workbench-grid {
    max-width: 900px;
    grid-template-columns: minmax(0, 1fr);
    justify-content: center;
    margin-inline: auto;
}

.workspace-section[data-stage="empty"] .result-panel {
    display: none;
}

.workspace-section[data-stage="selected"] .result-panel,
.workspace-section[data-stage="loading"] .result-panel,
.workspace-section[data-stage="complete"] .result-panel {
    animation: panelIn 260ms ease both;
}

.panel,
.artifact-card,
.class-card,
.guardrail-grid article {
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.panel {
    min-width: 0;
    padding: 22px;
}

.workspace-section[data-stage="empty"] .upload-panel {
    padding: 28px;
    box-shadow: var(--shadow-md);
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-intro {
    max-width: 560px;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.support-chip,
.result-badge {
    flex: 0 0 auto;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.73rem;
    font-weight: 790;
    white-space: nowrap;
}

.support-chip {
    background: #e0f2ef;
    color: var(--primary-dark);
}

.result-badge {
    background: #e8edff;
    color: #3730a3;
}

.result-panel[data-risk="clear"] .result-badge {
    background: #e4f5ea;
    color: var(--success);
}

.result-panel[data-risk="watch"] .result-badge {
    background: #fff3e3;
    color: var(--warning);
}

.result-panel[data-risk="alert"] .result-badge {
    background: #fde9eb;
    color: var(--danger);
}

.upload-area {
    min-height: 306px;
    display: grid;
    place-items: center;
    border: 2px dashed rgba(68, 101, 124, 0.46);
    border-radius: 8px;
    background: linear-gradient(180deg, #fbfdfd 0%, #eff6f7 100%);
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.workspace-section[data-stage="empty"] .upload-area {
    min-height: 388px;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: #e8f5f3;
    box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.12);
    transform: translateY(-1px);
}

.upload-content {
    width: min(100%, 340px);
    padding: 24px;
    text-align: center;
}

.upload-icon {
    width: 66px;
    height: 66px;
    display: grid;
    place-items: center;
    margin: 0 auto 15px;
    border-radius: 8px;
    background: #d7efeb;
    color: var(--primary);
}

.upload-content h3 {
    margin-bottom: 4px;
    font-size: 1.08rem;
}

.upload-content p {
    margin-bottom: 16px;
    color: var(--muted);
}

.primary-button,
.secondary-button,
.icon-button {
    min-height: 44px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
}

.primary-button {
    border: 0;
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.18);
}

.primary-button:hover:not(:disabled) {
    background: var(--primary-dark);
}

.secondary-button {
    border: 1px solid var(--line-strong);
    background: var(--surface-plain);
    color: var(--text);
    padding: 0 16px;
}

.secondary-button:hover {
    border-color: rgba(15, 118, 110, 0.45);
    color: var(--primary-dark);
}

.icon-button {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border: 0;
    background: #f6e8ea;
    color: var(--danger);
    font-size: 1.1rem;
}

.analyze-button {
    width: 100%;
    margin-top: 16px;
}

.analyze-button:disabled {
    cursor: not-allowed;
    opacity: 0.54;
    box-shadow: none;
}

.button-loader {
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.loader {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

.image-preview {
    overflow: hidden;
    border-radius: 8px;
    background: #111827;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
    animation: panelIn 240ms ease both;
}

.image-preview img {
    width: 100%;
    height: 306px;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), filter 0.25s ease;
}

.image-preview img:hover {
    transform: scale(1.02);
    filter: brightness(1.08);
}

.preview-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    background: var(--surface-plain);
}

.preview-actions div {
    min-width: 0;
}

.preview-actions span,
.preview-actions small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-actions span {
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 780;
}

.preview-actions small {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 680;
}

.upload-checklist {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.upload-checklist span {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 760;
    text-align: center;
}

.workflow-guide {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
    padding: 16px;
    border-radius: 8px;
    background: #eef5f6;
}

.workspace-section[data-stage="selected"] .workflow-guide,
.workspace-section[data-stage="loading"] .workflow-guide,
.workspace-section[data-stage="complete"] .workflow-guide {
    display: none;
}

.workflow-guide div {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.workflow-guide span {
    color: var(--primary-dark);
    font-size: 0.76rem;
    font-weight: 790;
}

.workflow-guide strong {
    color: var(--text);
    font-size: 0.94rem;
}

.workflow-guide small {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.45;
}

.error-message {
    display: grid;
    gap: 4px;
    margin-top: 14px;
    padding: 12px;
    border-radius: 8px;
    background: #fde9eb;
    color: var(--danger);
}

.error-message span {
    color: #7f1d1d;
}

.result-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.empty-result {
    min-height: 414px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 18px;
    border-radius: 8px;
    background: #eef3f6;
    color: var(--muted);
    text-align: center;
}

.empty-result p {
    width: min(100%, 340px);
    margin-bottom: 0;
    font-weight: 760;
}

.empty-visual {
    width: min(300px, 80%);
    aspect-ratio: 1.45;
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #121b27;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.empty-visual span {
    position: absolute;
    border-radius: 999px;
    border: 1px solid rgba(45, 212, 191, 0.48);
}

.empty-visual span:nth-child(1) {
    width: 58%;
    height: 72%;
}

.empty-visual span:nth-child(2) {
    width: 34%;
    height: 48%;
    transform: translateX(22px);
}

.empty-visual span:nth-child(3) {
    width: 78%;
    height: 2px;
    border: 0;
    background: rgba(37, 99, 235, 0.76);
}

.result-content {
    display: grid;
    gap: 18px;
}

.result-content > p {
    margin-bottom: 0;
    color: var(--muted);
}

.confidence-card {
    display: grid;
    gap: 10px;
    padding: 18px;
    border-radius: 8px;
    background: #edf7f4;
}

.confidence-card span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.confidence-card strong {
    color: var(--primary-dark);
    font-size: 3.1rem;
    font-weight: 760;
    line-height: 1;
}

.confidence-bar {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #d3e1e8;
}

.confidence-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
    transition: width 500ms ease;
}

.subsection-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.subsection-title h3 {
    margin-bottom: 0;
}

.subsection-title span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 720;
    white-space: nowrap;
}

.probability-list {
    display: grid;
    gap: 10px;
}

.probability-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    background: var(--surface-soft);
}

.probability-main {
    min-width: 0;
    display: grid;
    gap: 7px;
}

.probability-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.probability-name,
.probability-value {
    font-weight: 780;
}

.probability-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.probability-value {
    color: var(--primary-dark);
    white-space: nowrap;
}

.mini-bar {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #dce6ed;
}

.mini-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
}

.section-heading {
    max-width: 760px;
    margin-bottom: 20px;
}

.artifact-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.artifact-card {
    display: grid;
    grid-template-rows: auto auto;
    gap: 14px;
    padding: 14px;
}

.artifact-image-wrap {
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 8px;
    background: var(--surface-soft);
}

.artifact-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), filter 0.25s ease;
}

.artifact-image-wrap img:hover {
    transform: scale(1.04);
    filter: brightness(1.08);
}

.artifact-card[data-artifact="training-history"] .artifact-image-wrap img {
    object-fit: contain;
}

.artifact-card.is-missing .artifact-image-wrap::before {
    content: "Artifact unavailable";
    color: var(--muted);
    font-weight: 780;
}

.artifact-card p,
.class-card p,
.guardrail-grid p {
    margin-bottom: 0;
    color: var(--muted);
}

.class-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    gap: 18px;
    align-items: stretch;
}

.class-card {
    display: grid;
    gap: 13px;
    padding: 14px;
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.class-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.class-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 240px;
    border-radius: 6px;
    background: #101827;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), filter 0.25s ease;
}

.class-card img:hover {
    transform: scale(1.04);
    filter: brightness(1.08);
}

.class-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.class-label,
.class-index {
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 790;
    white-space: nowrap;
}

.class-label {
    width: fit-content;
    padding: 0 8px;
    background: #e8edff;
    color: #3730a3;
}

.class-card:nth-child(2) .class-label {
    background: #fff2dd;
    color: #92400e;
}

.class-card:nth-child(3) .class-label {
    background: #e4f5ea;
    color: var(--success);
}

.class-card:nth-child(4) .class-label {
    background: #e6f4f1;
    color: var(--primary-dark);
}

.class-index {
    color: var(--muted);
}

.class-card-copy {
    display: grid;
    gap: 6px;
}

.class-card-copy h3 {
    margin-bottom: 0;
}

.class-card-copy p {
    font-size: 0.86rem;
    line-height: 1.55;
}

.guardrail-section {
    display: grid;
    grid-template-columns: minmax(260px, 0.68fr) minmax(0, 1fr);
    gap: 18px;
    align-items: stretch;
}

.guardrail-copy {
    padding: 22px;
    border-radius: 8px;
    background: #fff8ea;
    box-shadow: var(--shadow-sm);
}

.guardrail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.guardrail-grid article {
    padding: 16px;
}

.guardrail-grid span {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-bottom: 14px;
    border-radius: 8px;
    background: #fff0d7;
    color: var(--warning);
    font-weight: 790;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes panelIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}

@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .topbar {
        padding: 0 24px;
    }

    .nav-toggle {
        display: flex;
    }

    .mobile-nav {
        position: fixed;
        top: 72px;
        right: 16px;
        left: 16px;
        z-index: 30;
        display: none;
        padding: 12px;
        border-radius: 8px;
        background: var(--surface-plain);
        box-shadow: var(--shadow-md);
    }

    body.nav-open .mobile-nav {
        display: grid;
    }

    .workspace-header {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .case-meta {
        max-width: 760px;
    }
}

@media (max-width: 980px) {
    .workbench-grid,
    .guardrail-section {
        grid-template-columns: 1fr;
    }

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

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

    .class-card:nth-child(n) {
        margin-top: 0;
    }

    .result-panel {
        min-height: auto;
    }
}

@media (max-width: 720px) {
    .topbar {
        grid-template-columns: auto minmax(0, 1fr);
        gap: 12px;
        padding: 12px 14px;
    }

    .status-pill {
        grid-column: 1 / -1;
        width: 100%;
        max-width: none;
        margin-bottom: 0;
    }

    main {
        width: min(100% - 24px, 1400px);
        padding-top: 24px;
    }

    .workspace-section,
    .content-section {
        scroll-margin-top: 126px;
    }

    .content-section {
        padding-top: 46px;
    }

    h1 {
        font-size: 2.05rem;
    }

    h2 {
        font-size: 1.32rem;
    }

    .case-meta,
    .class-grid,
    .guardrail-grid,
    .upload-checklist,
    .workflow-guide {
        grid-template-columns: 1fr;
    }

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

    .panel,
    .workspace-section[data-stage="empty"] .upload-panel {
        padding: 16px;
    }

    .panel-header,
    .subsection-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .upload-area,
    .workspace-section[data-stage="empty"] .upload-area,
    .image-preview img {
        min-height: 252px;
        height: 252px;
    }

    .empty-result {
        min-height: 318px;
    }

    .confidence-card strong {
        font-size: 2.35rem;
    }
}

/* Image Preview Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 26, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 1.8rem;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, color 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #2563eb;
    transform: scale(1.05);
}

.lightbox-content {
    max-width: 85%;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lightbox.active .lightbox-content {
    transform: scale(1);
}

.lightbox-content img {
    max-width: 100%;
    max-height: 75vh;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #090d16;
    object-fit: contain;
}

.lightbox-caption {
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    padding: 8px 24px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.6rem;
    }
    h2 {
        font-size: 1.15rem;
    }
    .topbar {
        padding: 0 10px;
    }
    .panel,
    .workspace-section[data-stage="empty"] .upload-panel {
        padding: 12px;
    }
    .upload-area,
    .workspace-section[data-stage="empty"] .upload-area,
    .image-preview img {
        min-height: 200px;
        height: 200px;
    }
    .confidence-card strong {
        font-size: 2rem;
    }
    .lightbox-content {
        max-width: 95%;
        max-height: 90%;
    }
    .lightbox-close {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
    .lightbox-caption {
        font-size: 0.9rem;
        padding: 6px 16px;
    }
}
