:root {
    --paper: #f6f4ef;
    --surface: #ffffff;
    --ink: #17181c;
    --muted: #6c7079;
    --faint: #9a9ea7;
    --hairline: #e4e0d7;
    --hairline-strong: #d3cec3;
    --accent: #b1442f;
    --accent-soft: #f3e3df;
    --good: #2f6b4f;
    --good-soft: #e8f1ea;
    --warn: #9a6a1e;
    --warn-soft: #f8efdc;
    --radius: 14px;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --serif: "Fraunces", Georgia, "Times New Roman", serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    font-family: var(--sans);
    background: var(--paper);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.site-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 22px 32px;
    border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.brand-mark {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 22px;
    letter-spacing: -0.01em;
}
.brand-tag {
    font-size: 12.5px;
    color: var(--faint);
    text-transform: uppercase;
    letter-spacing: 0.14em;
}
.header-link {
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px solid var(--hairline-strong);
    padding-bottom: 2px;
    transition: color .15s, border-color .15s;
}
.header-link:hover { color: var(--ink); border-color: var(--ink); }

/* Layout */
.wrap {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 56px 32px 40px;
    flex: 1;
}
.intro { max-width: 620px; margin-bottom: 40px; }
.intro h1 {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(34px, 5vw, 52px);
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin-bottom: 16px;
}
.intro p { font-size: 17px; color: var(--muted); max-width: 520px; }

.workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

/* Panels */
.panel {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 22px;
    min-height: 360px;
    display: flex;
    flex-direction: column;
}
.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding-bottom: 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--hairline);
}
.panel-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--faint);
    font-weight: 600;
}
.panel-model { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.model-select {
    font-family: var(--sans);
    font-size: 13px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--hairline-strong);
    border-radius: 8px;
    padding: 6px 28px 6px 10px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236c7079' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    transition: border-color .15s;
}
.model-select:hover, .model-select:focus { border-color: var(--accent); outline: none; }

.model-meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.model-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.model-acc {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: 99px;
    padding: 2px 9px;
}
.pred-note { font-size: 12.5px; color: var(--faint); margin-top: -6px; margin-bottom: 6px; }

/* Upload */
.upload-box {
    flex: 1;
    border: 1.5px dashed var(--hairline-strong);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 20px;
    cursor: pointer;
    color: var(--muted);
    background: #fcfbf9;
    transition: border-color .18s, background .18s, color .18s;
}
.upload-box:hover { border-color: var(--accent); color: var(--ink); background: #fff; }
.upload-box.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--ink);
}
.upload-glyph { width: 64px; height: 40px; color: var(--hairline-strong); margin-bottom: 18px; }
.upload-box:hover .upload-glyph, .upload-box.drag-over .upload-glyph { color: var(--accent); }
.upload-text { font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.upload-hint { font-size: 13px; color: var(--faint); }

.image-preview { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.image-preview img {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--hairline);
    object-fit: cover;
    max-height: 340px;
}
.btn-ghost {
    align-self: flex-start;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--muted);
    background: none;
    border: 1px solid var(--hairline-strong);
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink); }

/* Samples */
.samples { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--hairline); }
.samples-label {
    display: block;
    font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--faint); font-weight: 600; margin-bottom: 10px;
}
.samples-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.sample {
    padding: 0; border: 1px solid var(--hairline); border-radius: 8px;
    background: none; cursor: pointer; overflow: hidden; aspect-ratio: 4 / 3;
    transition: border-color .15s, transform .15s;
}
.sample img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sample:hover { border-color: var(--accent); transform: translateY(-2px); }
.samples-note { display: block; font-size: 11.5px; color: var(--faint); margin-top: 9px; }

@media (max-width: 760px) {
    .samples-row { grid-template-columns: repeat(3, 1fr); }
}

/* Empty / loading */
.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--faint);
    font-size: 14px;
    text-align: center;
}
.loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
    font-size: 14px;
}
.spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--hairline-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Prediction */
.pred-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--faint); margin-bottom: 6px; }
.pred-name { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; margin-bottom: 20px; }
.pred-conf-row { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.conf-track { flex: 1; height: 8px; background: var(--hairline); border-radius: 99px; overflow: hidden; }
.conf-fill { height: 100%; background: var(--ink); border-radius: 99px; transition: width .5s ease; }
.conf-num { font-family: var(--mono); font-size: 15px; min-width: 56px; text-align: right; }

.section-label {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--faint); font-weight: 600;
    margin: 26px 0 12px;
    padding-top: 18px;
    border-top: 1px solid var(--hairline);
}
.candidates-list { display: flex; flex-direction: column; }
.candidate {
    display: grid;
    grid-template-columns: 20px 1fr 86px 44px;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--hairline);
}
.candidate:last-child { border-bottom: none; }
.cand-rank { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.cand-name { font-size: 14px; }
.cand-bar { height: 5px; background: var(--hairline); border-radius: 99px; overflow: hidden; }
.cand-bar span { display: block; height: 100%; background: var(--hairline-strong); border-radius: 99px; }
.candidate:first-child .cand-bar span { background: var(--accent); }
.cand-pct { font-family: var(--mono); font-size: 12.5px; color: var(--muted); text-align: right; }

/* Feedback */
.feedback-box { margin-top: 22px; border-radius: 10px; padding: 14px 16px; border-left: 3px solid; font-size: 14px; }
.feedback-box.confident { background: var(--good-soft); border-color: var(--good); color: #244e3a; }
.feedback-box.low_confidence { background: var(--warn-soft); border-color: var(--warn); color: #7a531a; }
.feedback-suggestion { margin-top: 6px; font-size: 13px; opacity: .85; }

/* Error */
.error-box {
    margin-top: 4px;
    background: var(--accent-soft);
    color: #7d2a1c;
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 14px;
}

/* Footer */
.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 20px 32px;
    border-top: 1px solid var(--hairline);
    color: var(--faint);
    font-size: 12.5px;
}

@media (max-width: 760px) {
    .workspace { grid-template-columns: 1fr; }
    .wrap { padding: 36px 20px; }
    .site-header, .site-footer { padding-left: 20px; padding-right: 20px; }
    .panel { min-height: auto; }
}
