:root {
  --paper: #f6f4ef;
  --surface: #fffefb;
  --ink: #242321;
  --muted: #716e68;
  --line: #ded9d0;
  --line-soft: #ebe7df;
  --red: #b74435;
  --red-soft: #f8e9e5;
  --green: #34705a;
  --green-soft: #e8f1ed;
  --amber: #956c27;
  --amber-soft: #fbf0d9;
  --blue: #345e79;
  --blue-soft: #e8f0f5;
  --shadow: 0 16px 42px rgba(50, 42, 33, .07);
  --radius: 18px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 5%, rgba(183, 68, 53, .055), transparent 28rem),
    var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }

.app-shell { min-height: 100vh; }

.site-login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 48px 22px;
  background:
    radial-gradient(ellipse at 17% 16%, rgba(183, 68, 53, .10), transparent 30rem),
    radial-gradient(ellipse at 88% 88%, rgba(52, 112, 90, .08), transparent 26rem),
    var(--paper);
}
.site-login-card {
  width: min(100%, 430px);
  padding: 38px 42px 26px;
  border: 1px solid rgba(222, 217, 208, .9);
  border-radius: 22px;
  background: rgba(255, 254, 251, .94);
  box-shadow: 0 24px 70px rgba(50, 42, 33, .12);
}
.site-login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 38px; font-weight: 730; letter-spacing: -.02em; }
.site-login-card .eyebrow { margin: 0 0 7px; color: var(--red); font-size: 11px; font-weight: 720; letter-spacing: .14em; }
.site-login-card h1 { margin: 0; font-family: var(--serif); font-size: 32px; font-weight: 650; letter-spacing: -.04em; }
.site-login-lead { margin: 8px 0 26px; color: var(--muted); }
.site-login-card .field { margin: 0 0 17px; }
.site-login-card .field label { display: block; margin-bottom: 7px; color: #514e48; font-size: 13px; font-weight: 620; }
.site-login-card input { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; outline: none; background: #fff; transition: border-color .18s, box-shadow .18s; }
.site-login-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(52, 112, 90, .12); }
.site-login-error { min-height: 22px; margin: -3px 0 8px; color: var(--red); font-size: 13px; }
.site-login-submit { display: flex; width: 100%; min-height: 48px; align-items: center; justify-content: space-between; padding: 0 17px; }
.site-login-submit span { font-size: 20px; font-weight: 400; }
.site-login-foot { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 24px; color: var(--muted); font-size: 12px; }
.site-login-foot .connection-dot { width: 7px; height: 7px; }
.site-login-note { position: fixed; right: 24px; bottom: 18px; color: rgba(113, 110, 104, .7); font-family: var(--serif); font-size: 13px; }

@media (max-width: 520px) {
  .site-login-page { padding: 24px 17px 66px; }
  .site-login-card { padding: 30px 25px 23px; border-radius: 19px; }
  .site-login-brand { margin-bottom: 30px; }
  .site-login-card h1 { font-size: 29px; }
  .site-login-note { right: 0; left: 0; text-align: center; }
}

.app-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(160px, 1fr);
  align-items: center;
  min-height: 70px;
  padding: 0 34px;
  border-bottom: 1px solid rgba(222, 217, 208, .85);
  background: rgba(255, 254, 251, .92);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 730;
  letter-spacing: -.02em;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  color: white;
  background: var(--red);
  box-shadow: 0 5px 14px rgba(183, 68, 53, .22);
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  width: 13px;
  height: 2px;
  border-radius: 2px;
  background: white;
  content: "";
}

.brand-mark::after { transform: rotate(90deg); }

.top-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px;
  border-radius: 13px;
  background: #eeebe5;
}

.top-nav button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.top-nav button:hover { color: var(--ink); }
.top-nav button.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(47, 40, 32, .08);
  font-weight: 650;
}

.connection {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}
.site-logout { padding: 4px 8px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.site-logout:hover { color: var(--red); background: var(--red-soft); }

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #50a179;
  box-shadow: 0 0 0 4px rgba(80, 161, 121, .12);
}

.context-strip {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 7px 20px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  background: rgba(246, 244, 239, .82);
  font-size: 12px;
}

.context-strip strong { color: var(--ink); }
.context-strip .divider { color: #bbb5ab; }

.page {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 80px;
}

.page.narrow { width: min(850px, calc(100% - 40px)); }
.page.medium { width: min(1010px, calc(100% - 40px)); }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--red);
  font-size: 12px;
  font-weight: 720;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, h3, h4, p { margin-top: 0; }

h1 {
  margin-bottom: 7px;
  font-family: var(--serif);
  font-size: clamp(30px, 4vw, 45px);
  font-weight: 650;
  letter-spacing: -.035em;
  line-height: 1.15;
}

h2 {
  margin-bottom: 8px;
  font-size: 22px;
  letter-spacing: -.02em;
}

h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

.lead, .muted { color: var(--muted); }
.lead { max-width: 660px; margin-bottom: 0; }
.small { font-size: 13px; }
.tiny { font-size: 12px; }

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  font-weight: 630;
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.button:hover { border-color: #bbb5ac; transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button.primary { border-color: var(--red); color: white; background: var(--red); }
.button.primary:hover { background: #a63d30; }
.button.green { border-color: var(--green); color: white; background: var(--green); }
.button.ghost { border-color: transparent; background: transparent; }
.button.danger { color: var(--red); }
.button.compact { min-height: 34px; padding: 0 12px; font-size: 13px; }
.button[disabled] { opacity: .48; cursor: not-allowed; transform: none; }

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.analysis-footer-actions [data-action="back-library"] { margin-left: auto; }
.back-to-top {
  position: fixed;
  z-index: 40;
  right: 28px;
  bottom: 24px;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 254, 251, .96);
  box-shadow: 0 8px 24px rgba(50, 42, 33, .14);
  cursor: pointer;
  backdrop-filter: blur(12px);
}
.back-to-top span { color: var(--red); font-size: 19px; line-height: 1; }
.back-to-top:hover { border-color: var(--red); }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-pad { padding: 26px; }
.section-card { margin-top: 22px; padding: 26px; }

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid #ead4cd;
  border-radius: 12px;
  color: #704239;
  background: var(--red-soft);
  font-size: 13px;
}

.notice.info { border-color: #cfdee7; color: #34586c; background: var(--blue-soft); }
.notice.success { border-color: #cfe0d7; color: #2d604c; background: var(--green-soft); }
.notice.warning { border-color: #ead8b7; color: #77571f; background: var(--amber-soft); }
.notice + .notice { margin-top: 10px; }

.status {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  padding: 0 9px;
  border-radius: 99px;
  color: var(--muted);
  background: #eeece8;
  font-size: 12px;
  font-weight: 680;
}

.status.red { color: #91372d; background: var(--red-soft); }
.status.amber { color: #76561d; background: var(--amber-soft); }
.status.green { color: #2c624c; background: var(--green-soft); }
.status.blue { color: #315d76; background: var(--blue-soft); }

.task-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.task-card {
  display: flex;
  min-height: 222px;
  flex-direction: column;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(47, 40, 32, .045);
}

.task-card:hover { border-color: #cbc3b8; }
.task-card-top, .meta-row, .snapshot-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.status-row { display: flex; flex-wrap: wrap; gap: 7px; }

.task-card h3 { margin: 18px 0 5px; font-family: var(--serif); font-size: 23px; }
.task-card p { margin-bottom: 0; }
.task-card .card-actions { margin-top: auto; padding-top: 20px; }

.empty {
  padding: 70px 30px;
  border: 1px dashed #cbc5bc;
  border-radius: var(--radius);
  text-align: center;
  background: rgba(255, 254, 251, .55);
}

.empty-mark {
  display: grid;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: 50%;
  color: var(--red);
  background: var(--red-soft);
  font-family: var(--serif);
  font-size: 27px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.field { display: grid; gap: 7px; }
.field.span-2 { grid-column: 1 / -1; }

.field label, .field-label {
  color: #4d4a46;
  font-size: 13px;
  font-weight: 680;
}

.required::after { margin-left: 3px; color: var(--red); content: "*"; }

input, select, textarea {
  width: 100%;
  border: 1px solid #d8d3ca;
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: white;
  transition: border-color .15s, box-shadow .15s;
}

input, select { min-height: 43px; padding: 0 12px; }
textarea { min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
textarea.tall { min-height: 158px; }
input:focus, select:focus, textarea:focus {
  border-color: #aa8b80;
  box-shadow: 0 0 0 3px rgba(183, 68, 53, .1);
}

.drop-zone {
  position: relative;
  display: grid;
  min-height: 174px;
  place-items: center;
  padding: 25px;
  border: 1.5px dashed #beb6ac;
  border-radius: 15px;
  color: var(--muted);
  background: #fbfaf7;
  text-align: center;
  cursor: pointer;
}

.drop-zone:hover { border-color: var(--red); background: #fffaf8; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 15px; }
.drop-symbol { margin-bottom: 8px; color: var(--red); font-size: 30px; line-height: 1; }
.file-name { margin-top: 8px; color: var(--blue); font-size: 12px; word-break: break-all; }

.upload-preview {
  display: grid;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f3f1ed;
  place-items: center;
}

.upload-preview img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: contain;
}

.upload-preview img[hidden] { display: none; }
.upload-preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.upload-preview-placeholder {
  display: grid;
  max-width: 260px;
  gap: 6px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  place-items: center;
}
.upload-preview-placeholder[hidden] { display: none; }
.upload-preview-placeholder strong { color: var(--ink); }
.upload-submit-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; }
.image-submit-button { justify-content: center; cursor: pointer; }
.image-submit-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-file-names { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; color: var(--blue); font-size: 12px; }
.upload-hint { margin: 2px 0 0; }

.workflow-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
}

.workflow-item {
  position: relative;
  display: flex;
  min-height: 61px;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-right: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
}

.workflow-item:last-child { border-right: 0; }
.workflow-item.active { color: var(--ink); background: #fff8f5; }
.workflow-item.done { color: var(--green); }
.workflow-number {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #cbc5bc;
  border-radius: 50%;
  font-weight: 720;
}
.active .workflow-number { border-color: var(--red); color: white; background: var(--red); }
.done .workflow-number { border-color: var(--green); color: white; background: var(--green); }
.workflow-item strong { display: block; color: inherit; font-size: 13px; }

.task-titlebar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.task-titlebar h1 { font-size: 34px; }

.crop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.crop-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f3f0ea;
}

.crop-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.replace-page-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.crop-stage {
  overflow: auto;
  max-height: 650px;
  padding: 10px;
  border-radius: 9px;
  background: #d8d4cd;
}

.crop-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: crosshair;
}

@media (max-width: 640px) {
  .back-to-top { right: 14px; bottom: 14px; min-height: 40px; padding: 0 13px; }
  .analysis-footer-actions [data-action="back-library"] { margin-left: 0; }
}

.crop-help { margin: 12px 0 0; color: var(--muted); font-size: 12px; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, .95fr);
  gap: 22px;
  align-items: start;
}

.sticky { position: sticky; top: 126px; }

.evidence-stack { display: grid; gap: 12px; }
.evidence-image {
  display: block;
  width: 100%;
  max-height: 720px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.content-box {
  white-space: pre-wrap;
  word-break: break-word;
}

.option-grid { display: grid; gap: 10px; }
.option-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: start;
  gap: 9px;
}
.option-letter {
  display: grid;
  width: 34px;
  height: 43px;
  place-items: center;
  border-radius: 9px;
  color: var(--red);
  background: var(--red-soft);
  font-weight: 760;
}
.option-row.is-hidden { display: none; }

.visual-fragments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.visual-fragments figure {
  margin: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}
.visual-fragments img {
  display: block;
  width: auto;
  max-width: 220px;
  height: auto;
  max-height: 130px;
  object-fit: contain;
}
.visual-fragments figcaption {
  max-width: 220px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.structured-ocr-list {
  display: grid;
  gap: 12px;
  margin-top: 6px;
}
.structured-ocr-item {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(0, 1.3fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #fcfbf8;
}
.structured-ocr-item textarea { min-height: 116px; }

.content-edit-panel {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.content-edit-panel > .span-2 { grid-column: 1 / -1; }
.content-preview-panel { grid-column: 1 / -1; }
.content-review-actions {
  position: sticky;
  bottom: 12px;
  z-index: 4;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 254, 251, 0.96);
  box-shadow: 0 10px 28px rgba(69, 54, 41, 0.1);
  backdrop-filter: blur(8px);
}
.content-preview-sheet {
  margin-top: 14px;
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}
.content-preview-meta {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
}
.content-preview-section + .content-preview-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.content-preview-section h3 { margin-bottom: 9px; }
.preview-options, .preview-visual { display: grid; gap: 10px; }
.preview-visual + .preview-visual { margin-top: 14px; }
.katex-display { overflow-x: auto; overflow-y: hidden; }

.analysis-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.analysis-block {
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: #fcfbf8;
}

.analysis-block.wide { grid-column: 1 / -1; }
.analysis-block h3 { color: #4a4039; }
.analysis-block p:last-child { margin-bottom: 0; }

.manual-answer-panel {
  padding: 20px;
  border: 1px solid #e7d9bd;
  border-radius: 14px;
  background: #fffcf5;
}
.compact-head { margin-bottom: 14px; }
.compact-head h3 { margin-bottom: 3px; }
.manual-answer-panel [data-manual-choice],
.manual-answer-panel [data-manual-text] { margin-top: 16px; }
.answer-confirm-check {
  margin-top: 16px;
  padding: 14px 15px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: white;
}

.answer-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 13px;
  color: #285943;
  background: var(--green-soft);
}
.answer-value {
  display: grid;
  min-width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: var(--green);
  font-size: 19px;
  font-weight: 780;
}

.analysis-result-card {
  padding: 32px;
  border-radius: 18px;
  background: #fffefb;
}
.analysis-result-card .analysis-head { margin-bottom: 26px; }
.analysis-result-card .analysis-head h2 {
  margin-bottom: 8px;
  font-size: 26px;
}
.analysis-result-card .answer-banner {
  padding: 21px 22px;
  border-radius: 15px;
}
.analysis-result-card .answer-value {
  min-width: 54px;
  height: 54px;
  border-radius: 13px;
  font-size: 21px;
}
.answer-items-panel {
  display: grid;
  gap: 14px;
}
.answer-items-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 19px;
  border: 1px solid #cfe3d8;
  border-radius: 14px;
  color: #285943;
  background: var(--green-soft);
}
.answer-items-summary p {
  margin: 7px 0 0;
  color: var(--ink);
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.answer-items-list {
  display: grid;
  gap: 12px;
}
.answer-item-card {
  min-width: 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 4px solid #4c8b70;
  border-radius: 13px;
  background: #fffdfa;
}
.answer-item-card.answer-item-discussion { border-left-color: #5a7fb3; }
.answer-item-card.answer-item-proof { border-left-color: #9b6b38; }
.answer-item-head,
.answer-item-result,
.answer-item-target {
  display: flex;
  align-items: center;
  gap: 11px;
}
.answer-item-head { justify-content: space-between; }
.answer-mode {
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: #f2f0eb;
  font-size: 12px;
}
.answer-item-requirement {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.65;
}
.answer-item-target,
.answer-item-process,
.answer-item-conclusion,
.answer-item-result {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line-soft);
}
.answer-item-target,
.answer-item-result { align-items: flex-start; }
.answer-item-target strong,
.answer-item-result strong { flex: 0 0 72px; }
.answer-item-process ul { margin-bottom: 0; }
.answer-item-conclusion p {
  margin: 7px 0 0;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.answer-current-preview p {
  margin: 6px 0 0;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.analysis-result-card .analysis-grid {
  gap: 16px;
  margin-top: 18px !important;
}
.analysis-result-card .analysis-block {
  padding: 22px;
  border-radius: 14px;
  background: #fffdfa;
}
.analysis-result-card .analysis-block h3 {
  margin-bottom: 12px;
  font-size: 18px;
}
.analysis-result-card .analysis-block p,
.analysis-result-card .analysis-block li {
  font-size: 15px;
  line-height: 1.75;
}
.analysis-preview-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid #d9e7df;
  border-radius: 11px;
  color: #315f4b;
  background: #f3faf6;
  font-size: 13px;
}
.analysis-preview-note span { color: var(--muted); }
.analysis-result-card .katex-display { margin: 0.7em 0; }
.analysis-edit-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fbfaf7;
}
.analysis-edit-panel .form-grid { margin-top: 18px; }
.analysis-edit-panel textarea { min-height: 112px; }
.answer-feedback-panel {
  padding: 20px;
  border: 1px solid #e4d5b9;
  border-radius: 14px;
  background: #fffaf0;
}
.answer-feedback-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.answer-feedback-options .check-row {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
}
.corrected-answer-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.candidate-answer-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 0;
  padding: 16px 18px;
  border: 1px solid #e6c9a5;
  border-radius: 13px;
  background: #fff8e9;
}

.candidate-answer-value {
  display: grid;
  min-width: 52px;
  min-height: 44px;
  padding: 0 12px;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: #a96d21;
  font-size: 19px;
  font-weight: 780;
}

.verdict-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.verdict-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #fcfbf8;
}

.verdict-row p { margin: 4px 0 0; }

.answer-choice-grid {
  display: grid;
  gap: 9px;
}

.answer-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: #fcfbf8;
  cursor: pointer;
}
.answer-choice.is-hidden { display: none; }

.answer-choice input {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin-top: 2px;
  accent-color: var(--red);
}

.practice-list, .snapshot-list, .review-list { display: grid; gap: 13px; }
.practice-card, .snapshot-card, .review-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.user-management { margin: 18px 0 22px; }
.user-create-form { display: flex; align-items: end; gap: 14px; }
.user-create-form .field { width: min(100%, 340px); }
.login-logs-modal { width: min(100%, 720px); max-height: min(82vh, 760px); overflow: auto; }
.login-log-list { display: grid; border-top: 1px solid var(--line); }
.login-log-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(210px, 1.2fr); gap: 16px; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--line-soft); }
.login-log-heading { color: var(--muted); font-size: 12px; }
.modal-actions { justify-content: flex-end; margin-top: 18px; }
.generated-password-panel { display: grid; gap: 9px; margin: 18px 0; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #f3f8f4; }
.generated-password-row { display: flex; gap: 8px; max-width: 520px; }
.generated-password-row input { min-width: 0; flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.user-list { display: grid; margin-top: 20px; border-top: 1px solid var(--line); }
.user-list-heading, .user-list-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto; align-items: center; gap: 18px; padding: 14px 4px; border-bottom: 1px solid var(--line-soft); }
.user-list-heading { color: var(--muted); font-size: 12px; }
.user-list-row > div:first-child, .user-size-details { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.user-list-row .status { margin-left: 7px; }
.user-size-details { color: var(--muted); font-size: 12px; }
.user-size-details strong { color: var(--ink); }

details.answer-details {
  margin-top: 15px;
  border-top: 1px solid var(--line-soft);
}
details.answer-details summary {
  padding: 14px 0 4px;
  color: var(--red);
  cursor: pointer;
  font-weight: 680;
}
.answer-detail-body { padding-top: 10px; }

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  align-items: start;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.switch {
  position: relative;
  width: 44px;
  height: 25px;
  flex: 0 0 auto;
}
.switch input { position: absolute; opacity: 0; }
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #c9c4bb;
  cursor: pointer;
}
.switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .15);
  content: "";
  transition: transform .18s;
}
.switch input:checked + span { background: var(--red); }
.switch input:checked + span::after { transform: translateX(19px); }

.candidate-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.candidate {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  cursor: pointer;
}
.candidate:has(input:checked) { border-color: #c18375; background: #fff9f7; }
.candidate input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--red); }
.candidate p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.selection-card { padding: 22px; }
.selection-count { margin: 10px 0 18px; font-family: var(--serif); font-size: 34px; }

.review-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.review-section:first-child { margin-top: 0; padding-top: 0; border: 0; }
.review-section ul, .analysis-block ul { margin: 8px 0 0; padding-left: 20px; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 20px;
}

.settings-wide { grid-column: 1 / -1; }
.service-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.service-card-head h2 { margin: 4px 0 0; }
.engine-toggle {
  position: relative;
  display: flex;
  min-width: 150px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f5f3ef;
  cursor: pointer;
}
.engine-toggle.active { border-color: #b9d4c6; background: var(--green-soft); }
.engine-toggle strong, .engine-toggle small { display: block; }
.engine-toggle small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.engine-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.engine-toggle-track { position: relative; width: 42px; height: 24px; flex: 0 0 auto; border-radius: 99px; background: #c8c4bd; }
.engine-toggle-track::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0, 0, 0, .18); content: ""; transition: transform .15s; }
.engine-toggle input:checked + .engine-toggle-track { background: var(--green); }
.engine-toggle input:checked + .engine-toggle-track::after { transform: translateX(18px); }
.engine-toggle input:disabled + .engine-toggle-track { opacity: .58; }
.settings-save-row { margin-top: 24px; justify-content: flex-end; }
.settings-log-card { margin-top: 20px; }
.diagnostic-log-head,
.diagnostic-log-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.diagnostic-log-head h2 { margin: 0 0 6px; }
.diagnostic-log-head p { margin: 0; }
.diagnostic-log-panel { margin-top: 20px; }
.diagnostic-log-toolbar { align-items: center; margin-bottom: 10px; }
.diagnostic-log-preview {
  display: block;
  width: 100%;
  height: 360px;
  min-height: 220px;
  max-height: 70vh;
  resize: vertical;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #171614;
  color: #f4f0e8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  tab-size: 2;
  white-space: pre;
}
.diagnostic-log-preview:focus {
  border-color: #8cb09d;
  box-shadow: 0 0 0 3px rgba(67, 123, 96, .14);
  outline: none;
}
.content-box .katex-display, .analysis-result-card .katex-display, .review-section .katex-display { overflow-x: auto; overflow-y: hidden; padding: 3px 0; }
.structured-ocr-fields { display: grid; gap: 12px; }
.structured-ocr-fields textarea { min-height: 82px; }
.fragment-code { display: block; margin-bottom: 6px; }

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.check-row input { width: 18px; height: 18px; min-height: 0; margin-top: 3px; accent-color: var(--red); }

.divider-line { height: 1px; margin: 22px 0; background: var(--line-soft); }

.busy-overlay {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 25px;
  background: rgba(246, 244, 239, .8);
  backdrop-filter: blur(7px);
}
.busy-card {
  width: min(370px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 15px;
  border: 3px solid #eadbd6;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toast-region {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  display: grid;
  width: min(360px, calc(100% - 48px));
  gap: 9px;
}
.toast {
  padding: 13px 15px;
  border: 1px solid #d9d4cb;
  border-radius: 11px;
  color: white;
  background: #393633;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .16);
  font-size: 13px;
}
.toast.error { background: #87352d; }
.toast.success { background: #32624f; }

.back-link {
  display: inline-flex;
  margin-bottom: 18px;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.back-link:hover { color: var(--ink); }

.legacy {
  padding: 35px;
  text-align: center;
}

@media (max-width: 920px) {
  .app-header {
    grid-template-columns: auto 1fr;
    gap: 15px;
    padding: 12px 18px;
  }
  .top-nav { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; justify-content: flex-start; }
  .connection { display: none; }
  .context-strip { top: 114px; }
  .task-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .review-layout { grid-template-columns: 1fr; }
  .sticky { position: static; }
}

@media (max-width: 680px) {
  .page, .page.narrow, .page.medium { width: min(100% - 24px, 1180px); padding-top: 28px; }
  .page-heading, .task-titlebar { align-items: flex-start; flex-direction: column; }
  .page-heading .button, .task-titlebar .button { width: 100%; }
  .top-nav button { padding: 0 11px; }
  .context-strip { justify-content: flex-start; overflow-x: auto; white-space: nowrap; }
  .task-grid, .form-grid, .content-edit-panel, .crop-grid, .analysis-grid, .settings-grid,
  .upload-preview-grid, .upload-submit-row, .upload-file-names,
  .structured-ocr-item, .answer-feedback-options { grid-template-columns: 1fr; }
  .analysis-preview-note { align-items: flex-start; flex-direction: column; }
  .answer-items-summary, .answer-item-head { align-items: flex-start; flex-direction: column; }
  .answer-item-target, .answer-item-result { display: grid; gap: 7px; }
  .field.span-2, .analysis-block.wide, .settings-wide { grid-column: auto; }
  .service-card-head { align-items: stretch; flex-direction: column; }
  .diagnostic-log-head, .diagnostic-log-toolbar { align-items: stretch; flex-direction: column; }
  .diagnostic-log-toolbar .button-row { width: 100%; }
  .engine-toggle { width: 100%; }
  .workflow-bar { grid-template-columns: 1fr; }
  .workflow-item { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .workflow-item:last-child { border-bottom: 0; }
  .filter-row { grid-template-columns: 1fr; }
  .button-row .button { flex: 1 1 auto; }
  .card-pad, .section-card { padding: 19px; }
  .user-create-form { align-items: stretch; flex-direction: column; }
  .user-create-form .field { width: 100%; }
  .login-log-row { grid-template-columns: 1fr; gap: 4px; }
  .user-list-heading { display: none; }
  .user-list-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .user-size-details { grid-column: 1 / -1; grid-row: 2; flex-direction: row; flex-wrap: wrap; }
  .user-list-row > div:last-child { grid-column: 2; grid-row: 1; }
  #toast-region { right: 12px; bottom: 12px; width: calc(100% - 24px); }
}

@media print {
  .app-header, .context-strip, .button-row, .back-link, .back-to-top { display: none !important; }
  .page { width: 100%; padding: 0; }
  .card { border: 0; box-shadow: none; }
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(22, 32, 29, 0.36);
}

.modal-card {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--line, #dce5df);
  border-radius: 18px;
  background: var(--paper, #fffdf8);
  box-shadow: 0 24px 70px rgba(22, 32, 29, 0.22);
}

.page-heading.compact {
  margin-bottom: 18px;
}

.cloud-key-status {
  display: grid;
  gap: 6px;
}
