:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --surface-2: #eef0f4;
  --text: #16181d;
  --muted: #5d6470;
  --line: #e2e5ea;
  /* Each school's own colour (below); the accents are drawn from it. */
  --brand: #862633;
  --accent: var(--brand);
  --accent-soft: color-mix(in srgb, var(--brand) 9%, #ffffff);
  --accent-text: #ffffff;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  /* Sent messages: a soft grey bubble, not a heavy black block. */
  --user: #eceff3;
  --user-text: #16181d;
  --toast: #16181d;
  --toast-text: #ffffff;
  --marker: #fff0a0;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-workspace="school"]) {
    --bg: #111317;
    --surface: #1a1d22;
    --surface-2: #23272e;
    --text: #eceef2;
    --muted: #9aa1ad;
    --line: #2d323a;
    --accent: color-mix(in srgb, var(--brand) 45%, #ffffff);
    --accent-soft: color-mix(in srgb, var(--brand) 22%, #111317);
    --accent-text: #111317;
    --warn: #f0b458;
    --warn-soft: #33260f;
    --user: #2a2f37;
    --user-text: #eceef2;
    --toast: #eceef2;
    --toast-text: #111317;
    --marker: rgba(255, 214, 0, .28);
    color-scheme: dark;
  }
}
/* The school being guided, in its own colour (<html data-school>, set by app.js). */
/* From each school's UI page: 고려대 교색 크림슨 PANTONE 202C, 연세대 YONSEI Blue PANTONE 281C,
   경북대 KNU Red (C10 M100 Y100 K0, no screen value published), 서울시립대
   UOS Signature Blue PANTONE 293C (#004094 on the UI page), 건국대 Heritage Green (2025 identity, no values
   published yet: a near green), 서강대 Sogang Cardinal (C0 M100 Y100 K30 in the UI guide),
   충남대 CNU Blue PANTONE 661C (RGB 3 78 162 on the UI page). */
:root[data-school="korea"] { --brand: #862633; }
:root[data-school="yonsei"] { --brand: #003876; }
:root[data-school="knu"] { --brand: #d1121b; }
:root[data-school="uos"] { --brand: #004094; }
:root[data-school="konkuk"] { --brand: #036b3f; }
:root[data-school="sogang"] { --brand: #a6191e; }
:root[data-school="cnu"] { --brand: #034ea2; }
/* Where relative colours work, the accent keeps the school's hue at a lightness that reads: dark
   enough for white text in light mode, light enough on the dark background. */
@supports (color: oklch(from red l c h)) {
  :root { --accent: oklch(from var(--brand) min(l, 0.5) c h); }
  @media (prefers-color-scheme: dark) {
    :root:not([data-workspace="school"]) { --accent: oklch(from var(--brand) 0.75 clamp(0.08, c, 0.15) h); }
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
/* Keep room for the scrollbar so opening a list does not shift the page sideways. */
html { scrollbar-gutter: stable; }
body {
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
  word-break: keep-all; overflow-wrap: anywhere;
}
button { font: inherit; color: inherit; cursor: pointer; }

.top {
  position: sticky; top: 0; z-index: 25; display: flex; align-items: baseline; gap: 12px;
  max-width: 680px; margin: 0 auto; padding: 14px 16px; background: var(--bg);
}
.brand { border: 0; background: none; padding: 0; font-weight: 700; font-size: 17px; white-space: nowrap; }
.top { flex-wrap: wrap; row-gap: 0; }
@media (max-width: 520px) { .meta { font-size: 12px; flex-basis: 100%; } .hero :is(h1, h2) { font-size: 22px; margin-top: 24px; } }
.meta { color: var(--muted); font-size: 13px; }
.nowrap { white-space: nowrap; }
/* The guideline line, in the menu only where the header leaves it out (내 서류 on a phone). */
@media (max-width: 720px) {
  :root[data-embedded="workspace"] .top .meta { display: none; }
}
.personal-home { color: var(--accent); border: 1px solid var(--line); border-radius: 9px; padding: 5px 10px; min-height: 36px; font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.personal-home:hover { background: var(--accent-soft); }
.personal-home:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.personal-home[hidden] { display: none; }
.workspace-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); flex: 0 0 calc(100% + 88px); margin: 10px -88px 0 0; border-bottom: 1px solid var(--line); }
.workspace-nav[hidden], .workspace-link[hidden], .saved-guide-destination[hidden] { display: none; }
.workspace-link { display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 0; min-height: 46px; padding: 8px 4px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; font-weight: 550; white-space: nowrap; text-decoration: none; }
.workspace-link svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.workspace-link[aria-current="page"] { border-bottom-color: var(--text); color: var(--text); font-weight: 700; }
a.workspace-link:hover { background: var(--surface); color: var(--text); }
.workspace-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.saved-guide-destination { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 700; text-underline-offset: 3px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.card .card-heading h2 { flex: 1; min-width: 0; margin: 0; }
.save-guide { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; margin: -8px -8px 0 0; padding: 10px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.save-guide:hover { background: var(--surface); color: var(--accent); }
.save-guide[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.save-guide[aria-pressed="true"] path { fill: currentColor; }
.bookmark-icon, .bookmark-icon svg { display: block; }
.save-guide[aria-busy="true"] .bookmark-icon { opacity: .55; }
.personal-entry-note { margin: 12px 0; border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--surface); }
.personal-entry-note p { margin: 0 0 10px; }
/* The school being guided: a filled chip in the school colour, not one more grey word. */
.school-chip {
  display: inline-flex; align-items: center; gap: 7px; align-self: center; white-space: nowrap;
  border: 0; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  padding: 4px 11px 4px 12px; font-size: 14px; font-weight: 700;
}
.school-chip .chevron { width: 6px; height: 6px; margin-top: -3px; }
.school-chip[hidden] { display: none; }
.school-chip:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.school-chip[aria-expanded="true"] .chevron { transform: rotate(225deg); margin-top: 3px; }
/* With one school there is nothing to open: the chip is a label, without the chevron. */
.school-chip.only { padding-right: 12px; cursor: default; }
.school-chip.only .chevron { display: none; }
.school-chip.only:hover { box-shadow: none; }
.top { padding-right: 64px; }
.icon-button {
  position: absolute; top: 9px; right: 12px; display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 10px; background: none; color: var(--muted);
}
.search-button { right: 12px; }
.calc-button { right: 52px; }
.calc-button[hidden] { display: none; }
.top.has-calc { padding-right: 104px; }
.icon-button:hover, .icon-button[aria-expanded="true"] { background: var(--surface); color: var(--text); }
.menu {
  position: absolute; top: calc(100% - 4px); right: 12px; z-index: 10; width: min(280px, calc(100vw - 32px));
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .12);
}
.school-menu { right: auto; top: calc(100% - 6px); width: min(240px, calc(100vw - 32px)); }
.menu-label { margin: 6px 10px 2px; color: var(--muted); font-size: 13px; font-weight: 600; }
.school {
  display: flex; align-items: center; width: 100%; text-align: left; border: 0; background: none;
  border-radius: 8px; padding: 9px 10px; font-size: 15px;
}
.school:hover { background: var(--surface); }
.school[aria-checked="true"] { font-weight: 600; }
.school .check { margin-left: auto; color: var(--accent); }
.menu-note { margin: 4px 10px 8px; font-size: 12px; color: var(--muted); }

.chat { max-width: 680px; margin: 0 auto; padding: 8px 16px 160px; }

/* 첫 화면 */
/* (the page's one h1 is its name, for screen readers; the opening question under it is an h2 that looks the same) */
.hero :is(h1, h2) { font-size: 26px; line-height: 1.35; margin: 40px 0 8px; }
.hero p { color: var(--muted); margin: 0 0 20px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; }
.examples button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-size: 14px;
}
.examples button:hover { border-color: var(--accent); }
.examples .extra:not([hidden]) { animation: fade .22s ease; }
/* Quieter than the questions: no fill, a dashed edge, muted text. */
.examples .more { background: none; border: 1px dashed var(--line); color: var(--muted); }
.examples .more:hover { border-color: var(--muted); color: var(--text); }
.folds { margin-top: 44px; border-top: 1px solid var(--line); }
/* Full-width quiet bars, not more pills: each opens its list below. */
.fold-section { border-bottom: 1px solid var(--line); }
.fold-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none;
  padding: 14px 2px; font-size: 14px; font-weight: 600; color: var(--muted); transition: color .2s ease;
}
.fold-toggle .count { font-weight: 400; }
.chevron-wrap { margin-left: auto; flex: none; display: grid; place-items: center; width: 20px; height: 20px; }
.fold-toggle:hover, .fold-toggle[aria-expanded="true"] { color: var(--text); }
.fold-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.chevron {
  width: 7px; height: 7px; margin-top: -3px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); transition: transform .25s ease, margin .25s ease;
}
.fold-toggle[aria-expanded="true"] .chevron { transform: rotate(225deg); margin-top: 3px; }
.fold { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .3s ease, opacity .3s ease; }
.fold.open { grid-template-rows: 1fr; opacity: 1; }
.fold-items { overflow: hidden; min-height: 0; display: grid; gap: 8px; }
.fold.open .fold-items { padding: 2px 0 20px; }
.fold-items h3 { font-size: 15px; margin: 14px 0 0; }
.fold-items h3:first-child { margin-top: 4px; }
.fold-items .task { text-align: left; border: 1px solid var(--line); background: none; border-radius: var(--radius); padding: 12px 14px; }
.fold-items .task:hover { border-color: var(--accent); }
.fold-items .task small { display: block; color: var(--muted); font-size: 13px; }
.toc { display: grid; }
.toc-row { display: flex; gap: 10px; align-items: baseline; text-align: left; border: 0; background: none; border-radius: 8px; padding: 7px 8px; font-size: 15px; }
.toc-row:hover { background: var(--surface); }
.toc-row .no { flex: none; min-width: 5.5em; color: var(--muted); font-size: 13px; }
@media (prefers-reduced-motion: reduce) { .fold, .chevron, .fold-toggle { transition: none; } }

/* 대화 */
.msg { margin: 18px 0; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.user { display: flex; justify-content: flex-end; }
.user span { background: var(--user); color: var(--user-text); padding: 9px 14px; border-radius: 18px 18px 4px 18px; max-width: 80%; white-space: pre-wrap; }
.bot .prose { white-space: pre-line; margin: 0 0 10px; }
.bot hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0 12px; }
.bot .question { margin: 0 0 12px; color: var(--muted); }
.bot.current .question { color: var(--text); font-weight: 700; font-size: 18px; }
.options { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.options button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 9px 16px; text-align: left; max-width: 100%;
}
.options button:hover { border-color: var(--accent); }
.options button small { display: block; color: var(--muted); font-size: 13px; }
.options.multi { align-items: stretch; }
.multi-hint { margin: -6px 0 10px; color: var(--muted); font-size: 13.5px; }
/* 다음 stays in view above the composer while the choices run under it (--composer-h, app.js). */
.next-bar { position: sticky; bottom: calc(var(--composer-h, 92px) - 8px); z-index: 1; margin-top: 10px; padding: 8px 0; background: var(--bg); }
.options.multi label {
  display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer;
}
.options.multi label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.options.multi input { accent-color: var(--accent); width: 18px; height: 18px; }
/* The option the researcher's own words point to: a quiet '추천' tag and a soft pulse when it appears
   (no border or fill, which would read as already chosen). */
.options button.suggested, .options.multi label.suggested { animation: nudge 1.6s ease-out .35s 2; }
@keyframes nudge {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--muted) 35%, transparent); }
  70% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--muted) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.suggest-tag { display: inline-block; margin-left: 8px; font-size: 11.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; vertical-align: 1px; }
.primary {
  border: 0; background: var(--accent); color: var(--accent-text); border-radius: 12px; padding: 12px 16px; font-weight: 700; width: 100%;
}
.primary:disabled { opacity: .45; cursor: default; }
.controls { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.link { border: 0; background: none; padding: 0; color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--text); }
.thinking { color: var(--muted); font-size: 14px; }
.thinking .flow-reset { margin-left: 14px; min-height: 44px; }
.flow-error { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.flow-error h2 { margin: 0 0 8px; font-size: 17px; }
.flow-error p { margin: 0; overflow-wrap: anywhere; }
.flow-error button { min-height: 44px; }
.chat button:disabled, .chat input:disabled, .composer button:disabled { opacity: .55; cursor: wait; }
.thinking i { display: inline-block; width: 6px; height: 6px; margin-left: 3px; border-radius: 50%; background: currentColor; animation: dot 1.2s infinite ease-in-out; }
.thinking i:nth-child(2) { animation-delay: .15s; } .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* 검색 결과 */
.hits { display: grid; gap: 8px; margin: 4px 0 16px; }
.hit { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; }
.hit b { display: block; font-size: 14px; }
/* Searched words inside a clause, like a marker pen. */
mark { background: var(--marker); color: inherit; border-radius: 3px; padding: 0 1px; }
.hit span { display: block; color: var(--muted); font-size: 13px; }
.label-sm { font-size: 13px; color: var(--muted); font-weight: 600; margin: 12px 0 6px; }

/* 행동 카드 */
.card { border: 1px solid var(--line); border-radius: 18px; padding: 18px; background: var(--bg); }
.card h2 { font-size: 20px; margin: 0 0 4px; }
.card .summary { margin: 0 0 14px; color: var(--muted); }
.answers { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; }
.answers li { background: var(--surface); border-radius: 8px; padding: 3px 9px; font-size: 13px; color: var(--muted); border: 1px solid transparent; }
.card h3 { font-size: 14px; color: var(--muted); margin: 18px 0 8px; font-weight: 700; }
.forms { display: grid; gap: 8px; }
.form-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.form-row .name { flex: 1; min-width: 0; }
.form-row .name b { display: block; font-size: 13px; color: var(--accent); }
.form-row .name span { font-size: 15px; }
.form-helper-note { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.form-row .open { border: 0; background: var(--accent); color: var(--accent-text); border-radius: 10px; padding: 7px 12px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.form-row a.open { text-decoration: none; display: inline-block; }
.form-row .download { border: 1px solid var(--line); background: none; border-radius: 10px; padding: 6px 10px; font-size: 14px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 10px; }
.steps li { position: relative; padding-left: 34px; }
.steps li::before {
  counter-increment: step; content: counter(step); position: absolute; left: 0; top: 1px;
  width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px;
  display: grid; place-items: center;
}
.steps li.warning::before { content: "!"; counter-increment: none; background: var(--warn-soft); color: var(--warn); }
/* On the card just shown, a soft ring breathes out from the "!" twice, then rests. */
.msg.current .steps li.warning::before { animation: warn-pulse 2.4s ease-in-out .6s 2; }
@keyframes warn-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--warn) 30%, transparent); }
  35% { transform: scale(1.06); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px color-mix(in srgb, var(--warn) 0%, transparent); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}
.cond { display: inline-block; font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; margin-right: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 1px 8px; font-size: 12.5px; color: var(--muted); }
.chip.form { color: var(--accent); border-color: transparent; background: var(--accent-soft); }
.chip:hover { border-color: var(--accent); }
a.chip.source { text-decoration: none; display: inline-block; }
.notes { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.notes li { background: var(--surface); border-radius: 12px; padding: 10px 12px; font-size: 15px; }
.notes li.warning { background: var(--warn-soft); }
.notes li.warning::before { content: "주의 "; font-weight: 700; color: var(--warn); }
/* 규정마다 기준이 다른 항목: 기준을 나란히, 어느 쪽도 고르지 않는다 */
.differs-badge { display: block; font-size: 12.5px; font-weight: 700; color: var(--warn); margin-bottom: 2px; }
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin-top: 8px; }
.rule { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.rule p { margin: 2px 0 0; font-size: 14.5px; }
.rule-source { font-size: 12px; color: var(--muted); font-weight: 600; }
.also { display: grid; gap: 8px; }
.also button { text-align: left; border: 1px dashed var(--accent); background: none; border-radius: 12px; padding: 10px 12px; color: var(--accent); font-weight: 600; }
.source { font-size: 12.5px; color: var(--muted); margin: 16px 0 0; }
.search-offer { display: block; margin: 6px 0 2px; padding: 7px 12px; border: 1px dashed var(--line); border-radius: 10px; background: none; color: var(--accent); font-size: 14px; text-align: left; }
.search-offer:hover { border-color: var(--accent); }
.ask-guide { margin-top: 12px; }
/* Korean typed in English, read as Korean: like a search engine's "…(으)로 검색한 결과". */
.corrected { margin: 0 0 12px; font-size: 15px; }
.corrected p { margin: 0; }
.corrected b { color: var(--accent); }
.corrected-sub { margin-top: 2px !important; font-size: 13px; color: var(--muted); }
.corrected-sub .link { font-size: 13px; }

/* 입력창 */
.composer { position: fixed; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 20px 16px 16px; }
.composer-inner { max-width: 648px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); padding: 8px 8px 8px 14px; box-shadow: 0 4px 20px rgb(0 0 0 / .06); }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: none; color: var(--text); font: inherit; padding: 6px 0; max-height: 140px; overflow-y: hidden; }
.composer-inner:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent), 0 4px 20px rgb(0 0 0 / .06); }
.composer textarea::placeholder { color: var(--muted); }
.composer button { border: 0; background: var(--accent); color: var(--accent-text); border-radius: 10px; width: 38px; height: 38px; display: grid; place-items: center; flex: none; }

/* 조문 패널 */
.drawer {
  position: fixed; top: var(--guide-header-h, 72px); right: 0; bottom: 0; width: var(--drawer-w); z-index: 20; background: var(--bg);
  border-left: 1px solid var(--line); box-shadow: -8px 0 30px rgb(0 0 0 / .1); transform: translateX(105%); transition: transform .2s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
/* Wide screens keep one reading column centered beside the reserved tool pane. */
:root { --drawer-w: min(520px, 100%); }
@media (min-width: 900px) {
  :root { --drawer-w: clamp(360px, 40vw, 520px); }
  /* Reserve the tool pane before it opens, so the reading column never jumps. */
  body { --push: var(--drawer-w); }
  .chat { width: calc(100% - var(--push)); transform: translateX(calc(var(--push) / -2)); }
  .composer { right: var(--push); }
  .toast { left: calc((100% - var(--push)) / 2); }
  body.reading .drawer { box-shadow: none; }
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-head button { border: 0; background: none; font-size: 18px; color: var(--muted); }
.drawer-head strong { margin-right: auto; }
.search-form { padding: 12px 16px 0; }
.search-form input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text);
  font: inherit; padding: 9px 12px; outline: 0;
}
.search-form input:focus { border-color: var(--accent); }
.search-note { color: var(--muted); font-size: 14px; margin: 4px 0; }
.search-count { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.drawer-body { overflow: auto; padding: 14px 16px 40px; }
.clause { margin: 0 0 8px; font-size: 15px; }
.clause .no { font-weight: 700; margin-right: 4px; }
.clause.hl { background: var(--accent-soft); border-radius: 8px; padding: 6px 8px; margin-left: -8px; margin-right: -8px; }
.clause .amend { color: var(--muted); font-size: 12.5px; }
.tbl-wrap { overflow-x: auto; margin: 8px 0 14px; }
table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
td { border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; white-space: pre-line; overflow-wrap: normal; }
table:not(.form-table) tr:first-child td { background: var(--surface); font-weight: 600; }

/* Above the composer however tall it has grown (none while a sheet is open), as wide as its words up to the screen. */
.toast { position: fixed; left: 50%; bottom: calc(var(--composer-h, 88px) + 8px); transform: translateX(-50%); background: var(--toast); color: var(--toast-text); padding: 8px 14px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
.toast.show { opacity: 1; }
/* An error stays until closed: it can be clicked, and says so with its ✕. */
.toast { display: flex; align-items: center; gap: 10px; width: max-content; max-width: min(560px, calc(100vw - 32px)); }
.toast.error { pointer-events: auto; padding-right: 6px; }
.toast-close { border: 0; background: none; color: inherit; font-size: 15px; min-width: 32px; min-height: 32px; border-radius: 8px; }
.toast-close:hover { background: rgb(255 255 255 / .15); }

@media (prefers-reduced-motion: reduce) { .msg, .thinking i, .options button.suggested, .options.multi label.suggested, .msg.current .steps li.warning::before { animation: none; } .drawer, body, .composer { transition: none; } }
/* A focus ring that reads on every surface: the accent, thick enough, off the edge. */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.search-form input:focus-visible { outline: 0; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
/* A finger needs 44px: the header icons, the drawer's ← and ✕, the step links and the clause chips (their hit area). */
@media (pointer: coarse) {
  .icon-button { top: 5px; width: 44px; height: 44px; right: 6px; }
  .search-button { right: 6px; }
  .calc-button { right: 52px; }
  .top { padding-right: 60px; }
  .top.has-calc { padding-right: 104px; }
  .drawer-head { padding-top: 8px; padding-bottom: 8px; }
  .drawer-head button { min-width: 44px; min-height: 44px; }
  .controls { gap: 4px 18px; }
  .controls .link, .thinking .flow-reset { min-height: 44px; display: inline-flex; align-items: center; }
  .chip { position: relative; min-height: 30px; padding: 3px 10px; }
  .chip::after { content: ''; position: absolute; inset: -7px -3px; }
}
/* For search engines and screen readers only. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Form writing skill (작성 도우미) in the drawer. */
/* With the helper there are up to three buttons: on a narrow screen they go under the name. */
.form-row { flex-wrap: wrap; }
.form-row .name { flex: 1 1 14em; }
.form-row .skill { border: 1px solid var(--accent); background: none; color: var(--accent); border-radius: 10px; padding: 6px 10px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.skill-note { font-size: 13px; color: var(--muted); margin: 0 0 8px; white-space: pre-line; }
.skill-rules, .skill-notes { padding-left: 18px; margin: 0; font-size: 14px; display: grid; gap: 6px; }
.skill-rules li, .skill-notes li { white-space: pre-line; }
.tip p { margin: 0 0 4px; }
.tip .tip-head { margin-top: 10px; color: var(--text); font-weight: 600; }
.tip .tip-list { margin: 0 0 4px; padding-left: 16px; display: grid; gap: 2px; }
.tip .chips { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.skill-rules .chips { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.skill-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 8px; }
.skill-actions .primary { width: auto; }
.skill-actions .secondary { border: 1px solid var(--line); background: none; border-radius: 10px; padding: 8px 12px; font-size: 14px; color: var(--text); text-decoration: none; }

/* The form drawn as it looks, filled where it stands (작성 도우미): a sheet over the page, the paper on the left and
   the chosen cell's help on the right; on a narrow screen the help goes under the paper. The paper stays light like
   the printed form. The clause drawer (z-index 20) opens above it. */
body.sheet-open { overflow: hidden; }
.sheet { position: fixed; inset: var(--guide-header-h, 72px) 0 0; z-index: 15; display: flex; background: rgb(0 0 0 / .35); }
/* The helper fills the window, as on a phone: no margin, corners or shadow round it. */
.sheet-panel { position: relative; width: 100%; height: 100%; background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
.form-tabs { display: flex; gap: 2px; padding: 8px 10px 0; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--surface); scrollbar-width: thin; }
.form-tab { flex: none; max-width: 240px; display: flex; align-items: baseline; white-space: nowrap; gap: 5px; border: 1px solid transparent; border-bottom: 0; border-radius: 9px 9px 0 0; background: none; color: var(--muted); padding: 7px 12px; font-size: 13.5px; cursor: pointer; }
.form-tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-tab b { color: var(--text); font-weight: 600; }
.form-tab:hover { color: var(--text); }
.form-tab[aria-selected="true"] { background: var(--bg); border-color: var(--line); color: var(--text); margin-bottom: -1px; }
/* (a form with something written in it) */
.form-tab.begun::after { content: ''; flex: none; align-self: center; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.forms-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.forms-head h3 { margin-right: auto; }
.forms-head .skill-all { margin: 12px 0 4px; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 6px 12px; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.forms-head .skill-all:hover { background: var(--accent); color: #fff; }
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.sheet-title { margin-right: auto; display: flex; align-items: center; gap: 6px; min-width: 0; }
.sheet-actions, .sheet-secondary-actions { display: contents; }
.sheet-more-toggle, .sheet-help-toggle { display: none; }
.sheet-head strong { font-size: 15.5px; }
.sheet-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sheet-name small { color: var(--muted); font-size: 12px; }
.sheet-undo { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: none; color: var(--text); padding: 0; }
.sheet-undo:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.sheet-undo:disabled { opacity: .35; cursor: default; }
.sheet-head .primary { width: auto; padding: 8px 14px; font-size: 14px; }
.sheet-head .secondary { border: 1px solid var(--line); background: none; border-radius: 10px; padding: 7px 12px; font-size: 14px; color: var(--text); text-decoration: none; }
.sheet-close { border: 0; background: none; font-size: 18px; color: var(--muted); padding: 4px 6px; }
.hand-note { margin: 0; padding: 8px 14px; font-size: 13px; color: var(--warn); background: var(--warn-soft); }
.sheet-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(380px, 34vw, 500px); }
.paper-wrap { overflow: auto; background: var(--surface-2); padding: 24px; }
.paper { color-scheme: light; background: #fff; color: #111; max-width: 780px; margin: 0 auto; padding: 36px 40px; box-shadow: 0 1px 4px rgb(0 0 0 / .15); font-size: 13px; line-height: 1.45; }
.paper p { margin: 2px 0; white-space: pre-wrap; }
.paper .form-no { font-size: 12.5px; }
.paper .form-title { text-align: center; font-size: 20px; font-weight: 700; margin: 6px 0 14px; }
.paper .form-note { font-size: 11.5px; color: #444; }
.form-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 10px 0; }
.form-table td { border: 1px solid #333; padding: 3px 5px; vertical-align: middle; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
.form-table .cell-label { background: #f1f2f4; font-weight: 600; text-align: center; }
.form-table .cell-static { color: #666; text-align: center; }
.form-table .byhand { color: #888; font-weight: 500; }
.byhand-tag { display: block; font-size: 10.5px; color: #a07000; font-weight: 500; }
.form-table .cell-field { padding: 0; background: #fff8d6; }
.form-table .cell-field:focus-within { background: #fff; outline: 2px solid var(--brand); outline-offset: -2px; }
.cell-field textarea { display: block; width: 100%; box-sizing: border-box; border: 0; background: transparent; resize: none; overflow: hidden; font: inherit; font-size: 13px; line-height: 1.4; padding: 5px 6px; color: #111; min-height: 28px; }
.cell-field.prose textarea { min-height: 72px; }
.cell-field textarea:focus { outline: 0; }
.cell-field textarea::placeholder { color: #a3a8b0; }
.sheet-side { overflow: auto; border-left: 1px solid var(--line); padding: 14px 16px 40px; display: grid; align-content: start; gap: 10px; }
.sheet-help-content { display: grid; align-content: start; gap: 10px; min-width: 0; }
.sheet-side h3 { font-size: 16px; margin: 0 0 4px; }
.side-label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 0 0 2px; }
.side-cell { background: var(--surface); border-radius: 12px; padding: 12px; display: grid; gap: 6px; }
.side-cell[hidden] { display: none; }
.terms { display: grid; gap: 4px; }
.term { margin: 0; font-size: 13.5px; }
.term .chips { display: inline-flex; vertical-align: middle; }
.side-part { border-top: 1px solid var(--line); padding-top: 8px; }
.side-part summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 0; }
.side-part[open] > summary { margin-bottom: 6px; }
@media (max-width: 860px) {
  .sheet-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .sheet-body.with-help { grid-template-rows: minmax(0, 1fr) minmax(0, 42%); }
  .sheet-side { border-left: 0; border-top: 1px solid var(--line); padding: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 0; }
  .sheet-help-toggle { display: flex; align-items: center; justify-content: space-between; flex: none; width: 100%; min-height: 42px; border: 0; padding: 10px 14px; color: var(--text); background: var(--surface); font: inherit; font-size: 13px; text-align: left; }
  .sheet-help-toggle::after { content: '⌄'; font-size: 17px; }
  .sheet-help-toggle[aria-expanded="true"]::after { content: '⌃'; }
  .sheet-help-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
  .sheet-help-content { display: none; min-height: 0; padding: 12px 14px 24px; overflow: auto; }
  .sheet-help-content[data-expanded="true"] { display: grid; }
  .paper-wrap { padding: 8px; }
  /* A table of many columns keeps room to write in (app.js --paper-min); the paper then scrolls sideways. */
  .paper { padding: 16px 10px; min-width: calc(var(--paper-min, 0px) + 20px); }
  .sheet-title { flex-basis: 100%; }
}
/* A phone keeps one primary action and an explicit more button. Expanded secondary actions wrap inside the viewport. */
@media (max-width: 600px) {
  .sheet-head { gap: 6px; padding: 8px 10px; }
  .sheet-title { flex: 1 1 0; }
  .sheet-title strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
  .sheet-name small { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sheet-title .sheet-undo { flex: none; width: 30px; height: 30px; }
  .sheet-actions { display: flex; order: 2; flex-basis: 100%; flex-wrap: wrap; gap: 6px; min-width: 0; }
  .sheet-actions > .primary { flex: 1 1 auto; min-width: 0; }
  .sheet-more-toggle { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
  .sheet-secondary-actions { display: none; }
  .sheet-secondary-actions[data-expanded="true"] { display: flex; flex-basis: 100%; flex-wrap: wrap; gap: 6px; padding-top: 2px; min-width: 0; }
  .sheet-secondary-actions > * { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .sheet-head .primary, .sheet-head .secondary, .sheet-head .personal-home { padding: 6px 10px; font-size: 13px; min-height: 34px; }
}
.form-table .cell-check { background: #fff8d6; font-size: 12.5px; }
.form-table .cell-check .check-text { white-space: pre-wrap; margin-bottom: 4px; color: #333; }
.form-table .cell-check .check-pair { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-top: 4px; }
.form-table .cell-check .check-topic { flex-basis: 100%; color: #333; font-weight: 600; }
.form-table .cell-check label { display: inline-flex; align-items: center; gap: 3px; margin-right: 10px; white-space: nowrap; }
.form-table .cell-sign { background: repeating-linear-gradient(135deg, #fafafa 0 6px, #f0f0f0 6px 7px); }
.paper .form-line.writable { margin: 4px 0; text-align: right; }
.form-input-line { width: min(100%, 360px); border: 0; border-bottom: 1px solid #c9a400; background: #fff8d6; font: inherit; font-size: 13px; color: #111; padding: 3px 6px; text-align: right; }
.form-input-line:focus { outline: 2px solid var(--brand); outline-offset: 1px; background: #fff; }
.form-table .group { position: relative; }
.row-tools { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 4px; }
.row-tools button { width: 20px; height: 18px; border: 1px solid #c9c9c9; background: #fff; color: #333; border-radius: 5px; font-size: 12px; line-height: 1; padding: 0; }
.row-tools button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.row-tools button:disabled { opacity: .35; cursor: default; }
/* A list's ＋ − on a thin row under its last record (not part of the form). */
.form-table tr.list-tools td { padding: 2px 6px; background: #fafafa; text-align: left; white-space: nowrap; }
.list-tools .row-tools { display: inline-flex; flex-direction: row; gap: 4px; margin: 0 6px 0 0; vertical-align: middle; }
.list-tools-note { color: #6b6b6b; font-size: 11px; vertical-align: middle; }
/* A finger: a row group's ＋ − grow too and stand further apart (they are stacked, and − next to ＋ is easy to hit by
   mistake), reaching a little sideways; a list's, on their own row under the form's, grow more. */
@media (pointer: coarse) {
  .row-tools { gap: 8px; }
  .row-tools button { position: relative; width: 32px; height: 28px; font-size: 14px; }
  .row-tools button::after { content: ''; position: absolute; inset: -4px -6px; }
  .list-tools .row-tools button { width: 40px; height: 32px; font-size: 15px; }
  .list-tools .row-tools button::after { inset: -6px -2px; }
}
.cell-more { display: grid; gap: 8px; }
.help-box { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 4px; font-size: 14px; }
.help-box p { margin: 0; }
.rate-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rate-table td { border-top: 1px solid var(--line); padding: 4px 2px; vertical-align: top; }
.rate-table td:last-child { text-align: right; font-weight: 600; padding-left: 8px; overflow-wrap: anywhere; }
.rate-table td:last-child.lines { text-align: left; white-space: pre-line; font-weight: 500; min-width: 9em; }
.cell-field textarea.untouched, .form-input-line.untouched { color: #9aa0a8; }
.rate-limit { font-size: 13.5px; color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 6px 8px; }
.rate-limit .chips { display: inline-flex; gap: 4px; vertical-align: middle; }
/* What the helper remembers (최근 입력, 사람 목록, 지난 기록). */
.memory { display: grid; gap: 4px; }
.memory:empty { display: none; }
.memory .chips { display: flex; flex-wrap: wrap; gap: 4px; }
.memory .chip.recent { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.records { display: grid; gap: 8px; }
.side-rules[hidden] { display: none; }
/* 지난 기록 (from the toolbar, at the right) and 양식 설명 (from the ⓘ by the name, at the left) open over the form. */
.sheet-pop { position: absolute; z-index: 2; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgb(0 0 0 / .18); padding: 10px 14px 14px; display: grid; gap: 8px; align-content: start;
  max-height: calc(100% - 80px); overflow: auto; width: min(460px, calc(100% - 28px)); }
.sheet-pop[hidden] { display: none; }
.records-pop { right: 14px; }
.about-pop { left: 14px; }
.about-pop p { margin: 0; font-size: 14px; }
.about-pop .chips { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.records-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.records-pop-head strong { font-size: 15px; }
.sheet-about { font: italic 600 15px/1 Georgia, serif; }
.sheet-head .secondary[aria-expanded="true"] { border-color: var(--brand); color: var(--brand); }
/* One line between the parts under the chosen cell's box (이 칸의 규칙, 이 칸의 주의사항), none under the box. */
.side-cell + .side-part { border-top: 0; padding-top: 0; }
.record-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.record-list li { background: var(--surface); border-radius: 10px; padding: 8px 10px; }
.record-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.record-head small { color: var(--muted); white-space: nowrap; }
.record-list p { margin: 2px 0 6px; font-size: 13px; color: var(--muted); }
.record-actions, .record-tools { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.record-actions .link, .record-tools .link { font-size: 13px; }
.grade-list { display: grid; gap: 8px; margin-top: 4px; }
.grade-list .grade { border-top: 1px solid var(--line); padding-top: 6px; display: grid; gap: 2px; }
.grade-list .grade p { font-size: 13px; }
.grade-list .grade.found { background: var(--accent-soft); border-radius: 8px; border-top-color: transparent; padding: 6px 8px; }
.grade-area { color: var(--muted); font-size: 12.5px; }
.side-pick { display: grid; gap: 6px; }
.side-pick[hidden] { display: none; }
.pick { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 4px; }
.pick-value { margin: 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 7.5em; overflow: auto; }
.pick-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pick-foot small { color: var(--muted); font-size: 12px; }
.pick-foot .link { font-size: 13px; white-space: nowrap; }
.text-choice { display: block; white-space: pre-wrap; padding: 5px 6px; font-size: 13px; line-height: 1.6; color: #111; }
.text-choice input { margin: 0 3px; vertical-align: -2px; width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }
.choice-line .text-choice { display: inline-block; background: #fff8d6; border-bottom: 1px solid #c9a400; padding: 3px 8px; }
.check-panel { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; background: rgb(0 0 0 / .3); padding: 16px; }
.check-box { background: var(--bg); color: var(--text); border-radius: 14px; box-shadow: 0 12px 40px rgb(0 0 0 / .25); width: min(600px, 100%); max-height: calc(100% - 32px); overflow: auto; padding: 18px 20px; display: grid; gap: 10px; }
.check-box h3 { margin: 0; font-size: 17px; }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.check-list li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.check-list li.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: var(--warn-soft); }
.check-list p { margin: 0 0 4px; font-size: 14px; }
.check-list .chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.check-mark { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: var(--muted); margin-top: 1px; }
.check-list li.warn .check-mark { background: var(--warn); }
.check-forms .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.check-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.check-actions .primary { width: auto; padding: 8px 14px; }
.check-actions .secondary { border: 1px solid var(--line); background: none; border-radius: 10px; padding: 7px 12px; font-size: 14px; color: var(--text); }
.paper .form-line.writable.long { text-align: left; }
.form-input-line.long { display: block; width: 100%; box-sizing: border-box; text-align: left; resize: none; overflow: hidden; line-height: 1.45; min-height: 26px; }
.paper .form-line.writable.left { text-align: left; }
.paper .form-line.writable.left .form-input-line { text-align: left; }
.paper .form-line.field-line { display: flex; align-items: baseline; gap: 4px; }
.paper .form-line.field-line .line-lead { white-space: pre-wrap; flex: none; }
.paper .form-line.field-line .form-input-line { flex: 1; width: auto; min-width: 0; }
.paper .check-line { background: #fff8d6; padding: 4px 6px; border-radius: 4px; }
.paper .check-line input { margin-right: 4px; vertical-align: -2px; width: 15px; height: 15px; accent-color: var(--brand); }
.account-save-conflicts { position: fixed; z-index: 100; bottom: 12px; left: 12px; right: 12px; max-width: 620px; max-height: 50vh; overflow: auto; margin: auto; display: grid; gap: 8px; }
.account-save-conflict { padding: 14px 18px; border: 2px solid var(--warn); border-radius: 12px; background: var(--warn-soft); color: var(--text); box-shadow: 0 4px 20px #0002; }
.account-save-conflict p { margin: 6px 0 10px; font-size: 14px; }
.account-save-conflict button { padding: 8px 12px; }
/* Over an open sheet a notice takes its room from the sheet's bottom (--notice-room, app.js) and covers none of it;
   behind a dialog over the sheet (내려받기 전 점검, a clause) it is hidden until that closes. On a small screen the
   storage notice is a bar: its title and actions, the explanation kept for screen readers. */
.account-save-conflicts[inert] { display: none; }
body.sheet-open .sheet { bottom: var(--notice-room, 0px); }
@media (max-width: 600px), (max-height: 600px) {
  body.sheet-open .account-save-conflicts { bottom: 8px; left: 8px; right: 8px; }
  body.sheet-open .account-save-conflict[data-storage-error] { padding: 8px 12px; }
  body.sheet-open .account-save-conflict[data-storage-error] strong { display: block; margin-bottom: 6px; font-size: 14px; }
  body.sheet-open .account-save-conflict[data-storage-error] p { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
  body.sheet-open .account-save-conflict[data-storage-error] button { padding: 6px 10px; font-size: 13px; }
}

/* Calculators: the school's tables worked out for what is chosen (calc.js). */
.calc-list { display: grid; gap: 8px; margin-top: 10px; }
.calc-pick { display: grid; gap: 3px; text-align: left; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 10px 12px; color: var(--text); font-size: 15px; }
.calc-pick span { color: var(--muted); font-size: 13px; }
.calc-pick:hover { border-color: var(--accent); }
.calc-form { display: grid; gap: 12px; margin: 8px 0 18px; }
.calc-field { display: grid; gap: 5px; }
.calc-field[hidden] { display: none; }
.calc-field > label, .calc-lookup > label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.calc-field select, .calc-field input { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); padding: 6px 10px; font: inherit; font-size: 15px; }
.calc-number { display: flex; align-items: center; gap: 8px; }
.calc-number input { max-width: 140px; }
.calc-number span { color: var(--muted); font-size: 14px; }
.calc-lookup { display: grid; gap: 5px; margin-top: 4px; padding: 8px 10px; border-radius: 8px; background: var(--surface); }
.calc-hint { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.calc-hint[hidden] { display: none; }
.calc-lines { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 8px; }
.calc-line { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.calc-line-head { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; }
.calc-line-head strong { white-space: nowrap; }
.calc-how { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.calc-total { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--accent-soft); display: grid; gap: 4px; }
.calc-total p { margin: 0; display: flex; justify-content: space-between; gap: 10px; font-size: 15px; }
.calc-total strong { color: var(--accent); white-space: nowrap; }
.calc-notes li { margin-bottom: 6px; }
.calc-total .calc-actual { display: block; color: var(--muted); font-size: 13px; }
.calc-total.other { background: var(--surface); border: 1px solid var(--line); }
/* What may be paid, one line: kept at the bottom of the drawer while the fields above are written. */
/* (stuck to the drawer's very bottom: the drawer body's 40px bottom padding would otherwise show the card through) */
.calc-summary { position: sticky; bottom: -40px; z-index: 1; margin: 0 -16px 14px; padding: 10px 16px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 15px; border-top: 1px solid var(--line); }
.calc-summary:empty { display: none; }
.calc-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.calc-link { border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 7px 12px; font-size: 14px; font-weight: 600; }
.calc-link:hover { background: var(--accent); color: #fff; }

/* In the personal workspace, navigation spans the pane while the conversation
   and composer share one reading column. The scrollbar stays at the window edge. */
:root[data-embedded="workspace"] { --guide-content-w: 720px; }
:root[data-embedded="workspace"] .top {
  max-width: none; min-height: 76px; margin: 0; padding: 14px 112px 14px 28px;
  gap: 4px 12px; border-bottom: 1px solid var(--line);
}
:root[data-embedded="workspace"] .top .meta { flex-basis: 100%; font-size: 12px; line-height: 1.5; }
:root[data-embedded="workspace"] .top .icon-button { top: 10px; width: 44px; height: 44px; }
:root[data-embedded="workspace"] .top .search-button { right: 12px; }
:root[data-embedded="workspace"] .top .calc-button { right: 56px; }
:root[data-embedded="workspace"] .chat { max-width: var(--guide-content-w); padding: 28px 28px 160px; }
:root[data-embedded="workspace"] .composer { padding: 20px 28px 16px; }
:root[data-embedded="workspace"] .composer-inner { max-width: calc(var(--guide-content-w) - 56px); }
@media (max-width: 720px) {
  :root[data-embedded="workspace"] .top { min-height: 60px; padding: 16px 112px 16px 16px; }
  :root[data-embedded="workspace"] .top .brand { font-size: 16px; }
  :root[data-embedded="workspace"] .top .school-chip,
  :root[data-embedded="workspace"] .top .meta { display: none; }
  :root[data-embedded="workspace"] .top .icon-button { top: 8px; }
  :root[data-embedded="workspace"] .chat { padding: 20px 16px 150px; }
  :root[data-embedded="workspace"] .composer { padding: 16px; }
}

/* A retained writer belongs to My documents; its guide remains available behind it. */
:root[data-embedded="workspace"] body.workspace-writing #chat,
:root[data-embedded="workspace"] body.workspace-writing #composer { visibility: hidden; }

/* The document workspace already provides navigation and school identity. */
:root[data-embedded="workspace"] body.workspace-writing #guide-header { display: none; }
:root[data-embedded="workspace"] body.workspace-writing .sheet,
:root[data-embedded="workspace"] body.workspace-writing #drawer { top: 0; }

body.writer-only #composer,body.writer-only #search-button,body.writer-only #chat:not(:has(.personal-entry-note)){display:none}body.writer-only .sheet{visibility:visible}
