:root {
  --bg: #ffffff;
  --ink: #111827;
  --muted: #4b5563;
  --subtle: #6b7280;
  --line: #e5e7eb;
  --line-strong: #111827;
  --accent: #1d4ed8;
  --ok: #15803d;
  --err: #b91c1c;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Sans KR', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 20px 88px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--subtle);
}

.nav-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--subtle);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

header {
  padding: 32px 0 26px;
  border-bottom: 1px solid var(--line-strong);
}

.kicker {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 10px;
}

h1 {
  font-family: 'Noto Serif KR', serif;
  font-size: clamp(25px, 4.5vw, 34px);
  line-height: 1.3;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}

.lead {
  font-size: 15px;
  color: var(--muted);
  margin: 0;
}

/* View Mode Switch */
.mode-bar {
  display: flex;
  gap: 0;
  margin-top: 24px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  width: fit-content;
}

.mode-btn {
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  padding: 9px 18px;
  cursor: pointer;
}

.mode-btn.active {
  background: var(--ink);
  color: #ffffff;
  font-weight: 600;
}

/* Date Cards */
.date-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  margin-top: 24px;
}

.date-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 22px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  min-height: 170px;
  transition: background-color 0.15s ease;
}

.date-card:hover {
  background: #fafafa;
}

.date-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
  display: block;
}

.date-title {
  font-family: 'Noto Serif KR', serif;
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 6px;
}

.date-range {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

.date-foot {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--subtle);
}

.date-foot strong {
  color: var(--ink);
  font-weight: 500;
}

/* Domain Sub-tabs */
.sub-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 24px 0 8px;
}

.btn-line {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
}

.btn-line:hover { border-color: var(--line-strong); }
.btn-line.active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

section {
  padding: 30px 0;
  border-bottom: 1px solid var(--line);
}

section:last-of-type { border-bottom: 0; }

h2 {
  font-family: 'Noto Serif KR', serif;
  font-size: 20px;
  margin: 0 0 14px;
  letter-spacing: -0.015em;
}

.h2-sub {
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: var(--subtle);
  margin-left: 8px;
}

h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 24px 0 10px;
}

.sec-intro {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 14px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.search-input {
  border: 1px solid var(--line);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  min-width: 180px;
}

.search-input:focus {
  outline: none;
  border-color: var(--ink);
}

table.simple-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.simple-table th,
table.simple-table td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.simple-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--subtle);
  border-bottom: 1px solid var(--line-strong);
}

.col-word { font-weight: 600; width: 150px; }
.col-mean { color: var(--muted); width: 210px; }

.speak-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0 4px;
  margin-left: 4px;
}

.meaning-cell.masked {
  color: transparent;
  background: #f3f4f6;
  cursor: pointer;
  user-select: none;
}

.meaning-cell.masked::after {
  content: "tap to show";
  color: #9ca3af;
  font-size: 11px;
}

/* Grammar */
.grammar-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.grammar-list li {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.grammar-list li:last-child { border-bottom: 0; }

.g-head { font-weight: 700; font-size: 16px; }
.g-meaning { color: var(--accent); font-weight: 500; font-size: 14px; margin-left: 6px; }
.g-desc { font-size: 14px; color: var(--muted); margin: 4px 0 6px; }
.g-ex {
  font-size: 14px;
  padding-left: 12px;
  border-left: 2px solid var(--line-strong);
  margin: 4px 0 0;
}

/* Talking */
.talk-list {
  margin: 0;
  padding-left: 20px;
}

.talk-list li {
  margin-bottom: 12px;
  font-size: 15px;
}

/* Practice */
.practice-group {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.practice-group:last-child { border-bottom: 0; }
.p-title { font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.p-row { margin-bottom: 12px; font-size: 15px; }

.p-select {
  font-family: inherit;
  font-size: 14px;
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  margin: 0 4px;
}

.p-input {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 14px;
}

.p-input:focus {
  outline: none;
  border-color: var(--ink);
}

.fb { font-size: 13px; margin-top: 4px; display: none; }
.fb.show { display: block; }
.fb.ok { color: var(--ok); }
.fb.err { color: var(--err); }
.fb.ans { color: var(--accent); }

.btn-primary {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  cursor: pointer;
  margin-top: 6px;
}

.note-box {
  padding: 20px;
  border: 1px solid var(--line-strong);
  background: #fafafa;
  font-size: 15px;
  line-height: 1.8;
}

footer {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--subtle);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 640px) {
  .container { padding: 18px 16px 64px; }
  .date-grid { grid-template-columns: 1fr; }
  .col-word { width: 110px; }
  .col-mean { width: auto; }
  table.simple-table thead { display: none; }
  table.simple-table tr {
    display: block;
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
  }
  table.simple-table td {
    border-bottom: 0;
    padding: 3px 6px;
  }
  table.simple-table td:nth-child(3) {
    display: block;
    width: 100%;
    color: var(--subtle);
    font-size: 13px;
  }
}

/* Interactive Flashcard & Quiz UI */
.flashcard-wrap {
  border: 1px solid var(--line-strong);
  padding: 28px 24px;
  margin: 16px 0 24px;
  background: #ffffff;
}

.fc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--subtle);
  margin-bottom: 18px;
  gap: 10px;
  flex-wrap: wrap;
}

.fc-card {
  border: 1px solid var(--line);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: background-color 0.15s ease;
}

.fc-card:hover {
  background: #fafafa;
}

.fc-word {
  font-family: 'Noto Serif KR', serif;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.fc-hint {
  font-size: 12px;
  color: var(--subtle);
}

.fc-back {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  width: 100%;
  max-width: 520px;
}

.fc-meaning {
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}

.fc-note {
  font-size: 14px;
  color: var(--muted);
}

.fc-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  gap: 8px;
  flex-wrap: wrap;
}

.fc-judge {
  display: flex;
  gap: 8px;
}

.btn-ok {
  border: 1px solid var(--ok);
  background: #ffffff;
  color: var(--ok);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
}

.btn-ok:hover { background: #f0fdf4; }

.btn-again {
  border: 1px solid var(--err);
  background: #ffffff;
  color: var(--err);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
}

.btn-again:hover { background: #fef2f2; }

/* Mini MCQ Quiz */
.mcq-box {
  border-top: 1px solid var(--line-strong);
  padding-top: 22px;
  margin-top: 24px;
}

.mcq-q {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.mcq-opts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.mcq-opt {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
}

.mcq-opt:hover { border-color: var(--ink); }
.mcq-opt.correct { border-color: var(--ok); background: #f0fdf4; color: var(--ok); font-weight: 600; }
.mcq-opt.wrong { border-color: var(--err); background: #fef2f2; color: var(--err); }

.talk-memo {
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 54px;
}

.talk-memo:focus {
  outline: none;
  border-color: var(--ink);
}

@media (max-width: 600px) {
  .mcq-opts { grid-template-columns: 1fr; }
}
