:root {
  font-family: 'Pretendard', 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  background: #eef4ef;
  color: #192e24;
  --muted: #476156;
  --line: #d6e3d9;
  --accent: #167349;
  --accent-dark: #105939;
  --tint: #eaf5ed;
  --control-border: #cbded0;
  --focus: #368b62;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent-dark); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.wrap { width: 100%; max-width: 1040px; margin-inline: auto; padding: 30px 34px 34px; min-width: 0; }
.topbar { border-bottom: 1px solid var(--line); background: white; }
.top-inner { height: 67px; display: flex; align-items: center; justify-content: space-between; padding-inline: 24px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: #192e24; text-decoration: none; font-size: 1.15rem; font-weight: 800; letter-spacing: -.035em; word-break: keep-all; }
.brand-mark { display: grid; flex: none; place-items: center; width: 35px; height: 35px; border-radius: 9px; color: var(--accent-dark); background: #e1f0e6; }
.header-link { font-size: .875rem; font-weight: 700; text-underline-offset: 3px; }
.header-links { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 13px; justify-content: end; }
.app-layout { display: grid; grid-template-columns: 194px minmax(0, 1fr); min-height: calc(100vh - 68px); }
.sidebar { padding: 24px 14px; background: #f9fcf9; border-right: 1px solid var(--line); }
.sidebar nav { display: grid; position: sticky; top: 24px; gap: 5px; }
.sidebar a { white-space: nowrap; text-decoration: none; padding: 11px 12px; border-radius: 8px; color: var(--muted); font-size: .89rem; font-weight: 690; }
.sidebar a:hover, .sidebar .nav-current { color: var(--accent-dark); background: #e3f1e7; }
.sidebar .nav-current { font-weight: 800; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 20px; }
.eyebrow { color: var(--accent-dark); font-size: .88rem; font-weight: 720; }
h1 { margin-top: 5px; font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 850; letter-spacing: -.06em; }
.card { border: 1px solid var(--line); background: white; border-radius: 15px; box-shadow: 0 5px 18px #213b2b08; }
.form-content { padding: 23px 24px 14px; }
.settings-title { margin-bottom: 15px; font-size: 1.12rem; letter-spacing: -.035em; }
.mode-tabs { display: flex; gap: 7px; margin-bottom: 14px; }
.mode-tabs [aria-pressed=true] { background: var(--tint); border-color: #92b99f; }
.textbook-field { margin-top: 8px; }
.export-actions label { min-width: 130px; }
.export-actions label select { margin-top: 2px; min-height: 35px; padding-block: 6px; }
.two-fields, .counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field, .field-label { color: #2b4035; font-size: .92rem; font-weight: 730; }
.field-hint { margin-left: 3px; font-size: .78rem; font-weight: 500; color: var(--muted); }
.field { display: block; min-width: 0; }
input:not([type=checkbox], [type=file]), select, textarea, .scope-picker > summary { display: block; width: 100%; margin-top: 6px; border: 1px solid var(--control-border); border-radius: 8px; background-color: #fff; color: #1c382b; min-height: 41px; padding: 9px 11px; font-size: .91rem; font-weight: 500; }
input[aria-invalid=true] { border-color: #ba4e69; }
select { appearance: none; padding-right: 33px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { resize: vertical; line-height: 1.55; }
::placeholder { color: var(--muted); }
.scope, .basics { margin-top: 16px; }
.scope-picker { position: relative; }
.scope-picker > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; font-weight: 650; color: var(--accent-dark); background: #f6faf7; }
.scope-picker > summary::after, .extra > summary::after { content: ''; display: block; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); margin-right: 4px; flex: none; }
.scope-picker[open] > summary::after, .extra[open] > summary::after { transform: rotate(225deg) translate(-1px, -1px); }
#topic-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-body { border: 1px solid var(--line); border-radius: 9px; margin-top: 5px; padding: 10px; }
.scope-body > button { margin-top: 10px; }
.topics { display: grid; gap: 5px; }
.topic-group { border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.topic-group summary { padding: 8px 9px; font-size: .86rem; font-weight: 700; cursor: pointer; }
.topic-badges { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px 8px; }
.topic-check { position: relative; cursor: pointer; }
.topic-check span { display: block; border: 1px solid var(--control-border); border-radius: 6px; color: var(--muted); padding: 6px 8px; font-size: .84rem; }
.topic-check input:checked + span { background: var(--tint); border-color: #78aa8a; color: var(--accent-dark); font-weight: 700; }
.topic-check input:focus-visible + span, .dropzone:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.extras { margin-top: 14px; }
.extra { border-top: 1px solid var(--line); }
.extra > summary { display: flex; align-items: center; gap: 10px; color: #284739; cursor: pointer; padding: 11px 0; font-size: .88rem; font-weight: 730; }
.extra summary small { margin-left: auto; color: var(--muted); font-size: .78rem; font-weight: 500; text-align: right; }
.scope-picker > summary::-webkit-details-marker, .extra > summary::-webkit-details-marker { display: none; }
.extra-body { padding: 2px 0 12px; }
.dropzone { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px; background: #f6faf7; border: 1px dashed #a2c4ab; border-radius: 8px; color: var(--muted); font-size: .8rem; }
.dropzone.dragging { background: var(--tint); border-color: var(--accent); }
.dropzone .button { flex: none; }
.material-label { margin-top: 11px; }
.visually-hidden, .topic-check input { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.small-note { margin-top: 7px; color: var(--muted); font-size: .815rem; line-height: 1.5; white-space: pre-line; }
.small-note:empty { display: none; }
.counter { text-align: right; }
.form-actions { border-top: 1px solid var(--line); border-radius: 0 0 15px 15px; background: #f6faf7; padding: 15px 24px; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.action-card { background: #fff; color: var(--accent-dark); border: 1px solid #b5cebd; border-radius: 10px; padding: 13px 14px; text-align: left; cursor: pointer; }
.action-card strong, .action-card small { display: block; }
.action-card strong { font-size: .98rem; }
.action-card small { margin-top: 5px; font-size: .81rem; color: var(--muted); line-height: 1.4; }
.action-card:hover { background: var(--tint); }
.action-card.primary { background: var(--accent); border-color: var(--accent); color: white; }
.action-card.primary small { color: #e5f6eb; }
.action-card.primary:hover { background: var(--accent-dark); }
.action-card:disabled { cursor: wait; opacity: .7; }
.actions > [hidden] + .action-card { grid-column: 1 / -1; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 40px; padding: 8px 12px; border: 1px solid var(--control-border); border-radius: 8px; background: #fff; color: var(--accent-dark); font-size: .895rem; font-weight: 760; text-align: center; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--tint); border-color: #98bfa6; }
.button.compact { min-height: 34px; font-size: .82rem; padding: 6px 9px; }
.button:disabled { opacity: .65; cursor: wait; }
.progress { height: 4px; margin-top: 7px; border-radius: 999px; background: #dcebe0; overflow: hidden; }
.progress i { display: block; width: 35%; height: 100%; border-radius: 999px; background: var(--focus); animation: loading 1.4s ease-in-out infinite alternate; }
@keyframes loading { from { transform: translateX(-20%); } to { transform: translateX(205%); } }
.message { margin-top: 8px; padding: 8px 10px; border-radius: 7px; background: var(--tint); color: var(--accent-dark); font-size: .86rem; line-height: 1.5; }
.message.error { background: #fff0f3; color: #87233d; }
.output { margin-top: 15px; padding: 19px 23px; }
.output h2 { font-size: 1.23rem; font-weight: 810; letter-spacing: -.035em; }
.output-note { color: var(--muted); font-size: .86rem; line-height: 1.55; margin: 5px 0 10px; }
.import-panel { margin: 9px 0 23px; padding: 0 1px; }
.import-panel summary { padding: 8px 0; cursor: pointer; color: var(--muted); font-size: .86rem; font-weight: 700; }
.tabbar, .export-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tabbar { margin: 0 0 8px; }
.tabbar .active { background: var(--tint); border-color: #92b99f; }
.prompt-preview { min-height: 160px; max-height: 500px; font-family: ui-monospace, 'Malgun Gothic', monospace; }
.question-paper { border-radius: 8px; border: 1px solid var(--line); padding: 12px; overflow-wrap: anywhere; }
.question-paper h3 { font-size: 1.13rem; margin-bottom: 5px; }
.paper-meta { font-size: .82rem; color: var(--muted); margin-bottom: 9px; }
.question { border-top: 1px solid var(--line); padding-block: 9px; font-size: .91rem; line-height: 1.55; }
.question p { white-space: pre-wrap; margin-block: 4px; }
.question strong { display: block; }
.passage { padding: 7px; background: #f2f7f2; border-radius: 5px; }
.choices { margin: 5px 0; padding-left: 25px; }
.answer-line { display: block; border-bottom: 1px solid var(--control-border); height: 22px; }
@media (max-width: 820px) {
  .app-layout { display: block; }
  .sidebar { display: none; }
  .wrap { max-width: 730px; }
}
@media (max-width: 600px) {
  .wrap { padding: 19px 13px 22px; }
  .top-inner { height: auto; min-height: 53px; gap: 10px; padding: 7px 13px; }
  .brand { gap: 8px; font-size: 1rem; line-height: 1.2; }
  .intro { align-items: start; flex-direction: column; margin-bottom: 13px; }
  .intro .button { min-height: 34px; }
  .form-content, .form-actions, .output { padding-inline: 13px; }
  .form-content { padding-block: 15px 8px; }
  .action-card { padding: 11px 9px; }
  .two-fields, .counts { gap: 8px; }
  .extra summary small { font-size: .72rem; }
}
@media (max-width: 350px) {
  .header-links { gap: 3px 7px; }
  .header-link { font-size: .78rem; }
}
@media (prefers-reduced-motion: reduce) { .progress i { animation: none; } }
@page { size: A4; margin: 16mm; }
@media print {
  :root, body { background: #fff; color: #000; }
  .topbar, .sidebar, .intro, #settings, .import-panel, .output > :not(#result-view), .tabbar, .export-actions { display: none !important; }
  .app-layout, .wrap, .output, #result-view, .question-paper { display: block; padding: 0; margin: 0; max-width: none; min-height: 0; border: 0; box-shadow: none; }
  .question-paper h3 { font-size: 17pt; }
  .question { break-inside: avoid; font-size: 11pt; }
}
