:root {
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #1e293b;
  background: #fff;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --line: #e2e8f0;
  --sidebar-width: 256px;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
a { color: inherit; }
button, input { font: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid #6366f1; outline-offset: 3px; }

.login-layout { display: grid; grid-template-columns: 1fr 1fr; min-height: 100svh; }
.login-cover { min-width: 0; display: grid; place-items: center; overflow: hidden; }
.login-cover img { display: block; width: 100%; max-height: 100svh; object-fit: contain; }
.login-main { display: grid; place-items: center; padding: 40px; }
.login-panel { width: min(100%, 420px); margin-top: -36px; }
.login-logo { display: block; margin: 0 auto 14px; object-fit: contain; }
.login-panel h1 { margin: 0; color: #111827; font-size: 30px; text-align: center; line-height: 1.4; letter-spacing: -.04em; }
.login-intro { margin: 23px 0 39px; color: #6b7280; text-align: center; font-size: 16px; }
.login-fields { display: grid; gap: 20px; margin-bottom: 22px; }
.login-label { display: block; color: #374151; margin-bottom: 8px; font-size: 14px; font-weight: 500; }
.login-field { display: flex; align-items: center; min-height: 48px; padding: 11px 15px; border: 1px solid #d1d5db; border-radius: 12px; font-size: 15px; color: #4b5563; overflow-wrap: anywhere; }
.login-input { display: block; width: 100%; background: white; color: #111827; }
.login-password { position: relative; }
.login-password .login-input { padding-right: 52px; }
.login-password .login-input::-ms-reveal { display: none; }
.password-toggle { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: #64748b; cursor: pointer; }
.password-toggle:hover { background: #f3f4f6; color: #334155; }
.password-eye { position: relative; width: 15px; height: 15px; border: 1.5px solid currentColor; border-radius: 72% 20%; transform: rotate(45deg); }
.password-eye::before { content: ''; position: absolute; top: 50%; left: 50%; width: 5px; height: 5px; border-radius: 50%; background: currentColor; transform: translate(-50%, -50%); }
.password-toggle[aria-pressed="true"]::after { content: ''; position: absolute; top: 50%; left: 50%; width: 21px; height: 1.5px; background: currentColor; transform: translate(-50%, -50%) rotate(-45deg); }
.login-button { display: grid; min-height: 48px; place-items: center; border-radius: 12px; background: #203a86; box-shadow: 0 4px 10px #203a8627; color: white; text-decoration: none; font-weight: 650; font-size: 15px; }
button.login-button { width: 100%; border: 0; cursor: pointer; }
.login-button:hover { background: #193271; }
.login-error { margin: 0; color: #b91c1c; font-size: 14px; }
.admin-entry { margin: 18px 0 0; color: #4b5563; text-align: center; font-size: 14px; }
.admin-entry a { text-decoration: none; }
.admin-entry a:hover { color: #1e3a8a; text-decoration: underline; }

.dashboard { min-height: 100svh; }
.sidebar { position: fixed; z-index: 2; inset: 0 auto 0 0; display: flex; flex-direction: column; width: var(--sidebar-width); border-right: 1px solid #d1d5db; background: white; box-shadow: 0 1px 3px #0f172a0e; }
.brand-row { min-height: 69px; display: flex; align-items: center; gap: 8px; padding: 15px 13px 15px 16px; border-bottom: 1px solid #d1d5db; }
.brand { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; color: #111827; text-decoration: none; font-size: 14px; font-weight: 700; white-space: nowrap; }
.brand img { flex: none; object-fit: contain; border-radius: 7px; }
.icon-button { flex: none; min-width: 31px; height: 34px; padding: 0 7px; border: 0; border-radius: 7px; background: white; color: #4b5563; font-size: 23px; line-height: 1; cursor: pointer; }
.icon-button:hover { background: #f3f4f6; color: #111827; }
.expand-sidebar { position: fixed; z-index: 3; top: 15px; left: 14px; min-width: 36px; border: 1px solid #d1d5db; box-shadow: 0 1px 3px #0f172a15; font-size: 17px; }
.sidebar-nav { flex: 1; display: grid; align-content: start; gap: 5px; padding: 16px; }
.nav-item { display: flex; gap: 12px; align-items: center; padding: 12px 15px; border: 1px solid transparent; border-radius: 8px; background: #fff; color: #475569; text-align: left; font-size: 14px; font-weight: 600; cursor: pointer; }
.nav-item:hover:not(.nav-current):not(:disabled) { background: #f8fafc; }
.nav-current { border-color: #bfdbfe; background: #eff6ff; color: #1e3a8a; }
.nav-document { position: relative; width: 15px; height: 18px; border: 1.6px solid; border-radius: 3px; }
.nav-document::after { content: ""; position: absolute; inset: 5px 3px auto; height: 1px; background: currentColor; box-shadow: 0 4px currentColor; }
.nav-stack { box-shadow: 3px 3px 0 -1px #fff, 3px 3px 0 currentColor; }
.sidebar-footer { display: grid; gap: 12px; padding: 16px; border-top: 1px solid #d1d5db; }
.sidebar-status { display: grid; gap: 5px; padding-bottom: 12px; border-bottom: 1px solid #e5e7eb; color: #4b5563; font-size: 12px; }
.service-state { display: flex; align-items: center; gap: 7px; }
.service-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #d97706; }
.service-state.ready::before { background: #059669; }
.sidebar-user, .sign-out { padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; font-weight: 550; }
.sidebar-user { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: #f3f4f6; }
.sign-out { text-decoration: none; text-align: center; }
button.sign-out { width: 100%; background: white; color: inherit; cursor: pointer; }
.sign-out:hover { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.workspace-frame { margin-left: var(--sidebar-width); padding: 24px; }
.sidebar-collapsed .sidebar { display: none; }
.sidebar-collapsed .workspace-frame { margin-left: 0; }
.workspace { max-width: 1660px; min-height: calc(100svh - 48px); margin: 0 auto; padding: 24px; border: 1px solid #e5e7eb; border-radius: 12px; background: #f6f8fa; box-shadow: 0 1px 2px #0f172a0a; }
.workspace-header { display: inline-flex; margin-bottom: 30px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 1px 2px #0f172a0a; }
.mode-button { padding: 9px 14px; border: 0; border-radius: 8px; background: #fff; color: #475569; font-size: 14px; font-weight: 650; line-height: 20px; cursor: pointer; white-space: nowrap; }
.mode-button:not([aria-pressed="true"]):hover:not(:disabled) { background: #f1f5ff; }
.mode-button[aria-pressed="true"] { background: var(--accent); color: white; }
.mode-button span { margin-right: 3px; }
.work-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.work-controls { min-width: 0; }
.card { padding: 30px 32px 32px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 1px 2px #0f172a0a; }
.card + .card { margin-top: 24px; }
.card h2 { display: flex; align-items: center; gap: 9px; margin: 0 0 22px; color: #334155; font-size: 16px; font-weight: 650; line-height: 22px; }
.card h2 span { font-size: 18px; }

.dropzone { position: relative; display: flex; min-height: 280px; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 30px 20px; border: 2px dashed #7770e9; border-radius: 12px; text-align: center; cursor: pointer; }
.dropzone:hover, .dropzone.dragging, .dropzone:focus-within { border-color: var(--accent); background: #f6f5ff; }
.dropzone:focus-within { outline: 2px solid #a5b4fc; outline-offset: 2px; }
.dropzone.has-file { min-height: 146px; background: #f8faff; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { margin-bottom: 3px; font-size: 50px; line-height: 1.2; }
.dropzone.has-file .drop-icon { font-size: 30px; }
.drop-title { max-width: 100%; color: #475569; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.pick-label { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 2px; }
.drop-hint { color: #64748b; font-size: 13px; }
.drop-requirement { margin-top: 4px; color: #a05312; font-size: 13px; line-height: 1.6; }
.dropzone.has-file .drop-requirement { display: none; }
.upload-notice { margin: 12px 0 0; color: #475569; font-size: 14px; line-height: 1.6; }
.upload-notice.error, .notice.error { color: #b91c1c; }
.file-details { margin-top: 21px; }
.file-summary { display: flex; flex-wrap: wrap; gap: 7px 18px; margin-bottom: 20px; color: #64748b; font-size: 13px; }
.file-summary strong { color: #4338ca; }
.dates { font-variant-numeric: tabular-nums; }
.file-actions { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 16px; }
.topic-field { flex: 1 1 250px; }
.topic-field label { display: block; margin-bottom: 7px; color: #334155; font-size: 14px; font-weight: 600; }
.topic-field label span { color: #64748b; font-size: 12px; font-weight: 400; }
#topic { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid #cbd5e1; border-radius: 7px; background: white; color: #1e293b; font-size: 14px; }
#topic::placeholder { color: #64748b; }
.buttons { display: flex; gap: 9px; }
.primary, .secondary { display: inline-flex; min-height: 40px; padding: 8px 16px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.primary { background: var(--accent); color: white; }
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.secondary { background: white; color: #475569; border-color: var(--line); }
.secondary:hover:not(:disabled) { background: #f8fafc; }
button:disabled { opacity: .55; cursor: default; }
.notice { margin: 0; color: #475569; font-size: 14px; line-height: 1.6; }
.progress-card progress { display: block; width: 100%; height: 8px; margin-top: 15px; accent-color: var(--accent); }
.result-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc; }
.result-row strong { color: #047857; font-size: 14px; }
.result-row p { margin: 5px 0 0; color: #475569; font-size: 13px; overflow-wrap: anywhere; }

.batch-dropzone { min-height: 170px; padding: 22px 15px; }
.batch-dropzone .drop-icon { font-size: 31px; }
.batch-queue { margin-top: 21px; }
.batch-summary { display: flex; align-items: baseline; justify-content: space-between; gap: 7px 12px; flex-wrap: wrap; margin-bottom: 10px; }
.batch-summary h3 { margin: 0; color: #334155; font-size: 14px; }
.batch-summary span { color: #64748b; font-size: 12px; line-height: 1.5; }
.batch-list { display: grid; gap: 7px; max-height: 385px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.batch-row { min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 7px; padding: 6px; border: 1px solid var(--line); border-radius: 9px; }
.batch-row.selected { border-color: #c7d2fe; background: #f5f7ff; }
.batch-file-name { display: grid; gap: 4px; min-width: 0; width: 100%; padding: 5px 7px; border: 0; border-radius: 5px; background: transparent; color: #1e293b; text-align: left; cursor: pointer; }
.batch-file-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.batch-file-state { color: #64748b; font-size: 12px; overflow-wrap: anywhere; line-height: 1.5; }
.batch-row.running .batch-file-state { color: #4338ca; }
.batch-row.done .batch-file-state { color: #047857; }
.batch-row.failed .batch-file-state { color: #b91c1c; }
.batch-row-actions { display: flex; gap: 3px; align-items: center; }
.batch-row-actions a, .batch-remove { padding: 5px 6px; border: 0; border-radius: 5px; background: transparent; font-size: 12px; cursor: pointer; white-space: nowrap; }
.batch-row-actions a { color: var(--accent-dark); font-weight: 650; text-decoration: none; }
.batch-remove { color: #64748b; }
.batch-row-actions a:hover, .batch-remove:hover:not(:disabled) { background: #eaf0ff; }
.batch-progress { display: block; width: 100%; height: 7px; margin-top: 12px; accent-color: var(--accent); }
.batch-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }

.draft-card { position: sticky; top: 24px; display: flex; flex-direction: column; height: max(415px, calc(100svh - 180px)); min-width: 0; padding: 0; overflow: hidden; }
.draft-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 21px 24px; border-bottom: 1px solid var(--line); }
.draft-header h2 { margin: 0; }
.draft-heading-group { min-width: 0; }
.draft-file { max-width: 100%; margin: 5px 0 0; color: #64748b; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-status { flex: none; }
.draft-status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 20px; background: #f1f5f9; color: #475569; font-size: 12px; white-space: nowrap; }
.draft-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.draft-status.active { background: #eef2ff; color: #4338ca; }
.draft-status.complete { background: #ecfdf5; color: #047857; }
.draft-status.error { background: #fef2f2; color: #b91c1c; }
.draft-scroll { flex: 1; min-height: 0; padding: 25px 24px 32px; overflow: auto; scrollbar-gutter: stable; }
.draft-scroll:focus-visible { outline: 2px solid #a5b4fc; outline-offset: -2px; }
.draft-empty { display: grid; min-height: 100%; place-content: center; justify-items: center; text-align: center; color: #64748b; font-size: 14px; line-height: 1.6; }
.draft-empty-icon { position: relative; width: 28px; height: 35px; border: 2px solid #a5b4fc; border-radius: 6px; background: #eef2ff; }
.draft-empty-icon::after { content: ""; position: absolute; left: 5px; top: 9px; width: 14px; height: 2px; background: #a5b4fc; box-shadow: 0 6px #a5b4fc, 0 12px #a5b4fc; }
.draft-empty p { margin: 14px 0 0; }
.draft-title { margin: 0 0 24px; color: #172554; font-size: clamp(18px, 2vw, 24px); font-weight: 700; line-height: 1.5; }
.draft-body h3 { margin: 23px 0 10px; color: #1e293b; font-size: 17px; }
.draft-body h3:first-child { margin-top: 0; }
.draft-body h4 { margin: 14px 0 5px; color: #334155; font-size: 14px; }
.draft-body p { margin: 0 0 11px; color: #334155; font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
.draft-body a { color: var(--accent-dark); text-underline-offset: 2px; }

@media (max-width: 960px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-cover { display: none; }
  .login-main { min-height: 100svh; padding: 32px 24px; }
  .login-panel { margin: 0; }
  .workspace-frame { padding: 15px; }
  .workspace { padding: 18px; }
  .card { padding: 21px; }
  .work-columns { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .draft-card { position: static; height: clamp(415px, 74svh, 700px); padding: 0; }
}
@media (max-width: 720px) {
  .workspace-frame { margin-left: 0; padding: 12px; }
  .workspace { padding: 16px; min-height: calc(100svh - 24px); }
  .workspace-header { margin-left: 33px; margin-bottom: 22px; }
  .sidebar { box-shadow: 12px 0 30px #0f172a2d; }
  .card { padding: 17px; }
  .draft-card { padding: 0; }
  .card h2 { margin-bottom: 16px; }
  .dropzone { min-height: 230px; }
  .batch-dropzone { min-height: 155px; }
  .result-row { align-items: flex-start; flex-direction: column; }
}
