:root {
    color-scheme: light;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --bg: #F4E6C8;
    --surface: #fffaf0;
    --surface-2: #f3e9d2;
    --border: #DCC9A3;
    --text: #6F5F4A;
    --muted: #8A624A;
    --accent: #8A624A;
    --accent-hover: #6F5F4A;
    --accent-soft: #efe3cb;
    --on-accent: #F4E6C8;
    --danger: #b5482f;
    --shadow: 0 1px 3px rgba(111,95,74,.10), 0 8px 24px rgba(111,95,74,.08);
    --radius: 14px;
    --radius-sm: 10px;
    color: var(--text);
    background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
main {
    display: grid;
    grid-template-columns: minmax(260px, 310px) minmax(0, 1fr);
    gap: 18px;
    max-width: 1140px;
    margin: auto;
    padding: 16px;
    align-items: start;
}
section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
button, input { font: inherit; }
button {
    min-height: 40px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }
button:not(:disabled):hover { border-color: var(--accent); }
:focus-visible, .drop:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.drop {
    display: grid;
    gap: 8px;
    text-align: center;
    padding: 22px 8px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
}
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop span, .muted { font-size: .86rem; color: var(--muted); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
#file-info { overflow-wrap: anywhere; }
.range-row { display: flex; gap: 8px; margin-top: 8px; }
#range { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; background: var(--surface); color: var(--text); }
#status { font-size: .9rem; color: var(--muted); }
#status[data-error="true"] { color: var(--danger); }
.primary, #pages button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.primary { width: 100%; }
.primary:not(:disabled):hover, #pages button[aria-pressed="true"]:hover { background: var(--accent-hover); }
header { display: flex; align-items: center; justify-content: space-between; }
h1 { font-size: 1.1rem; margin: 0; }
.order-help { margin: 8px 0; }
#pages { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 6px; list-style: none; padding: 3px; max-height: 185px; overflow: auto; }
#pages:empty { display: none; }
#pages li { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: grab; }
#pages li.over { border-color: var(--accent); background: var(--accent-soft); }
#pages button:first-child { flex: 1; }
.preview { display: grid; justify-items: center; align-content: center; gap: 8px; min-height: 300px; border-radius: var(--radius-sm); padding: 12px; background: var(--surface-2); }
#preview-status { margin: 0; font-size: .86rem; color: var(--muted); }
canvas { max-width: 100%; max-height: 680px; width: auto; height: auto; object-fit: contain; background: #fff; box-shadow: var(--shadow); }
@media (max-width: 700px) {
    main { grid-template-columns: 1fr; gap: 12px; padding: 10px; }
    section { padding: 14px; }
}
