:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --text: #1c2433;
  --muted: #5b6577;
  --line: #d9dfe8;
  --accent: #2456c9;
  --accent-text: #ffffff;
  --accent-soft: #e8eefc;
  --ok: #1d7a46;
  --ok-soft: #e4f4ea;
  --warn: #8a5a00;
  --warn-soft: #fbf1dc;
  --err: #b42318;
  --err-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d;
    --surface: #1b212b;
    --text: #e7ebf2;
    --muted: #a3acbb;
    --line: #313a48;
    --accent: #7ea2ff;
    --accent-text: #0d1322;
    --accent-soft: #233154;
    --ok: #6fd39a;
    --ok-soft: #173426;
    --warn: #f0c060;
    --warn-soft: #3a2e14;
    --err: #ff8a80;
    --err-soft: #3d1d1b;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--accent); }

h1, h2, h3 { line-height: 1.3; margin: 0 0 0.6em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.98rem; margin-top: 1em; }

.topbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 16px 8px;
}
.brand h1 { margin: 0; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; }

.badge {
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}
.badge[data-tone="ok"] { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge[data-tone="warn"] { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge[data-tone="err"] { background: var(--err-soft); color: var(--err); border-color: transparent; }

.tabs {
  display: flex;
  gap: 4px;
  max-width: 1040px;
  margin: 8px auto 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tabs [role="tab"] {
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.tabs [role="tab"][aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs [role="tab"]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

main { max-width: 1040px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
details.card > summary { cursor: pointer; font-weight: 700; }
details.card[open] > summary { margin-bottom: 12px; }

.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 4px 0 0; }

.field { margin-bottom: 14px; }
.field > label, fieldset legend { display: block; font-weight: 600; margin-bottom: 6px; }
.tag { font-size: 0.72rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); margin-left: 4px; vertical-align: middle; }
.tag.soft { background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 600; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
}
input[type="number"] { width: 7em; display: inline-block; padding: 4px 8px; }
textarea { resize: vertical; min-height: 4em; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, .dropzone:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input[type="file"] { font: inherit; max-width: 100%; }

.check { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; }
.check input { margin-top: 5px; }

fieldset.radios { border: 0; padding: 0; margin: 0 0 10px; }
fieldset.radios label { display: flex; gap: 8px; align-items: center; margin: 4px 0; flex-wrap: wrap; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.row.nowrap input { flex: 1; min-width: 0; }
.row.between { justify-content: space-between; }
.row > h2 { margin: 0; }

button {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.ghost { background: transparent; }
button.small { padding: 5px 11px; font-size: 0.86rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.status { margin: 10px 0 0; font-weight: 600; min-height: 1.2em; }
.status[data-tone="ok"] { color: var(--ok); }
.status[data-tone="warn"] { color: var(--warn); }
.status[data-tone="err"] { color: var(--err); }
.range { color: var(--muted); font-size: 0.86rem; }
.range[data-tone="err"] { color: var(--err); }

.steps { padding-left: 1.4em; margin: 0 0 12px; }
.steps li { margin: 4px 0; }
.notes { padding-left: 1.2em; margin: 8px 0 12px; color: var(--muted); font-size: 0.9rem; }
.notes li { margin: 3px 0; }
ul.plain { padding-left: 1.2em; margin: 0; }
ul.plain li { margin: 4px 0; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.table td input[type="text"] { padding: 4px 6px; min-width: 5em; }
.table .num { text-align: right; white-space: nowrap; }
.table tr.excluded td { opacity: 0.5; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill[data-tone="ok"] { background: var(--ok-soft); color: var(--ok); }
.pill[data-tone="warn"] { background: var(--warn-soft); color: var(--warn); }
.pill[data-tone="err"] { background: var(--err-soft); color: var(--err); }
.pill[data-tone="off"] { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  background: var(--bg);
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone p { margin: 4px 0; }
.linklike { color: var(--accent); text-decoration: underline; cursor: pointer; font-weight: 600; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.filelist { list-style: none; padding: 0; margin: 8px 0 0; font-size: 0.88rem; }
.filelist li { padding: 2px 0; color: var(--muted); }
.filelist li[data-tone="err"] { color: var(--err); }

progress { width: 100%; height: 10px; margin-top: 12px; accent-color: var(--accent); }

.actions-card { position: sticky; top: 0; z-index: 2; }

.results { display: grid; gap: 14px; }
.result { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.result header { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }
.result header h3 { margin: 0; }
.result .meta { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; font-size: 0.88rem; margin: 8px 0; }
.result .meta dt { color: var(--muted); }
.result .meta dd { margin: 0; }
.result textarea { min-height: 11em; }
.result .error-text { color: var(--err); font-weight: 600; }

.meter { margin: 6px 0 0; font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.meter[data-tone="ok"] { color: var(--ok); }
.meter[data-tone="warn"] { color: var(--warn); }
.meter[data-tone="err"] { color: var(--err); }

.issues { list-style: none; padding: 0; margin: 6px 0; font-size: 0.88rem; }
.issues li { padding: 4px 8px; border-radius: 6px; margin: 3px 0; }
.issues li[data-level="error"] { background: var(--err-soft); color: var(--err); }
.issues li[data-level="warn"] { background: var(--warn-soft); color: var(--warn); }
.issues li[data-level="ok"] { background: var(--ok-soft); color: var(--ok); }

.dup { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; font-size: 0.9rem; }
.dup ul { margin: 4px 0 0; padding-left: 1.2em; }

.guideline { white-space: pre-wrap; font-family: inherit; font-size: 0.85rem; max-height: 420px; overflow: auto; background: var(--bg); padding: 12px; border-radius: 8px; margin: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
@media (max-width: 720px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  .actions-card { position: static; }
}

.callout { background: var(--warn-soft); color: var(--text); border-radius: 8px; padding: 10px 12px; font-size: 0.9rem; margin: 0 0 12px; }
.table td input.guessed { border-color: var(--warn); background: var(--warn-soft); }
#studentTable { min-width: 680px; }
.dropzone .status { margin-top: 6px; }

.footer { max-width: 1040px; margin: 0 auto; padding: 8px 16px 32px; color: var(--muted); font-size: 0.85rem; }
.footer p { margin: 2px 0; }
