:root {
    color-scheme: light;
    --ink: #20201f;
    --muted: #6d6b68;
    --paper: #f5f2ec;
    --card: rgba(255, 255, 255, 0.88);
    --line: #ddd7cd;
    --accent: #9c3f30;
    --accent-dark: #742c22;
    --soft-accent: #f2ddd7;
    --shadow: 0 18px 45px rgba(58, 48, 39, 0.09);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% 5%, rgba(156, 63, 48, 0.12), transparent 28rem),
        linear-gradient(145deg, #f8f6f1 0%, var(--paper) 52%, #eee9e0 100%);
    font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

button, label, input { font: inherit; }

.page-shell {
    width: min(1480px, calc(100% - 40px));
    margin: 0 auto;
    padding: 46px 0 60px;
}

.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 32px;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.18em;
}

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

h1 {
    margin-bottom: 10px;
    font-family: Georgia, "Noto Serif SC", serif;
    font-size: clamp(29px, 4vw, 46px);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.subtitle, .brand, .upload-copy p, .file-name {
    color: var(--muted);
}

.subtitle { margin-bottom: 0; }
.brand { margin-bottom: 3px; font-size: 13px; white-space: nowrap; }

.upload-panel, .card {
    border: 1px solid rgba(221, 215, 205, 0.9);
    background: var(--card);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.upload-panel {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) auto;
    align-items: center;
    gap: 12px 28px;
    padding: 24px 28px;
    border-radius: 18px;
    margin-bottom: 22px;
}

.upload-copy h2, .card-heading h2 { margin-bottom: 6px; font-size: 18px; }
.upload-copy p { margin-bottom: 3px; font-size: 14px; }
.privacy-note { font-size: 12px !important; }

#upload-form { display: flex; gap: 10px; }

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0 20px;
    cursor: pointer;
    font-weight: 650;
    transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--accent); }
.button.primary:hover:not(:disabled) { background: var(--accent-dark); }
.button.secondary { color: var(--ink); border-color: var(--line); background: #fff; }
.button:disabled { cursor: not-allowed; opacity: 0.45; }

.file-name {
    grid-column: 1 / -1;
    overflow: hidden;
    margin: 0;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(420px, 0.92fr);
    gap: 22px;
    align-items: start;
}

.left-column { display: grid; gap: 22px; min-width: 0; }
.card { border-radius: 18px; padding: 22px; }

.card-heading {
    display: flex;
    min-height: 34px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.card-heading h2 { margin: 0; }

.status {
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 650;
}

.status.idle { color: #625f59; background: #ece8e0; }
.status.loading { color: #725814; background: #f4e8ba; }
.status.success { color: #24613b; background: #dcecdf; }
.status.error { color: #812f25; background: var(--soft-accent); }

.preview-card { min-height: 430px; }
.preview-placeholder, #preview {
    width: 100%;
    height: 348px;
    border-radius: 12px;
}

.preview-placeholder {
    display: grid;
    place-items: center;
    border: 1px dashed #cfc7bb;
    color: #8a857d;
    background-color: #f1eee8;
    background-image:
        linear-gradient(45deg, #e7e2da 25%, transparent 25%),
        linear-gradient(-45deg, #e7e2da 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e7e2da 75%),
        linear-gradient(-45deg, transparent 75%, #e7e2da 75%);
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-size: 20px 20px;
    font-size: 14px;
}

#preview {
    object-fit: contain;
    background: #ece8e1;
}

.report-card { position: sticky; top: 18px; min-width: 0; }
.report-placeholder { min-height: 510px; color: #8b877f; display: grid; place-items: center; }

#report {
    overflow: auto;
    max-height: calc(100vh - 240px);
    min-height: 510px;
    margin: 0;
    color: #282725;
    font: 13px/1.75 "Cascadia Mono", "Consolas", "Microsoft YaHei", monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.text-button {
    border: 0;
    color: var(--accent);
    background: transparent;
    cursor: pointer;
    font-weight: 650;
}

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

.chart-item {
    min-width: 0;
    border: 1px solid #e5dfd5;
    border-radius: 13px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.76);
}

.chart-item.wide { grid-column: 1 / -1; }
.chart-item h3 { margin-bottom: 12px; font-size: 14px; }
.chart-item canvas { display: block; width: 100%; }

.legend-row { margin: 8px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.legend { display: inline-block; width: 16px; height: 2px; margin: 0 5px 3px 10px; vertical-align: middle; }
.legend.dark-line { background: #456890; }
.legend.light-line { background: #b34e42; }
.stacked-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; font-size: 12px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 50%; }

.colors-chart { display: grid; gap: 9px; }
.color-row { display: grid; grid-template-columns: 34px 76px minmax(0, 1fr) 52px; align-items: center; gap: 9px; font-size: 12px; }
.color-swatch { width: 34px; height: 22px; border: 1px solid rgba(0, 0, 0, 0.12); border-radius: 5px; }
.color-code { color: var(--muted); font-family: monospace; }
.color-track { height: 9px; overflow: hidden; border-radius: 999px; background: #ece8e1; }
.color-fill { height: 100%; border-radius: inherit; }
.color-percent { text-align: right; font-variant-numeric: tabular-nums; }

.error-box {
    border: 1px solid #ddb7af;
    border-radius: 10px;
    padding: 14px;
    color: #762d24;
    background: #f8e8e4;
    line-height: 1.6;
}

[hidden] { display: none !important; }

@media (max-width: 980px) {
    .workspace { grid-template-columns: 1fr; }
    .report-card { position: static; }
    #report { max-height: none; }
}

@media (max-width: 680px) {
    .page-shell { width: min(100% - 24px, 1480px); padding-top: 26px; }
    .hero { align-items: flex-start; flex-direction: column; gap: 12px; }
    .brand { white-space: normal; }
    .upload-panel { grid-template-columns: 1fr; padding: 20px; }
    #upload-form { display: grid; grid-template-columns: 1fr 1fr; }
    .file-name { grid-column: 1; }
    .card { padding: 17px; }
    .preview-card { min-height: 340px; }
    .preview-placeholder, #preview { height: 270px; }
    .charts-grid { grid-template-columns: 1fr; }
    .chart-item.wide { grid-column: auto; }
    .color-row { grid-template-columns: 30px 68px minmax(0, 1fr) 46px; gap: 6px; }
}
