:root {
    --ink: #172033;
    --muted: #667085;
    --line: #d9dee8;
    --panel: #ffffff;
    --canvas: #f3f5f8;
    --navy: #173a63;
    --blue: #2f6fed;
    --blue-soft: #edf4ff;
    --green: #13795b;
    --green-soft: #eaf8f2;
    --red: #c33434;
    --red-soft: #fff0ef;
    --amber: #a05a00;
    --amber-soft: #fff7e6;
    --shadow: 0 12px 30px rgba(23, 32, 51, .08);
    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    color: var(--ink);
    background: var(--canvas);
    font-family: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
}

button, input { font: inherit; }

button:focus-visible,
input:focus-visible,
summary:focus-visible,
.image-button:focus-visible {
    outline: 3px solid rgba(47, 111, 237, .28);
    outline-offset: 2px;
}

.app-header {
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.header-inner,
main {
    width: min(1220px, calc(100% - 40px));
    margin: 0 auto;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

h1 {
    margin: 0;
    font-size: 19px;
    line-height: 1.3;
    letter-spacing: .01em;
}

main { padding: 28px 0 56px; }

.panel {
    background: var(--panel);
    border: 1px solid rgba(217, 222, 232, .9);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.upload-panel { padding: 24px; }

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-heading h2,
.section-heading h3 {
    margin: 0;
    font-size: 17px;
    line-height: 1.4;
}

.section-heading p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.upload-grid,
.image-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.file-field {
    position: relative;
    display: block;
    min-height: 112px;
    padding: 18px;
    border: 1px dashed #aab4c5;
    border-radius: 11px;
    background: #fafbfc;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease;
}

.file-field:hover {
    border-color: var(--blue);
    background: var(--blue-soft);
}

.file-field.paste-target {
    border-color: #6f8ed8;
    background: #f7faff;
}

.file-field.has-file {
    border-style: solid;
}

.file-field.drag-active {
    border-color: var(--blue);
    border-style: solid;
    background: var(--blue-soft);
    box-shadow: inset 0 0 0 2px rgba(47, 111, 237, .12);
}

.file-field input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

.file-caption {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--navy);
    font-size: 14px;
    font-weight: 700;
}

.file-action { color: var(--blue); }

.paste-input {
    display: block;
    width: 100%;
    height: 34px;
    margin-top: 18px;
    padding: 0;
    overflow: hidden;
    border: 0;
    outline: 0;
    color: var(--muted);
    background: transparent;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: text;
}

.paste-input::placeholder {
    color: var(--muted);
    opacity: 1;
}

.paste-input:focus::placeholder {
    color: transparent;
}

.mobile-file-tip {
    display: none;
    margin: 8px 0 0;
    color: var(--navy);
    font-size: 12px;
    line-height: 1.4;
}

.mobile-selection-actions {
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.mobile-selection-actions button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 12px;
}

.image-format-note {
    display: inline-block;
    margin-left: 7px;
    padding: 4px 7px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
}

.upload-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 18px;
}

.upload-notice {
    margin-top: 16px;
    padding: 13px 15px;
    color: var(--amber);
    background: var(--amber-soft);
    border: 1px solid #f5dfb0;
    border-radius: 9px;
    font-size: 13px;
    line-height: 1.7;
}

.upload-notice strong {
    display: block;
    margin-bottom: 2px;
}

.upload-notice ol {
    margin: 0;
    padding-left: 22px;
}

.primary-button,
.secondary-button {
    min-height: 42px;
    padding: 0 22px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    transition: background .18s ease, opacity .18s ease;
}

.primary-button {
    border: 1px solid var(--blue);
    color: #fff;
    background: var(--blue);
}

.primary-button:hover { background: #245bc5; }

.primary-button:disabled {
    cursor: wait;
    opacity: .62;
}

.secondary-button {
    border: 1px solid var(--line);
    color: var(--ink);
    background: #fff;
}

.secondary-button:hover { background: #f7f8fa; }

.progress {
    display: none;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding: 12px 14px;
    color: var(--navy);
    background: var(--blue-soft);
    border-radius: 9px;
    font-size: 13px;
}

.progress.visible { display: flex; }

.spinner {
    width: 17px;
    height: 17px;
    border: 2px solid #bcd1f7;
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#results {
    display: none;
    margin-top: 18px;
}

#results.visible { display: block; }

.result-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 210px;
    gap: 18px;
    align-items: stretch;
}

.verdict {
    padding: 24px;
    border-left: 5px solid var(--green);
}

.verdict.inconsistent { border-left-color: var(--red); }
.verdict.attention { border-left-color: var(--amber); }
.verdict.unable { border-left-color: var(--amber); }

.eyebrow {
    margin: 0 0 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
}

.verdict h2 {
    margin: 0;
    color: var(--green);
    font-size: 29px;
    line-height: 1.2;
}

.verdict.inconsistent h2 { color: var(--red); }
.verdict.attention h2 { color: var(--amber); }
.verdict.unable h2 { color: var(--amber); }

.verdict-reason {
    display: grid;
    gap: 7px;
    max-width: 800px;
    margin: 13px 0 0;
    padding: 0;
    list-style: none;
    color: #475467;
    font-size: 14px;
    line-height: 1.7;
}

.verdict-reason li {
    position: relative;
    padding-left: 17px;
    line-break: strict;
    text-wrap: pretty;
}

.verdict-reason li::before {
    position: absolute;
    top: .68em;
    left: 1px;
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    content: "";
    opacity: .55;
}

.duration-card {
    display: flex;
    min-height: 148px;
    padding: 22px;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    border: 1px solid #cfe0ff;
    background:
        radial-gradient(circle at 100% 0, rgba(47, 111, 237, .16), transparent 48%),
        #f7faff;
}

.duration-card .eyebrow {
    color: #315c9a;
}

.duration-reading {
    display: flex;
    align-items: baseline;
    gap: 6px;
    color: var(--blue);
    font-variant-numeric: tabular-nums;
}

.duration-value {
    font-size: 38px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.04em;
}

.duration-unit {
    font-size: 14px;
    font-weight: 700;
}

.duration-caption {
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.duration-card.incomplete .duration-reading {
    color: var(--amber);
}

.result-section {
    margin-top: 18px;
    padding: 24px;
}

.image-card {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fbfcfd;
}

.image-card h4 {
    margin: 0 0 11px;
    font-size: 14px;
}

.image-button {
    display: grid;
    width: 100%;
    min-height: 360px;
    padding: 0;
    place-items: center;
    overflow: hidden;
    border: 0;
    border-radius: 8px;
    background: #eef1f5;
    cursor: zoom-in;
}

.image-button img {
    display: block;
    width: 100%;
    max-height: 560px;
    object-fit: contain;
}

.legend {
    display: flex;
    gap: 18px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 12px;
}

.legend span::before {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 6px;
    border-radius: 2px;
    content: "";
}

.legend .legend-a::before { background: #d97706; }
.legend .legend-b::before { background: #0f766e; }

.difference-list {
    display: grid;
    gap: 12px;
}

.difference-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
}

.difference-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 15px 17px;
    border-bottom: 1px solid #edf0f4;
    background: #fafbfc;
}

.difference-title {
    margin: 0;
    font-size: 14px;
}

.difference-body {
    display: grid;
    grid-template-columns: 130px 1fr;
    margin: 0;
    padding: 8px 17px 14px;
}

.difference-body dt,
.difference-body dd {
    margin: 0;
    padding: 9px 0;
    border-bottom: 1px solid #edf0f4;
    font-size: 13px;
    line-height: 1.65;
}

.difference-body dt {
    color: var(--muted);
    font-weight: 700;
}

.difference-body dd {
    min-width: 0;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.crops {
    margin: 0 17px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.crops summary {
    padding: 11px 13px;
    color: var(--navy);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.crop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    padding: 0 12px 12px;
}

.crop-card {
    padding: 8px;
    border: 1px solid #edf0f4;
    border-radius: 7px;
    background: #fafbfc;
}

.crop-card span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 11px;
}

.crop-card img {
    display: block;
    width: 100%;
    max-height: 160px;
    object-fit: contain;
    border-radius: 4px;
    cursor: zoom-in;
}

.empty-state {
    margin: 0;
    padding: 20px;
    color: var(--muted);
    background: #fafbfc;
    border: 1px dashed var(--line);
    border-radius: 9px;
    font-size: 13px;
    text-align: center;
}

.result-actions {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.result-notice {
    margin-top: 18px;
    padding: 16px 18px;
    color: var(--amber);
    background: var(--amber-soft);
    border: 1px solid #f5dfb0;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.75;
}

.result-notice h3 {
    margin: 0 0 4px;
    font-size: 13px;
}

.result-notice ol {
    margin: 0;
    padding-left: 22px;
}

.result-notice li + li {
    margin-top: 2px;
}

dialog {
    width: min(1080px, calc(100% - 32px));
    max-height: calc(100vh - 32px);
    padding: 12px;
    border: 0;
    border-radius: 12px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}

dialog::backdrop { background: rgba(15, 23, 42, .78); }

.modal-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.modal-close {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    background: #fff;
    cursor: pointer;
}

#modalImage {
    display: block;
    width: 100%;
    max-height: calc(100vh - 92px);
    object-fit: contain;
}

.edit-dialog {
    width: min(980px, calc(100% - 28px));
    height: min(760px, calc(100vh - 28px));
    padding: 0;
    overflow: hidden;
}

.edit-dialog::backdrop { background: rgba(15, 23, 42, .78); }

.edit-shell {
    display: grid;
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: #fff;
}

.edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
}

.edit-header h3 {
    margin: 0;
    font-size: 15px;
}

.edit-stage {
    min-height: 0;
    padding: 12px;
    background: #101828;
}

.edit-stage img {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

.edit-toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--line);
    background: #fff;
}

.edit-toolbar button {
    min-width: 0;
    padding: 0 10px;
    white-space: nowrap;
}

@media (max-width: 760px) {
    .header-inner,
    main {
        width: min(100% - 24px, 1220px);
    }

    main { padding-top: 18px; }
    .upload-panel, .result-section, .verdict { padding: 18px; }
    .upload-grid, .image-grid { grid-template-columns: 1fr; }
    .upload-footer { align-items: stretch; }
    .upload-footer {
        display: grid;
    }
    .primary-button { width: 100%; }
    .image-button { min-height: 260px; }
    .difference-body { grid-template-columns: 1fr; }
    .difference-body dt {
        padding-bottom: 0;
        border-bottom: 0;
    }

    .edit-dialog {
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .edit-stage {
        padding: 8px;
    }

    .edit-toolbar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        padding: 10px;
    }

    .edit-toolbar button {
        min-height: 38px;
        font-size: 13px;
    }

}

@media (max-width: 440px) {
    .file-field {
        min-height: 78px;
    }

    .paste-input {
        display: none;
    }

    .mobile-file-tip {
        display: block;
    }

    .mobile-selection-actions.visible {
        display: grid;
    }
}

@media (max-width: 920px) {
    .result-overview {
        grid-template-columns: 1fr;
    }

    .duration-card {
        min-height: auto;
        padding: 18px 20px;
    }

    .duration-reading {
        margin-top: 4px;
    }
}

