:root {
  --bg: #f7f7fb;
  --text: #1a1a2e;
  --border: #d0d0e0;
  --code-bg: rgba(0, 0, 0, 0.06);
  --row-alt: rgba(0, 0, 0, 0.04);
  --section-bg: rgba(0, 0, 0, 0.03);
  --tab-active-bg: #1a1a2e;
  --tab-active-color: #fff;
  --muted: #666;
  --radius: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', ui-monospace, monospace;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  padding: 0 1rem;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

/* Header */
.site-header {
  text-align: center;
  margin-bottom: 2rem;
}

.site-header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.site-header h1 a {
  color: inherit;
  text-decoration: none;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
}

/* Tabs */
.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin-bottom: 2rem;
}

.tab-btn {
  display: inline-block;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.12s;
}

.tab-btn:hover {
  border-color: #888;
}

.tab-btn.active {
  background: var(--tab-active-bg);
  color: var(--tab-active-color);
  border-color: var(--tab-active-bg);
  font-weight: 700;
}

/* Sections */
.sec {
  margin-bottom: 1.5rem;
}

.sec h2 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.sec p {
  margin-bottom: 0.5rem;
}

.intro {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 1rem;
}
.word-count {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.6;
  margin-bottom: 0.75rem;
}

/* Code */
code {
  background: var(--code-bg);
  padding: 0.1em 0.45em;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.92em;
}

.code-block {
  background: var(--code-bg);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 0.75rem;
}

/* Grid rows (replaces tables for uniform layouts) */
.grid-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.grid-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: var(--section-bg);
  font-size: 13px;
}

.grid-row.alt {
  background: var(--row-alt);
}

/* Sound rows */
.sound-row {
  display: grid;
  grid-template-columns: 40px 60px 1fr;
}

.sound-row.highlight-warn {
  background: rgba(232, 93, 117, 0.06);
}

.big-letter {
  font-size: 20px;
  font-weight: 800;
  min-width: 28px;
}

.big-letter.vowel { color: #6bc4a6; }
.big-letter.cons  { color: #6b7fd4; }
.big-letter.warn  { color: #e85d75; }

.ipa {
  color: var(--muted);
  font-size: 12px;
}

.note {
  font-size: 11px;
  font-style: italic;
  color: var(--muted);
}

.note.warn {
  font-style: normal;
  color: #e85d75;
}

/* Pron rows */
.pron-row {
  display: grid;
  grid-template-columns: 60px 80px 1fr;
}

/* Scale rows */
.scale-row {
  display: grid;
  grid-template-columns: 48px 28px 1fr;
}

.scale-val {
  font-weight: 600;
  color: var(--muted);
  font-size: 13px;
}

/* Domain rows */
.domain-cat {
  margin-bottom: 1.25rem;
}

.cat-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.domain-row {
  display: grid;
  grid-template-columns: 48px 110px 1fr 1fr;
  cursor: default;
  transition: background 0.1s;
  background: transparent;
}

.domain-axis {
  font-weight: 600;
  font-size: 13px;
}

/* Structure */
.struct-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 1.5rem;
}

.struct-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

.struct-card .big-letter {
  color: var(--text);
  min-width: 32px;
}

/* Vocabulary */
.lang-switch {
  display: flex;
  gap: 3px;
  justify-content: flex-end;
  margin-bottom: 6px;
}

.lang-btn {
  padding: 3px 8px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.1s;
}

.lang-btn:hover { border-color: #888; color: var(--text); }

.lang-btn.active {
  background: #1a1a2e;
  color: #fff;
  border-color: #1a1a2e;
}

.vocab-search {
  width: 100%;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  margin-bottom: 10px;
}

.vocab-search:focus {
  outline: none;
  border-color: #888;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 1.25rem;
}

.filter-btn {
  padding: 5px 12px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 400;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-transform: capitalize;
  transition: all 0.1s;
}

.filter-btn:hover { border-color: #888; }

.filter-btn.active {
  background: #1a1a2e;
  color: #fff;
  border-color: #1a1a2e;
  font-weight: 700;
}

.filter-settled.active {
  background: #4a9e6b;
  border-color: #4a9e6b;
}

.vocab-entry {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
}
.vocab-entry.alt { background: var(--row-alt); }

.vocab-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.morpheme-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border: 1px solid;
  border-radius: 3px;
  white-space: nowrap;
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
  transition: opacity 0.1s;
}
#vocab-list .morpheme-tag:hover {
  opacity: 0.65;
}
@keyframes nav-flash {
  0%   { box-shadow: 0 0 0 3px #f0c040; }
  100% { box-shadow: none; }
}
.nav-highlight {
  animation: nav-flash 1.4s ease-out;
}

.morpheme-label {
  font-weight: 400;
  font-size: 10px;
}

.morpheme-sub {
  width: 100%;
  margin-top: 3px;
  opacity: 0.7;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.settled-badge {
  font-size: 10px;
  color: #4a9e6b;
  font-weight: 400;
}

.settled-btn {
  padding: 3px 9px;
  font-family: inherit;
  font-size: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.1s;
  flex-shrink: 0;
}

.settled-btn:hover { border-color: #888; }

.settled-btn.active {
  background: #4a9e6b;
  color: #fff;
  border-color: #4a9e6b;
}

/* Edit mode: 3-column vocab entries */
#vocab-list.edit-mode .vocab-entry {
  grid-template-columns: 1fr 1fr auto auto;
}
.vocab-del-btn {
  padding: 1px 6px;
  font-size: 13px;
  border: 1px solid #c44;
  border-radius: 3px;
  background: none;
  color: #c44;
  cursor: pointer;
  line-height: 1;
}
.vocab-del-btn:hover { background: #c44; color: #fff; }

.cat-header-btns {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.vocab-add-btn {
  padding: 3px 9px;
  font-family: inherit;
  font-size: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.1s;
}

.vocab-add-btn:hover {
  border-color: #888;
  color: var(--text);
}

.vocab-edit-btn {
  padding: 2px 7px;
  font-family: inherit;
  font-size: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.1s;
  white-space: nowrap;
}

.vocab-edit-btn:hover {
  border-color: #888;
  color: var(--text);
}

/* Inline vocabulary editor */
.vocab-entry.ve-editing,
.vocab-entry.ve-add-row {
  align-items: start;
}

.ve-en-input,
.ve-dupi-input {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
}

.ve-en-input:focus,
.ve-dupi-input:focus {
  outline: none;
  border-color: #888;
}

.ve-add-col1 {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ve-morphemes-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-height: 1rem;
}

.ve-inline-actions {
  display: flex;
  gap: 4px;
  align-items: flex-start;
  padding-top: 2px;
}

.ve-save-btn {
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border: 1px solid var(--text);
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
  white-space: nowrap;
}

.ve-save-btn:hover { opacity: 0.8; }

.ve-cancel-btn {
  font-family: inherit;
  font-size: 13px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.ve-cancel-btn:hover { color: var(--text); border-color: #888; }

/* Examples table */
.ex-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 0.5rem;
}

.ex-table td {
  padding: 5px 8px;
  vertical-align: top;
}

.ex-table tr:nth-child(even) td {
  background: var(--row-alt);
}

.ex-table tr:hover td {
  background: rgba(0,0,0,0.06);
}

/* Shared */
.mono-bold { font-weight: 700; }
.muted { color: var(--muted); font-size: 12px; }

/* Playground */
.pg-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.pg-cat {
  margin-bottom: 10px;
}

.pg-cat-name {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.pg-domain-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.pg-domain-btn {
  padding: 3px 9px;
  font-family: inherit;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all 0.1s;
}

.pg-domain-btn:hover { border-color: #888; }
.pg-struct-btn { text-transform: none; }

.pg-domain-btn b { font-weight: 700; }
.pg-domain-btn span { font-size: 10px; color: var(--muted); margin-left: 3px; }

.pg-domain-info {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  margin: 1rem 0 0.5rem;
}

.pg-slider {
  width: 100%;
  margin-bottom: 4px;
}

.pg-scale-ends {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 1rem;
}

.pg-result {
  text-align: center;
  padding: 1.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.pg-word {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.pg-meaning {
  font-size: 14px;
  margin-bottom: 4px;
}

.pg-note {
  font-size: 12px;
  color: var(--muted);
}

.pg-axis-row {
  display: grid;
  grid-template-columns: 70px 1fr 160px;
  align-items: center;
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12px;
  gap: 8px;
  transition: background 0.08s;
}

.pg-axis-row:hover { background: var(--row-alt); }

.pg-axis-syl { font-weight: 700; font-size: 13px; }

.pg-axis-bar-wrap {
  height: 5px;
  border-radius: 3px;
  background: rgba(0,0,0,0.08);
  overflow: hidden;
}

.pg-axis-bar {
  height: 100%;
  border-radius: 3px;
  transition: opacity 0.08s;
}

.pg-axis-level {
  text-align: right;
  color: var(--muted);
  font-size: 11px;
}

/* Text reader */
.text-para {
  margin-bottom: 1.5rem;
}

.text-du-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: baseline;
  margin-top: 4px;
}

.du-word {
  display: inline-block;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  user-select: text;
  transition: all 0.1s;
}

.du-word:hover {
  border-color: var(--border);
  background: var(--section-bg);
}

.du-word.active {
  border-color: var(--text);
  background: var(--row-alt);
}

.du-detail {
  margin-top: 6px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--section-bg);
  margin-bottom: 0.5rem;
}

.du-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.du-detail-word {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.du-detail-close {
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
}

.du-detail-close:hover { color: var(--text); }

.du-detail-morphemes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.du-detail-entry {
  font-size: 13px;
  margin-bottom: 6px;
}

.du-detail-alts {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px;
}


/* ---- Learning tool ---- */

.learn-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.learn-logo {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.learn-logo a {
  color: var(--text);
  text-decoration: none;
}

.learn-title {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.4rem;
}

.learn-subtitle {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2rem;
}

.learn-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  font-size: 12px;
}

.learn-nav a {
  color: var(--text);
  text-decoration: none;
}

.learn-nav a:hover { text-decoration: underline; }

/* Welcome */
.learn-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  background: var(--section-bg);
  text-align: center;
  margin-top: 1.5rem;
}

.learn-card-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.learn-url {
  font-size: 13px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 0.75rem 0;
  word-break: break-all;
  text-align: left;
}

.learn-bookmark-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

/* Shared button */
.btn-primary {
  display: inline-block;
  padding: 10px 24px;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.12s;
}

.btn-primary:hover { opacity: 0.8; }
.btn-primary:disabled { opacity: 0.4; cursor: default; }

/* Completion banner */
.completion-banner {
  background: rgba(26, 110, 64, 0.1);
  border: 1px solid rgba(26, 110, 64, 0.35);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  margin-bottom: 1.5rem;
  color: #1a6e40;
}

/* Picker tabs */
.picker-tabs {
  margin-bottom: 1.25rem;
}

.picker-tab-panel {
  display: none;
}

.picker-tab-panel.active {
  display: block;
}

/* Picker */
.picker-section {
  margin-bottom: 1.75rem;
}

.picker-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.wordset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
}

.wordset-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.1s;
}

.wordset-btn:hover { border-color: #888; background: var(--row-alt); }

.wordset-btn.active {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

.wordset-btn.active .wordset-mini-fill { background: rgba(255,255,255,0.5) !important; }

.wordset-btn.just-completed {
  border-color: #1a6e40;
}

.wordset-btn-label {
  font-weight: 600;
  margin-bottom: 3px;
}

.wordset-btn-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  opacity: 0.7;
  margin-bottom: 4px;
}

.wordset-mini-bar {
  height: 3px;
  border-radius: 2px;
  background: rgba(0,0,0,0.12);
  overflow: hidden;
}

.wordset-mini-fill {
  height: 100%;
  background: #1a6e40;
  border-radius: 2px;
  transition: width 0.3s;
}

.picker-controls {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.picker-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.picker-row-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  min-width: 110px;
}

.picker-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.type-btn, .pick-lang-btn {
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all 0.1s;
}

.type-btn:hover, .pick-lang-btn:hover { border-color: #888; }

.type-btn.active, .pick-lang-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
  font-weight: 600;
}

.picker-start { text-align: center; }

/* Exercise */
.lx-progress-wrap {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.lx-progress-fill {
  height: 100%;
  background: #1a6e40;
  border-radius: 4px;
  transition: width 0.4s;
}

.lx-progress-label {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  margin-bottom: 1.5rem;
}

.lx-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  background: var(--section-bg);
}

.lx-question {
  text-align: center;
  margin-bottom: 1.5rem;
}

.lx-dupi-raw {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.lx-lang-display {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.lx-prompt {
  font-size: 12px;
  color: var(--muted);
  margin-top: 0.5rem;
}

.lx-meta {
  font-size: 11px;
  color: var(--muted);
}

.lx-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lx-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.1s;
}

.lx-option:hover:not(:disabled) { border-color: #888; background: var(--row-alt); }
.lx-option:disabled { cursor: default; }

.lx-option.correct {
  border-color: #1a6e40;
  background: rgba(26, 110, 64, 0.08);
  color: #1a6e40;
  font-weight: 600;
}

.lx-option.wrong {
  border-color: #b81a30;
  background: rgba(184, 26, 48, 0.08);
  color: #b81a30;
}

.lx-result {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.lx-result-msg {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.lx-result-msg.correct { color: #1a6e40; }
.lx-result-msg.wrong { color: #b81a30; }

.lx-result-answer {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.lx-morpheme-reveal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin-bottom: 1rem;
  font-size: 1rem;
}

/* Crossword */
.cw-wrapper {
  max-width: 700px;
  margin: 0 auto;
}

.cw-hint {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 1rem;
}

.cw-grid {
  display: grid;
  gap: 0;
  grid-template-columns: repeat(var(--cols), 56px);
  margin-bottom: 1.5rem;
  justify-content: center;
}

.cw-cell {
  width: 56px;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1px solid var(--border);
}

.cw-empty {
  background: #1a1a2e;
  border-color: #1a1a2e;
}

.cw-letter {
  background: #fff;
}

.cw-input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-family: inherit;
  font-size: 22px;
  font-weight: 700;
  text-transform: lowercase;
  padding: 0;
  outline: none;
}

.cw-input:focus {
  background: rgba(26, 110, 64, 0.12);
  box-shadow: inset 0 0 0 2px #1a6e40;
}

.cw-correct {
  background: rgba(26, 110, 64, 0.18) !important;
  color: #1a6e40;
}

.cw-wrong {
  background: rgba(184, 26, 48, 0.12) !important;
  color: #b81a30;
}

.cw-highlight {
  background: rgba(240, 192, 64, 0.25) !important;
  box-shadow: inset 0 0 0 1px #d4a017;
}

.cw-clue {
  background: var(--section-bg);
  border: 1px solid var(--border);
  padding: 1px 2px;
  gap: 0;
}

.cw-clue-up,
.cw-clue-mid,
.cw-clue-down {
  width: 100%;
  text-align: center;
  line-height: 1.1;
  word-break: break-word;
  hyphens: auto;
}

.cw-clue-up {
  font-size: 8px;
  font-weight: 700;
  color: var(--text);
}

.cw-clue-mid {
  font-size: 8px;
  font-weight: 700;
  color: var(--text);
}

.cw-clue-down {
  font-size: 8px;
  font-weight: 700;
  color: var(--text);
}

.cw-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.cw-result {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  min-height: 1.5em;
}

/* Chapter navigation */
.chapter-nav-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.chapter-nav-btn {
  padding: 0.3rem 0.6rem;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 4px;
}
.chapter-nav-btn:disabled { opacity: 0.3; cursor: default; }
.chapter-nav-btn:not(:disabled):hover { background: var(--tab-active-bg); color: #fff; border-color: var(--tab-active-bg); }
.chapter-select {
  padding: 0.3rem 0.5rem;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 4px;
  flex: 1;
  max-width: 400px;
}
.chapter-info {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* Text edit button */
.text-edit-btn {
  margin-top: 0.3rem;
  padding: 0.15rem 0.5rem;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 3px;
}
.text-edit-btn:hover { color: var(--tab-active-bg); border-color: var(--tab-active-bg); }

/* Text editor inline */
.te-editor {
  margin-top: 0.5rem;
}
.te-textarea {
  width: 100%;
  padding: 0.5rem;
  font-size: 14px;
  border: 1px solid var(--tab-active-bg);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  min-height: 60px;
}
.te-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.3rem;
}
.te-save-btn, .te-cancel-btn {
  padding: 0.2rem 0.6rem;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 3px;
}
.te-save-btn { background: var(--tab-active-bg); color: #fff; border-color: var(--tab-active-bg); }
.te-cancel-btn { background: var(--bg); color: var(--text); }

/* Unknown dupi word (no vocab match) */
.du-word.du-unknown {
  opacity: 0.65;
  border-style: dashed;
}

/* Clickable English words in edit mode */
.en-word {
  cursor: pointer;
  border-bottom: 1px dashed var(--muted);
  transition: background 0.15s;
}
.en-word:hover {
  background: var(--tab-active-bg);
  color: #fff;
  border-color: var(--tab-active-bg);
}

/* English word → add translation form */
.ew-form {
  margin: 0.8rem 0;
  padding: 0.8rem;
  border: 1px solid var(--tab-active-bg);
  border-radius: var(--radius);
  background: var(--bg);
}
.ew-form-header {
  font-size: 13px;
  margin-bottom: 0.6rem;
  color: var(--muted);
}
.ew-form-header b { color: var(--text); }
.ew-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.ew-row label {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.ew-row input, .ew-row select {
  padding: 0.2rem 0.4rem;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}
.ew-dupi-input { width: 160px; }
.ew-lang-input { width: 140px; }
.ew-cat-select { width: 200px; }
.ew-morphemes-preview {
  font-size: 12px;
  padding: 0.2rem 0;
  min-height: 1.2em;
}
.ew-search-area {
  margin-top: 0.5rem;
  position: relative;
}
.ew-search-input {
  width: 100%;
  padding: 0.25rem 0.4rem;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}
.ew-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: none;
}
.ew-sr-item {
  padding: 0.25rem 0.5rem;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--section-bg);
}
.ew-sr-item:hover { background: var(--section-bg); }
.ew-sr-item code { font-weight: 700; }
.ew-sr-lang { font-size: 10px; color: var(--muted); }
.ew-sr-cat { font-size: 10px; color: var(--muted); }
.ew-sr-empty { padding: 0.25rem 0.5rem; font-size: 12px; color: var(--muted); }
.ew-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.ew-save-btn, .ew-cancel-btn {
  padding: 0.25rem 0.7rem;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
}
.ew-save-btn { background: var(--tab-active-bg); color: #fff; border: 1px solid var(--tab-active-bg); }
.ew-cancel-btn { background: var(--bg); color: var(--text); border: 1px solid var(--border); }

/* Double-domains table */
.dd-table-wrap { overflow-x: auto; }
.dd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.dd-table th {
  text-align: left;
  padding: 0.3rem 0.5rem;
  border-bottom: 2px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.dd-table td {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--section-bg);
  vertical-align: baseline;
}
.dd-table code { font-size: 14px; }
.dd-syl { font-weight: 700; }

/* Word Order exercise */
.wo-en-sentence {
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  margin-top: 0.5rem;
}

.wo-construction {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 48px;
  padding: 0.8rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  margin: 1rem 0;
  align-items: center;
  justify-content: center;
}

.wo-construction-placeholder {
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}

.wo-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 1rem;
}

.wo-chip {
  padding: 0.4rem 0.8rem;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.wo-chip:hover:not(:disabled) {
  border-color: #888;
  background: var(--row-alt);
}

.wo-bank-chip.used {
  opacity: 0.3;
  pointer-events: none;
}

.wo-const-chip {
  background: var(--tab-active-bg);
  color: #fff;
  border-color: var(--tab-active-bg);
}

.wo-const-chip:hover:not(:disabled) {
  opacity: 0.8;
}

.wo-const-chip:disabled {
  cursor: default;
}

.wo-chip:disabled {
  cursor: default;
  opacity: 0.6;
}

.wo-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.wo-needed-hint {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

/* Conversation exercise */
.cv-dialogue {
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--bg2);
  border-radius: 8px;
}

.cv-line {
  margin-bottom: 0.6rem;
  line-height: 1.6;
}

.cv-line:last-child {
  margin-bottom: 0;
}

.cv-speaker {
  font-weight: 700;
  margin-right: 0.4rem;
  color: var(--accent);
}

.cv-speaker-b .cv-speaker {
  color: #b07020;
}

.cv-dupi-morph {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1px;
}

.cv-meaning-hint {
  font-size: 0.8em;
  color: var(--muted);
  margin-left: 0.4rem;
  font-style: italic;
}

.cv-meaning-target {
  text-align: center;
  margin-bottom: 0.8rem;
  color: var(--muted);
}

.cv-meaning-target strong {
  color: var(--text);
  font-family: monospace;
  font-size: 1.05em;
  background: var(--bg2);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 0.3rem;
}

.cv-construction {
  display: inline-flex;
  min-height: 2em;
  min-width: 6em;
  vertical-align: middle;
}

.cv-hint-box {
  margin: 0.5rem 0 1rem;
  padding: 0.7rem 1rem;
  background: #10707015;
  border: 1px solid #10707040;
  border-radius: 6px;
  font-size: 0.9em;
  color: var(--text);
}

.cv-hint-box p {
  margin: 0;
}

/* Conversation mobile */
@media (max-width: 560px) {
  .cv-dialogue {
    padding: 0.6rem;
    font-size: 0.9em;
  }
}

@media (max-width: 700px) {
  .cw-grid {
    grid-template-columns: repeat(var(--cols), 38px);
  }
  .cw-cell {
    width: 38px;
    height: 38px;
  }
  .cw-input {
    font-size: 16px;
  }
  .cw-clue-up,
  .cw-clue-mid,
  .cw-clue-down { font-size: 7px; }
}

/* Existing responsive at the end */
@media (max-width: 560px) {
  .domain-row { grid-template-columns: 40px 90px 1fr; }
  .domain-row .muted:last-child { display: none; }
  .pg-axis-row { grid-template-columns: 60px 1fr; }
  .pg-axis-level { display: none; }
  .ex-table td:last-child { display: none; }
}

/* Statistics page */
.stat-table { width: 100%; border-collapse: collapse; }
.stat-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.stat-table td:first-child { font-weight: 600; white-space: nowrap; width: 1%; }
.stat-table td:nth-child(2) { white-space: nowrap; width: 1%; }
.stat-table td:last-child { font-size: 12px; color: var(--muted); }
.stat-table tr:last-child td { border-bottom: none; }
.stat-table tr:last-child td:first-child,
.stat-table tr:last-child td:nth-child(2) { font-size: 16px; border-top: 2px solid var(--text); }
.stat-value { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 18px; text-align: right; padding-right: 16px; }
.stat-link { color: inherit; text-decoration: none; border-bottom: 1px dashed var(--border); }
.stat-link:hover { border-bottom-color: var(--text); }

/* Scale page */
.scale-page-table { margin: 0.5rem 0 1rem; display: flex; flex-direction: column; gap: 2px; }
.scale-page-table .scale-row { align-items: center; padding: 6px 8px; border-radius: var(--radius); }
.scale-page-table .scale-row:nth-child(even) { background: var(--row-alt); }
.scale-page-table .scale-num { font-weight: 700; font-size: 18px; color: var(--muted); text-align: right; padding-right: 8px; }
.scale-page-table code { font-size: 16px; font-weight: 700; }

.scale-double-table { margin: 0.5rem 0 1rem; display: flex; flex-direction: column; gap: 2px; }
.scale-double-table .scale-row { grid-template-columns: 100px 1fr; align-items: center; padding: 6px 8px; border-radius: var(--radius); }
.scale-double-table .scale-row:nth-child(even) { background: var(--row-alt); }
.scale-double-word { font-size: 16px; font-weight: 700; }

/* Chapter stats */
.chapter-stats { font-size: 13px; color: var(--muted); margin-top: 1.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
