:root {
  color-scheme: light;
  --ink: #17201e;
  --muted: #66706d;
  --line: #dce2df;
  --paper: #f5f7f6;
  --white: #ffffff;
  --accent: #0b6b5e;
  --accent-dark: #074f46;
  --warm: #a6532d;
  --danger: #a43e3e;
  --shadow: 0 18px 50px rgba(23, 32, 30, .12);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .46; }

.topbar {
  height: 68px; padding: 0 28px; background: var(--white); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 720; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center; background: var(--ink); color: white;
  border-radius: 6px; font: 23px "Mongolian Baiti", "Noto Sans Mongolian", serif;
}
.account { display: flex; align-items: center; gap: 10px; }
.quota { color: var(--muted); margin-right: 8px; white-space: nowrap; }
.quota strong { color: var(--accent); font-size: 1.12rem; }

.workspace {
  min-height: calc(100vh - 68px); display: grid; grid-template-columns: minmax(300px, 390px) 300px minmax(420px, 1fr);
  background: var(--white);
}
.upload-pane, .history-pane, .result-pane { min-width: 0; padding: 30px; }
.upload-pane, .history-pane { border-right: 1px solid var(--line); }
.history-pane { padding-left: 22px; padding-right: 22px; background: #fafbfa; }
.result-pane { background: var(--white); overflow: hidden; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-heading.compact { align-items: center; margin-bottom: 17px; }
.section-heading h1 { margin: 3px 0 0; font-size: 1.55rem; line-height: 1.25; letter-spacing: 0; }
.section-heading h2, .result-toolbar h2, .dialog-heading h2 { margin: 0; font-size: 1.1rem; letter-spacing: 0; }
.eyebrow { margin: 0; color: var(--accent); font-size: .74rem; font-weight: 750; text-transform: uppercase; }
.limit { color: var(--muted); font-size: .76rem; white-space: nowrap; padding-top: 7px; }

.dropzone {
  height: 190px; border: 1.5px dashed #9faeaa; border-radius: 8px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 7px; background: var(--paper); color: var(--muted); transition: .18s ease;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: #edf7f4; }
.dropzone input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.dropzone strong { color: var(--ink); }
.upload-symbol { width: 36px; height: 36px; border: 1px solid var(--line); background: white; border-radius: 50%; display: grid; place-items: center; color: var(--accent); font-size: 1.35rem; }
.file-list { margin-top: 13px; max-height: 210px; overflow: auto; }
.file-item { min-height: 42px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); font-size: .84rem; }
.file-item span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-size { color: var(--muted); font-variant-numeric: tabular-nums; }
.upload-actions { display: flex; gap: 9px; margin-top: 18px; }

.primary-button, .quiet-button, .icon-button { border: 0; border-radius: 6px; min-height: 38px; padding: 0 15px; font-weight: 680; }
.primary-button { background: var(--accent); color: white; }
.primary-button:hover { background: var(--accent-dark); }
.primary-button.small { min-height: 36px; font-size: .84rem; }
.primary-button.full { width: 100%; margin-top: 5px; }
.quiet-button { background: #edf0ef; color: var(--ink); }
.quiet-button:hover { background: #e1e6e4; }
.icon-button { width: 38px; padding: 0; background: transparent; color: var(--muted); font-size: 1.35rem; }
.icon-button:hover { background: var(--paper); color: var(--ink); }
.progress-wrap { margin-top: 18px; }
.progress-label { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-bottom: 6px; }
progress { width: 100%; height: 7px; border: 0; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 6px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 6px; }
.message { color: var(--danger); font-size: .82rem; min-height: 1.2em; line-height: 1.45; }

.history-list { display: flex; flex-direction: column; gap: 7px; }
.history-item { width: 100%; border: 1px solid transparent; border-radius: 7px; background: transparent; padding: 12px; text-align: left; color: var(--ink); }
.history-item:hover { background: white; border-color: var(--line); }
.history-item.active { background: white; border-color: #a6c9c2; box-shadow: 0 3px 12px rgba(23,32,30,.05); }
.history-top { display: flex; justify-content: space-between; gap: 9px; align-items: center; }
.history-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .86rem; font-weight: 650; }
.history-meta { margin-top: 7px; display: flex; justify-content: space-between; color: var(--muted); font-size: .73rem; }
.status { border-radius: 999px; padding: 3px 7px; font-size: .68rem; font-weight: 700; white-space: nowrap; }
.status.queued { color: #76511d; background: #f8edda; }
.status.processing { color: #145c74; background: #e4f2f7; }
.status.completed { color: #176044; background: #e3f3eb; }
.status.failed { color: var(--danger); background: #f7e7e7; }

.empty-result { min-height: 55vh; display: grid; place-content: center; justify-items: center; color: #9aa3a0; }
.empty-result span { font-family: serif; font-size: 3.4rem; color: #c5cecb; }
.empty-result p { font-size: .86rem; }
.result-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.result-toolbar h2 { margin-top: 4px; font-size: 1.25rem; }
.result-meta { margin: 6px 0 0; color: var(--muted); font-size: .8rem; }
.toolbar-actions { display: flex; gap: 8px; }
.queue-banner { margin-top: 20px; padding: 13px 15px; border-left: 3px solid var(--warm); background: #fbf4eb; color: #664624; font-size: .87rem; }
.pages { margin-top: 6px; max-height: calc(100vh - 190px); overflow: auto; padding-right: 6px; }
.result-page { padding: 24px 0; border-bottom: 1px solid var(--line); }
.page-title { margin: 0 0 16px; font-size: .84rem; color: var(--muted); font-weight: 650; }
.blocks { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 22px; }
.text-block { white-space: pre-wrap; line-height: 1.8; overflow-wrap: anywhere; }
.text-block.zh { flex: 1 1 100%; }
.text-block.mn {
  writing-mode: vertical-lr; text-orientation: mixed; font-family: "Mongolian Baiti", "Noto Sans Mongolian", serif;
  font-size: 1.2rem; line-height: 1.65; min-height: 240px; max-height: 58vh; overflow-x: auto; padding: 12px 4px;
}
.failed-page { color: var(--danger); font-size: .88rem; }

dialog { border: 0; border-radius: 8px; box-shadow: var(--shadow); color: var(--ink); }
dialog::backdrop { background: rgba(18, 25, 23, .48); }
.auth-dialog { width: min(410px, calc(100vw - 30px)); padding: 28px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 1.16rem; margin-bottom: 24px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--paper); padding: 3px; border-radius: 7px; margin-bottom: 20px; }
.segmented button { border: 0; background: transparent; border-radius: 5px; min-height: 36px; color: var(--muted); }
.segmented button.active { background: white; color: var(--ink); box-shadow: 0 2px 7px rgba(23,32,30,.09); font-weight: 700; }
.auth-dialog label { display: grid; gap: 7px; margin-bottom: 15px; font-size: .82rem; font-weight: 650; }
.auth-dialog input { height: 42px; border: 1px solid var(--line); border-radius: 6px; padding: 0 11px; outline: none; }
.auth-dialog input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11,107,94,.1); }
.admin-dialog { width: min(720px, calc(100vw - 30px)); max-height: 80vh; padding: 24px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.admin-row { display: grid; grid-template-columns: 1fr 110px 100px; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding: 12px 0; font-size: .85rem; }
.admin-row input { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 5px; padding: 0 8px; }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: minmax(290px, 38%) 1fr; }
  .history-pane { grid-column: 1; grid-row: 2; border-top: 1px solid var(--line); }
  .result-pane { grid-column: 2; grid-row: 1 / span 2; }
}
@media (max-width: 720px) {
  .topbar { padding: 0 15px; }
  .account { gap: 4px; }
  .account .quiet-button { padding: 0 8px; }
  .workspace { display: block; }
  .upload-pane, .history-pane, .result-pane { padding: 22px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .history-pane { max-height: 350px; overflow: auto; }
  .result-toolbar { flex-direction: column; }
  .pages { max-height: none; }
  .quota { display: none; }
  .admin-row { grid-template-columns: 1fr 76px 84px; }
}
