/* 논술 연습실 화면 스타일 (모바일 우선, 밝은/어두운 모드) */
:root {
  --bg: #f6f3ee; --card: #fffdf9; --ink: #1d1b18; --muted: #6b655c; --line: #e4ddd2;
  --accent: #8c1d2f; --accent-ink: #fff; --soft: #f3e6e3; --ok: #2f6b3a; --warn: #9a5b00;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
}
body.ajou { --accent: #1e4f9a; --soft: #e5ecf7; }
@media (prefers-color-scheme: dark) {
  :root { --bg: #151412; --card: #1f1d1a; --ink: #ece7df; --muted: #a39b8f; --line: #34302a; --soft: #3a2326; --shadow: none; }
  body.ajou { --soft: #1f2a3c; }
  body.khu { --accent: #d4566a; } body.ajou { --accent: #6b9be0; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 Pretendard, system-ui, sans-serif; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.3; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; margin: .2em 0 .4em; }
h2 { font-size: 1.15rem; margin: 1.4em 0 .5em; }
.muted { color: var(--muted); }
.err { color: #c0392b; min-height: 1.2em; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; color: var(--ink); text-decoration: none; white-space: nowrap; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; color: var(--muted); font: inherit; font-size: .85rem; padding: 6px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.seg button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
main { max-width: 860px; margin: 0 auto; padding: 16px; outline: none; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: space-around; background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabs a { flex: 1; text-align: center; padding: 8px 0; text-decoration: none; color: var(--muted); font-size: .85rem; border-radius: 10px; }
.tabs a.on { color: var(--accent); font-weight: 800; background: var(--soft); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin: 12px 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.dday { font-size: 2.2rem; font-weight: 800; color: var(--accent); line-height: 1; }
.chip { display: inline-block; font-size: .78rem; padding: 2px 9px; border-radius: 999px; background: var(--soft); color: var(--accent); font-weight: 700; margin-right: 4px; }
.chip.gray { background: var(--line); color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .85rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.list a.item { display: block; text-decoration: none; color: inherit; }
.item h3 { margin: .3em 0 .2em; font-size: 1.02rem; }
textarea, input[type=text], input[type=password], select { width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
textarea { min-height: 260px; resize: vertical; line-height: 1.8; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.counter { font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--muted); text-align: right; }
.counter.over { color: #c0392b; font-weight: 700; } .counter.good { color: var(--ok); font-weight: 700; }
.timer { position: sticky; top: 57px; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin: 8px 0; }
.timer b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.timer.late b { color: #c0392b; }
.md { overflow-wrap: anywhere; }
.md table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-size: .9rem; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; }
.md th { background: var(--soft); }
.md blockquote { margin: .6em 0; padding: .2em 1em; border-left: 3px solid var(--accent); color: var(--muted); }
.md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.md details { background: var(--soft); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.passage { background: color-mix(in srgb, var(--soft) 45%, var(--card)); border-radius: 12px; padding: 4px 14px; }
.qchips { display: flex; gap: 6px; flex-wrap: wrap; }
.qchips label { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; background: var(--card); }
.qchips input { accent-color: var(--accent); }
.subtabs { display: flex; gap: 6px; margin: 12px 0; }
.subtabs button { flex: 1; }
.subtabs button[aria-selected="true"] { background: var(--soft); border-color: var(--accent); color: var(--accent); }
.pages img { width: 100%; border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; background: #fff; }
.pages img.hl { outline: 3px solid var(--accent); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.thumbs figure { position: relative; margin: 0; }
.thumbs img { width: 92px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumbs button { position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: #c0392b; color: #fff; font-weight: 800; cursor: pointer; }
.think { font-size: .82rem; color: var(--muted); white-space: pre-wrap; max-height: 9em; overflow: auto; border-left: 3px solid var(--line); padding-left: 10px; }
.score { font-size: 2.4rem; font-weight: 800; color: var(--accent); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: s 1s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); width: min(92vw, 380px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
svg.chart { width: 100%; height: 160px; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; }
