:root {
  --ink: #182230;
  --muted: #586474;
  --brand: #002060;
  --brand-soft: #eef1f5;
  --paper: #fff;
  --line: #D9DEE7;
  --bg: #F6F5F1;
  --danger: #b42318;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.app-shell { min-height: 100vh; }

.sidebar {
  display: flex;
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  padding: 24px 18px;
  flex-direction: column;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.brand,
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.brand img { width: 38px; height: 38px; }
.sidebar nav { display: flex; min-height: 0; margin-top: 36px; flex: 1; flex-direction: column; gap: 6px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; }
.sidebar nav a:last-child { margin-top: auto; }
.nav-icon { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar nav a,
.bottom-nav a { padding: 11px 14px; color: var(--muted); text-decoration: none; border-radius: 10px; }
.sidebar nav a.active { color: var(--brand); background: var(--brand-soft); font-weight: 650; }

main { min-height: 100vh; margin-left: 240px; padding: 36px; }
body:not(.is-authenticated) { background: var(--bg); }
body:not(.is-authenticated) main {
  display: grid;
  min-height: 100vh;
  margin-left: 0;
  padding: 32px 20px;
  place-items: center;
}

.auth-card {
  width: min(100%, 440px);
  padding: 32px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(24, 34, 48, .08);
}

.auth-brand { justify-content: center; font-size: 18px; }
.auth-logo { width: 46px; height: 46px; }
.auth-heading { margin: 26px 0 18px; text-align: center; }
.auth-card h1,
.page-header h1 { margin: 0; }
.auth-heading p,
.auth-card p,
.panel p { color: var(--muted); line-height: 1.6; }
.auth-heading p { margin: 8px 0 0; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: #f2f4f8;
  border-radius: 8px;
}

.auth-tabs a {
  display: grid;
  min-height: 40px;
  padding: 8px 12px;
  place-items: center;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
}

.auth-tabs a.active {
  min-height: 40px;
  padding: 8px 12px;
  color: var(--brand);
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(35, 48, 86, .08);
}
form { display: grid; gap: 10px; margin-top: 22px; }
.auth-card form { margin-top: 16px; }
#code-form { margin-top: 12px; }
#register-fields { display: grid; gap: 10px; }
label { font-weight: 650; }
input {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.phone-row { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.phone-row:focus-within { outline: 3px solid rgba(0, 32, 96, .25); outline-offset: 2px; }
.phone-row span { padding-left: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.phone-row input { border: 0; outline: 0; }
input:focus-visible,
button:focus-visible,
a:focus-visible { outline: 3px solid rgba(0, 32, 96, .25); outline-offset: 2px; }
.phone-row input:focus { outline: 0; }

button {
  min-height: 48px;
  padding: 11px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:disabled { opacity: .55; cursor: not-allowed; }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.status { min-height: 24px; margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.status.error { color: var(--danger); }
.field-error { margin: -2px 0 2px; color: var(--danger); font-size: 14px; font-weight: 500; }
.password-row { display: flex; gap: 8px; }
.password-row input { flex: 1; }
.password-row button { min-width: 70px; }
.check { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 14px; font-weight: 500; line-height: 1.5; }
.check input { width: 18px; min-height: 18px; margin: 2px 0 0; }
.check a,
.status a { color: var(--brand); }
.auth-switch { margin: 18px 0 0; text-align: center; }
.text-button { display: inline; min-height: auto; padding: 0; background: transparent; color: var(--brand); font-weight: 650; }
#captcha-fields { display: grid; gap: 6px; padding: 12px; background: var(--brand-soft); border-radius: 10px; }
#captcha-fields small { color: var(--muted); }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; max-width: 1100px; margin: 0 auto 28px; }
.eyebrow { margin: 0; color: var(--brand); font-weight: 700; }
.grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); gap: 20px; max-width: 1100px; margin: auto; }
.panel { padding: 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; }
.panel h2 { margin: 0; }
input[type=file] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.chat-main { position: relative; display: flex; height: 100vh; min-height: 0; padding: 0 36px 20px; flex-direction: column; overflow: hidden; }
.chat-main.drag-active::after { position: absolute; z-index: 20; display: grid; inset: 12px; border: 2px dashed #7793d1; border-radius: 18px; background: rgba(237, 242, 252, .92); color: var(--brand); content: "松开即可添加文件"; font-size: 20px; font-weight: 700; place-items: center; pointer-events: none; }
.chat-header { display: flex; width: 100%; flex: 0 0 auto; align-items: center; justify-content: space-between; margin: 0 auto; padding: 20px 0 14px; }
.chat-header h1 { font-size: 22px; }
.clear-conversation-button { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fff; color: var(--muted); cursor: pointer; }
.clear-conversation-button:hover { border-color: #b9c4d6; color: var(--ink); }
.clear-conversation-button:disabled { cursor: wait; opacity: .55; }
.chat-workspace { display: flex; width: calc(100% + 72px); min-height: 0; margin: 0 -36px; flex: 1; flex-direction: column; }
.chat-thread { min-height: 0; padding: 20px 44px; flex: 1; overflow-y: auto; scrollbar-gutter: stable; }
.chat-welcome { display: grid; min-height: 45%; place-content: center; justify-items: center; text-align: center; }
.chat-welcome img { width: 52px; height: 52px; }
.chat-welcome h2 { margin: 16px 0 4px; font-size: 26px; }
.chat-welcome p { max-width: 520px; margin: 0; color: var(--muted); line-height: 1.6; }
.chat-status { max-width: 720px; min-height: auto; margin: 0 auto 12px; padding: 10px 14px; border-radius: 14px; background: var(--brand-soft); }
.chat-status:empty { display: none; }
.chat-stream { display: block; }
.history-pagination { width: min(100%, 720px); margin: 0 auto 18px; text-align: center; }
.history-loader { min-height: 34px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--muted); font-size: 13px; font-weight: 650; }
.chat-turn { display: flex; width: min(100%, 720px); margin: 0 auto 24px; gap: 12px; align-items: flex-start; }
.assistant-turn { justify-content: flex-start; }
.user-turn { justify-content: flex-end; }
.chat-avatar { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px; object-fit: contain; }
.chat-response { min-width: 0; flex: 1; color: var(--ink); line-height: 1.6; }
.chat-response > :first-child { margin-top: 0; }
.chat-response > :last-child { margin-bottom: 0; }
.chat-upload-bubble { max-width: min(100%, 620px); padding: 12px; border-radius: 20px 20px 5px 20px; background: #e9edf3; }
.chat-upload-bubble p { margin: 9px 2px 0; text-align: right; }
.chat-upload-grid { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.chat-upload-thumbnail { display: grid; width: 76px; gap: 4px; color: var(--muted); font-size: 11px; }
.chat-upload-preview { display: grid; width: 76px; height: 76px; overflow: hidden; place-items: center; border: 1px solid var(--line); border-radius: 14px; background: #f5f5f2; }
.chat-upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.chat-upload-preview strong { color: var(--brand); font-size: 14px; }
.chat-upload-thumbnail small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-progress-steps { display: grid; margin: 0; padding: 0; list-style: none; gap: 12px; }
.chat-progress-steps li { display: grid; grid-template-columns: 9px minmax(0, 1fr); align-items: start; gap: 9px; color: var(--muted); }
.chat-progress-steps li.is-active,
.chat-progress-steps li.is-complete { color: var(--ink); }
.chat-progress-steps strong { display: block; line-height: 1.45; }
.chat-progress-steps p { margin: 3px 0 0; color: var(--muted); }
.progress-indicator { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: var(--brand); }
.chat-progress-steps li.is-active .progress-indicator { animation: status-pulse 1.2s ease-in-out infinite; }
.chat-progress-steps li.is-done .progress-indicator,
.chat-progress-steps li.is-complete .progress-indicator { background: #18794e; }
.chat-progress-steps li.is-warning .progress-indicator { background: #9a6700; }
.chat-progress-steps li.is-error .progress-indicator,
.assistant-turn.is-error { color: var(--danger); }
.chat-disclosure { min-width: 0; }
.chat-disclosure-summary { color: var(--muted); cursor: pointer; font-weight: 650; list-style-position: outside; }
.chat-disclosure[open] .chat-disclosure-summary { margin-bottom: 12px; color: var(--ink); }
.chat-user-confirmation { max-width: min(100%, 620px); padding: 13px 16px; border-radius: 18px 18px 5px 18px; background: #e9edf3; line-height: 1.55; }
.chat-user-confirmation p { margin: 5px 0 0; white-space: pre-wrap; }
.chat-user-message { max-width: min(100%, 620px); padding: 11px 15px; border-radius: 18px 18px 5px 18px; background: #e9edf3; line-height: 1.55; white-space: pre-wrap; }
.math-content { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.math-content math { display: inline-block; max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: -.15em; white-space: normal; }
.math-content .katex-display { display: block; margin: .7em 0; overflow-x: auto; text-align: center; }
.question-diagram { display: block; width: auto; max-width: min(100%, 520px); height: auto; max-height: 360px; margin: 12px 0; object-fit: contain; }
.intake-batch { width: min(100%, 760px); }
.intake-batch-heading { margin-bottom: 12px; }
.intake-batch-heading > strong { font-size: 17px; }
.intake-batch-heading p { margin: 5px 0 0; color: var(--muted); }
.recognized-question-list { display: grid; gap: 12px; }
.recognized-question-card { padding: 15px 16px; border: 1px solid var(--line); border-left: 4px solid #b8c1cf; border-radius: 12px; background: #f7f8fa; }
.recognized-question-card.is-current { border-left-color: var(--brand); background: #f5f8ff; }
.recognized-question-card:is(.is-correct, .is-saved) { border-left-color: #18794e; }
.recognized-question-card.is-skipped { opacity: .68; }
.recognized-question-card header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.recognized-question-card section { margin-top: 12px; }
.recognized-question-card section > strong { color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.recognized-question-card p { margin: 4px 0 0; line-height: 1.7; white-space: pre-wrap; }
.question-state { padding: 3px 8px; border-radius: 999px; background: #e8ecf2; color: var(--muted); font-size: 12px; white-space: nowrap; }
.chat-candidate { padding: 2px 0; }
.chat-candidate dl { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 7px 14px; margin: 10px 0 0; }
.chat-candidate dt { color: var(--muted); font-weight: 650; }
.chat-candidate dd { margin: 0; white-space: pre-wrap; }
@keyframes status-pulse { 50% { opacity: .35; transform: scale(.72); } }
.conversation-dock { width: min(100%, 820px); margin: 0 auto; flex: 0 0 auto; }
.chat-composer { margin: 0; }
.composer-surface { padding: 10px 12px; border: 1px solid #c9d0dc; border-radius: 22px; background: var(--paper); box-shadow: 0 10px 28px rgba(24, 34, 48, .10); cursor: text; }
.composer-row { display: flex; min-height: 40px; align-items: center; justify-content: space-between; gap: 10px; }
.composer-tools { display: flex; min-width: 0; flex-wrap: wrap; align-items: center; gap: 4px; }
#chat-input { display: block; width: 100%; min-width: 0; max-height: 150px; min-height: 34px; padding: 5px 2px 7px; resize: none; overflow-y: auto; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; line-height: 1.5; }
#chat-input::placeholder { color: var(--muted); }
.send-button { width: 40px; min-height: 40px; padding: 0; flex: 0 0 40px; border-radius: 50%; font-size: 24px; line-height: 1; }
.attach-button { display: inline-flex; min-height: 40px; align-items: center; gap: 5px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); cursor: pointer; font-size: 13px; font-weight: 650; white-space: nowrap; }
.attach-icon { font-size: 23px; font-weight: 400; line-height: 1; }
.send-button { font-size: 21px; }
.send-button.is-stop { background: var(--ink); font-size: 15px; }
.compact-button { min-height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 650; }
.compact-button:hover { background: var(--soft); color: var(--ink); }
.composer-actions { display: flex; min-width: 0; flex-wrap: wrap; align-items: center; gap: 2px; }
.composer-action { min-height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 14px; }
.composer-action:hover { background: var(--soft); color: var(--ink); }
.composer-action.is-primary { background: var(--brand); color: #fff; }
.composer-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.upload-file-list { display: flex; flex-wrap: wrap; gap: 10px; padding: 2px 2px 10px; margin: 0; list-style: none; }
.upload-file-list:empty { display: none; }
.upload-thumbnail { display: grid; width: 76px; gap: 4px; color: var(--muted); font-size: 11px; }
.upload-preview { position: relative; display: grid; width: 76px; height: 76px; overflow: hidden; place-items: center; border: 1px solid var(--line); border-radius: 14px; background: #e8e8e4; }
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview strong { color: var(--brand); font-size: 14px; }
.upload-thumbnail small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 500; }
.upload-state { position: absolute; inset: auto 5px 5px; padding: 3px 6px; border-radius: 999px; background: rgba(24, 34, 48, .78); color: #fff; font-size: 11px; line-height: 1; }
.upload-thumbnail.is-done .upload-state { background: #18794e; }
.upload-thumbnail:is(.is-failed, .is-processing_failed, .is-recognition_failed) .upload-state { background: var(--danger); }
.image-preview-trigger { display: block; width: 100%; height: 100%; min-height: 0; padding: 0; border: 0; border-radius: inherit; background: transparent; cursor: zoom-in; overflow: hidden; }
.upload-preview .image-preview-trigger { position: static; }
.upload-preview > button[data-remove-file] { position: absolute; inset: 5px 5px auto auto; width: 24px; min-height: 24px; padding: 0; border: 1px solid rgba(255,255,255,.8); border-radius: 50%; background: rgba(24,34,48,.72); color: #fff; font-size: 19px; line-height: 1; }
.upload-progress { position: absolute; inset: auto auto 0 0; height: 4px; background: #4b6fd8; transition: width .15s linear; }
.image-preview-dialog { width: min(94vw, 1100px); max-width: none; height: min(92vh, 900px); max-height: none; padding: 48px 18px 18px; border: 0; border-radius: 18px; background: #111; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.image-preview-dialog[open] { display: grid; place-items: center; }
.image-preview-dialog::backdrop { background: rgba(0,0,0,.72); }
.image-preview-dialog form { position: absolute; inset: 10px 10px auto auto; margin: 0; }
.image-preview-dialog form button { width: 34px; min-height: 34px; padding: 0; border-radius: 50%; background: #fff; color: #111; font-size: 24px; line-height: 1; }
.image-preview-dialog > img { display: block; width: auto; max-width: 100%; height: auto; max-height: 100%; object-fit: contain; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stats div { display: grid; gap: 6px; }
.stats strong { font-size: 32px; }
.stats span { color: var(--muted); }
.recent { grid-column: 1 / -1; }
.page-panel { max-width: 900px; margin: 0 auto; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-title a { color: var(--brand); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.page-intro { margin: 6px 0 0; color: var(--muted); }
.learning-usage-strip { display: flex; max-width: 1100px; align-items: center; gap: 18px; margin: -12px auto 18px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--muted); font-size: 13px; }
.learning-usage-strip strong { color: var(--ink); }
.learning-usage-strip span { display: flex; align-items: baseline; gap: 5px; }
.learning-usage-strip b { color: var(--ink); font-size: 15px; }
.learning-usage-strip small { color: var(--muted); }
.learning-usage-strip.is-limit { border-color: #f2c94c; background: #fffbeb; }
.error-dashboard { display: grid; max-width: 1120px; gap: 18px; }
.pending-review-intro { margin: 8px 0 0; color: var(--muted); line-height: 1.65; }
.pending-review-list { display: grid; gap: 12px; margin: 18px 0 0; padding: 0; list-style: none; }
.pending-review-list > li { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--brand-soft); }
.pending-review-list p { margin: 8px 0 0; line-height: 1.6; white-space: pre-wrap; }
.pending-review-options { display: flex; flex-wrap: wrap; gap: 8px; }
.dashboard-overview { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(340px, .9fr); gap: 18px; }
.progress-dashboard .dashboard-overview { grid-template-columns: minmax(0, 1fr); }
.section-kicker { margin: 0 0 2px; color: var(--muted); font-size: 12px; }
.review-rule-panel,
.review-calendar-panel,
.today-plan-panel,
.all-errors-panel { min-width: 0; }
.review-rule-panel > p { color: var(--muted); }
.review-rule-stages { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 0; margin: 18px 0; list-style: none; }
.review-rule-stages li { display: grid; min-width: 0; gap: 4px; padding: 10px 5px; border-radius: 10px; background: var(--brand-soft); text-align: center; }
.review-rule-stages strong { font-size: 18px; }
.review-rule-stages span { color: var(--muted); font-size: 11px; }
.memory-principles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.memory-principles p { display: grid; align-content: start; gap: 4px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.memory-principles strong { font-size: 13px; }
.memory-principles span { color: var(--muted); font-size: 12px; }
.calendar-controls { display: flex; align-items: center; gap: 8px; }
.calendar-controls strong { min-width: 112px; text-align: center; }
.calendar-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; margin: 12px 0 10px; }
.calendar-stats p { display: grid; gap: 2px; margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--brand-soft); }
.calendar-stats strong { color: var(--ink); font-size: 18px; line-height: 1.2; }
.calendar-stats span { color: var(--muted); font-size: 11px; }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
.calendar-filters { display: inline-flex; gap: 2px; padding: 4px; border-radius: 10px; background: var(--brand-soft); }
.calendar-filters button { min-height: 34px; padding: 6px 13px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.calendar-filters button:hover { color: var(--ink); background: rgba(255, 255, 255, .55); }
.calendar-filters button[aria-pressed="true"] { background: var(--paper); color: var(--brand); box-shadow: 0 1px 3px rgba(24, 34, 48, .12); font-weight: 650; }
.calendar-filters button:focus-visible { outline: 2px solid rgba(0, 32, 96, .32); outline-offset: 1px; }
.calendar-summary { margin: 0; color: var(--muted); font-size: 12px; text-align: right; }
.review-calendar-scroll { overflow-x: auto; padding-bottom: 4px; }
.calendar-weekdays,
.review-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(112px, 1fr)); min-width: 784px; }
.calendar-weekdays span { padding: 8px; color: var(--muted); text-align: center; font-size: 12px; }
.review-calendar-grid { border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.calendar-day { display: grid; min-height: 126px; align-content: start; gap: 8px; padding: 10px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0; background: var(--paper); color: var(--ink); text-align: left; }
.calendar-day:hover:not(.is-empty),
.calendar-day.is-selected { background: #f6f8fb; }
.calendar-day.is-empty { background: #fafafa; }
.calendar-day.is-today { box-shadow: inset 0 0 0 2px var(--brand); }
.calendar-day-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.calendar-day-heading > strong { font-size: 14px; }
.calendar-day-heading > span { color: var(--muted); font-size: 10px; font-weight: 500; }
.calendar-day-metrics { display: grid; gap: 3px; }
.calendar-day-metrics span { display: flex; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 500; }
.calendar-day-metrics strong { color: var(--ink); font-size: 11px; }
.calendar-day-metrics .is-new strong { color: #b42318; }
.calendar-day-metrics .is-due strong { color: #175cd3; }
.calendar-day-metrics .is-completed strong { color: #067647; }
.calendar-day-metrics .is-correction strong,
.calendar-day-metrics .is-overdue strong { color: #b54708; }
.calendar-day-metrics .is-deferred strong { color: #9a6700; }
.calendar-day .calendar-date-open,
.calendar-day-metrics .calendar-metric { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; min-height: 24px; margin: 0; padding: 0; border: 0; border-radius: 3px; background: transparent; color: var(--muted); text-align: left; font-size: 11px; font-weight: 500; }
.calendar-day .calendar-date-open strong { color: var(--ink); font-size: 14px; }
.calendar-day-metrics .calendar-metric { text-decoration: underline; text-underline-offset: 3px; }
.calendar-day-metrics .calendar-metric:hover { color: var(--ink); background: #fff6e9; }
.calendar-history-warning { color: #b54708; font-size: 10px; }
.calendar-backlog-select { display: flex; align-items: center; gap: 8px; width: fit-content; font-size: 12px; }
.calendar-backlog-select input { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
.calendar-stages { display: flex; flex-wrap: wrap; gap: 3px; }
.calendar-stages span { padding: 1px 5px; border-radius: 999px; background: var(--brand-soft); color: var(--muted); font-size: 9px; font-weight: 700; }
.calendar-day-detail { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.calendar-detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.calendar-detail-heading h3 { margin: 0; font-size: 16px; }
#calendar-prev, #calendar-next, #calendar-day-close { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 32px; width: 32px; height: 32px; min-height: 32px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); line-height: 1; box-shadow: none; }
#calendar-prev:hover, #calendar-next:hover, #calendar-day-close:hover { background: #f0f1f3; color: var(--ink); }
#calendar-prev svg, #calendar-next svg, #calendar-day-close svg { width: 16px; height: 16px; pointer-events: none; }
.calendar-day-items { display: grid; gap: 10px; margin-top: 12px; }
.calendar-pdf-actions { margin-top: 10px; }
.calendar-pdf-actions .status { margin: 0; }
.calendar-detail-item { display: grid; gap: 7px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.calendar-detail-item h4 { margin: 0; font-size: 14px; line-height: 1.55; }
.review-defer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: #7a4d00; font-size: 12px; }
.review-defer-actions label { display: inline-flex; align-items: center; gap: 6px; }
.review-defer-actions select { min-height: 34px; padding: 5px 28px 5px 9px; }
.review-defer-actions button { min-height: 34px; padding: 6px 11px; }
.calendar-event-labels { display: flex; flex-wrap: wrap; gap: 5px; }
.calendar-event-labels span { padding: 2px 7px; border-radius: 999px; background: var(--brand-soft); color: var(--muted); font-size: 11px; }
.calendar-event-labels .is-correction { background: #fffaeb; color: #b54708; }
.calendar-event-labels .is-completed { background: #ecfdf3; color: #067647; }
.calendar-detail-item p { margin: 0; color: var(--muted); font-size: 12px; }
.plan-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0; margin: 18px 0; list-style: none; }
.plan-steps li { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.plan-steps li > span { display: grid; width: 28px; height: 28px; flex: 0 0 28px; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--muted); font-weight: 700; }
.plan-steps div { display: grid; min-width: 0; gap: 2px; }
.plan-steps strong { font-size: 13px; }
.plan-steps small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.plan-steps li.is-done { border-color: #b8dfca; background: #f4fbf7; }
.plan-steps li.is-done > span { background: #18794e; color: #fff; }
.plan-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.plan-actions .check { margin: 0; color: var(--muted); font-size: 13px; }
.error-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.error-card-heading time { color: var(--muted); font-size: 12px; }
.selection-hint { color: var(--muted); font-size: 12px; }
.error-list { padding: 0; list-style: none; }
.error-list > li { padding: 14px 0; border-top: 1px solid var(--line); }
.error-list .empty { color: var(--muted); }
.error-list .error-card { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 18px 0; }
.error-select { display: grid; align-self: start; width: 28px; height: 28px; place-items: center; cursor: pointer; }
.error-select input { width: 18px; height: 18px; accent-color: var(--brand); }
.error-card article { min-width: 0; }
.error-record-id { margin: 8px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.error-record-id code { font-family: ui-monospace, Consolas, monospace; user-select: text; }
.question-diagram { display: block; width: auto; max-width: min(100%, 720px); max-height: 520px; margin: 12px auto 4px; object-fit: contain; }
.error-card h3 { margin: 10px 0 14px; font-size: 15px; line-height: 1.65; white-space: pre-wrap; }
.error-card dl { display: grid; gap: 10px; margin: 0; }
.error-card dl > div { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 12px; }
.error-card dt { color: var(--muted); font-size: 12px; }
.error-card dd { margin: 0; color: var(--muted); white-space: pre-wrap; }
.error-card dd > strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: 13px; }
.knowledge-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.knowledge-tags span { padding: 3px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--muted); font-size: 12px; }
.error-detail-trigger { margin-top: 12px; }
.bottom-nav { display: none; }
body.is-embedded .sidebar,
body.is-embedded .bottom-nav { display: none; }
body.is-embedded {
  --ink: #0f1115;
  --muted: #61666b;
  --brand: #0f1115;
  --brand-soft: #f3f4f5;
  --paper: #fff;
  --line: rgba(15, 17, 21, .10);
  --bg: #fff;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}
body.is-embedded main {
  margin-left: 0;
  padding: 28px clamp(24px, 4vw, 56px) 56px;
}
body.is-embedded .page-header,
body.is-embedded .page-panel {
  width: min(100%, 920px);
}
body.is-embedded[data-page="errors"] .page-header,
body.is-embedded[data-page="errors"] .page-panel,
body.is-embedded[data-page="progress"] .page-header,
body.is-embedded[data-page="progress"] .page-panel { width: min(100%, 1120px); }
body.is-embedded[data-page="settings"] .page-header,
body.is-embedded[data-page="settings"] .settings-panel {
  width: min(100%, 680px);
}
body.is-embedded .page-header { margin-bottom: 20px; }
body.is-embedded .learning-usage-strip { margin-top: -8px; }
body.is-embedded .page-header h1 {
  margin-top: 2px;
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  letter-spacing: -.01em;
}
body.is-embedded .eyebrow {
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
  font-weight: 500;
}
body.is-embedded .panel {
  padding: 22px 24px;
  border-color: var(--line);
  border-radius: 12px;
  box-shadow: none;
}
body.is-embedded .panel h2 {
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
}
body.is-embedded .panel p { line-height: 1.6; }
body.is-embedded button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
}
body.is-embedded .ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}
body.is-embedded .ghost:hover,
body.is-embedded .selection-item:hover { background: #f6f7f8; }
body.is-embedded .badge {
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}
body.is-embedded .status { font-size: 12px; line-height: 18px; }
body.is-embedded .error-list li { padding: 12px 0; }
body.is-embedded .error-list .error-card { padding: 18px 0; }
body.is-embedded .error-detail,
body.is-embedded .review-stem {
  border-radius: 10px;
  background: var(--brand-soft);
}
body.is-embedded .selection-item {
  padding: 10px 12px;
  border-radius: 10px;
  transition: background .12s ease;
}
body.is-embedded .stats { gap: 16px 24px; }
body.is-embedded .stats div {
  min-height: 84px;
  align-content: center;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--brand-soft);
}
body.is-embedded .stats strong {
  font-size: 26px;
  line-height: 32px;
  font-weight: 600;
}
body.is-embedded .stats span { font-size: 13px; }
body.is-embedded .bank-status { margin-top: 20px; padding-top: 18px; }
.review-panel,
.practice-panel { display: grid; align-content: start; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.badge { padding: 5px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 13px; }
#sensitive-action { width: 100%; padding: 10px 12px; border: 1px solid #cbd3e0; border-radius: 10px; background: var(--paper); font: inherit; }
#sensitive-action:focus,
select:focus-visible,
textarea:focus-visible { outline: 3px solid rgba(0, 32, 96, .25); outline-offset: 2px; }
.danger { background: var(--danger); }
.error-detail { margin-top: 20px; padding: 18px; border-radius: 12px; background: var(--brand-soft); white-space: pre-wrap; }
.diagnosis-list { display: grid; grid-template-columns: minmax(110px, 150px) 1fr; gap: 10px 16px; white-space: normal; }
.diagnosis-list dt { color: var(--muted); font-weight: 700; }
.diagnosis-list dd { margin: 0; white-space: pre-wrap; }
.recommendation-list { display: grid; gap: 10px; padding-left: 22px; white-space: normal; }
.recommendation-list li { padding: 10px 12px; border-radius: 10px; background: var(--paper); }
.recommendation-list .recommendation-wait { color: var(--muted); }
.recommendation-list p { margin: 5px 0; white-space: pre-wrap; }
.recommendation-list .recommendation-options { color: var(--muted); font-size: 13px; }
.review-content { line-height: 1.7; }
.review-stem { padding: 16px; border-radius: 12px; background: var(--brand-soft); white-space: pre-wrap; }
.review-content details { margin: 12px 0; }
.bank-status { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.selection-list { display: grid; gap: 8px; }
.selection-item { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.selection-item span { min-width: 0; overflow-wrap: anywhere; }
.pdf-history-list { display: grid; gap: 8px; }
.pdf-history-item { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 16px; padding: 12px; border-radius: 10px; background: var(--brand-soft); }
.pdf-history-item div { display: grid; min-width: 0; gap: 3px; }
.pdf-history-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-history-item small { color: var(--muted); }
.pdf-progress { margin: 8px 0; font-size: 13px; line-height: 1.6; }
.pdf-progress p { margin: 4px 0; }
.pdf-progress-groups { display: grid; gap: 4px; color: var(--muted); }
.pdf-progress details { margin-block: 8px; }
.pdf-progress summary { cursor: pointer; color: var(--brand); }
.pdf-progress li { margin-bottom: 12px; overflow-wrap: anywhere; }
.pdf-progress small, .pdf-progress-note { color: var(--muted); font-size: 12px; }
.pdf-download { flex: 0 0 auto; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); font-weight: 650; text-decoration: none; }
.progress-stats { margin-top: 22px; }
.settings-panel { max-width: 680px; }
.settings-session { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.settings-session h2 { margin: 0; }
.settings-session p { color: var(--muted); line-height: 1.6; }
.legal-card h1 { margin-top: 24px; }
.back-link { color: var(--brand); }

@media(max-width:720px) {
  .sidebar { display: none; }
  main { margin: 0; padding: 20px 16px 88px; }
  body:not(.is-authenticated) main { padding: 24px 16px; place-items: start center; }
  .auth-card { margin-top: 20px; padding: 24px 20px; border-radius: 12px; box-shadow: none; }
  .auth-brand { font-size: 17px; }
  .auth-logo { width: 42px; height: 42px; }
  .auth-heading { margin-top: 22px; }
  .page-header { align-items: flex-start; }
  .grid { grid-template-columns: 1fr; }
  .chat-main { height: 100vh; padding: 0 12px 78px; }
  .chat-workspace { width: calc(100% + 24px); margin-inline: -12px; }
  .chat-header { padding: 14px 4px 10px; }
  .chat-header .eyebrow { display: none; }
  .chat-header h1 { font-size: 19px; }
  .chat-thread { padding: 12px; }
  .chat-welcome { min-height: 42%; padding: 24px 12px; }
  .chat-welcome h2 { font-size: 23px; }
  .conversation-dock { width: calc(100% - 24px); }
  .composer-interaction { max-height: 48vh; padding: 14px; border-radius: 16px; }
  .composer-surface { border-radius: 18px; }
  .composer-placeholder { font-size: 13px; }
  .chat-turn { gap: 9px; }
  .chat-avatar { width: 28px; height: 28px; flex-basis: 28px; }
  .chat-upload-bubble { max-width: calc(100% - 20px); }
  .chat-candidate dl { grid-template-columns: 1fr; gap: 3px; }
  .chat-candidate dd { margin-bottom: 8px; }
  .diagnosis-list { grid-template-columns: 1fr; gap: 4px; }
  .diagnosis-list dd { margin-bottom: 10px; }
  .recent { grid-column: auto; }
  .actions button { flex: 1 1 130px; }
  .bottom-nav { position: fixed; inset: auto 0 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 8px 4px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); text-align: center; }
  .bottom-nav a { padding: 9px 3px; font-size: 12px; }
  .bottom-nav a.active { color: var(--brand); font-weight: 700; }
}

@media(max-width:960px) {
  .dashboard-overview { grid-template-columns: 1fr; }
  .calendar-stats { grid-template-columns: repeat(4, 1fr); }
  .plan-steps { grid-template-columns: repeat(2, 1fr); }
  .calendar-toolbar { align-items: flex-start; flex-direction: column; }
  .calendar-summary { text-align: left; }
}

@media(max-width:620px) {
  .review-rule-stages { grid-template-columns: repeat(3, 1fr); }
  .memory-principles,
  .plan-steps { grid-template-columns: 1fr; }
  .calendar-stats { grid-template-columns: repeat(2, 1fr); }
  .calendar-filters { display: grid; width: 100%; grid-template-columns: repeat(5, 1fr); }
  .calendar-filters button { padding-inline: 4px; }
  .error-card dl > div { grid-template-columns: 1fr; gap: 3px; }
}
