/* WordsApp — dictionary-inspired UI. Signature: Duden-yellow spine + bold
   serif headwords. System fonts only; must work with no network. */

:root {
  --yellow: #F5C400;
  --ink: #191919;
  --paper: #FCFBF8;
  --card: #FFFFFF;
  --muted: #71706B;
  --line: #E4E2DA;
  --danger: #B3261E;
  --again: #B3261E;
  --hard: #B26A00;
  --good: #2E6B30;
  --easy: #1A5CA8;
  --serif: Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ECEAE3;
    --paper: #161513;
    --card: #201F1C;
    --muted: #9A988F;
    --line: #35332E;
    --danger: #E46962;
    --again: #E46962;
    --hard: #E0A030;
    --good: #7CC47F;
    --easy: #7FB2E8;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
main { max-width: 760px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
a { color: inherit; }

/* --- top bar --- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 760px; margin: 0 auto; padding: 1rem;
  border-bottom: 3px solid var(--yellow);
}
.wordmark {
  font-family: var(--serif); font-weight: bold; font-size: 1.5rem;
  text-decoration: none; letter-spacing: -0.02em;
}
.wordmark span { color: var(--yellow); }
.wordmark.big { font-size: 2.4rem; margin: 0 0 0.25rem; }
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.topbar nav a { text-decoration: none; font-weight: 500; }
.topbar nav a:hover { text-decoration: underline; text-decoration-color: var(--yellow); text-decoration-thickness: 2px; }
.due-pill {
  background: var(--yellow); color: #191919; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; padding: 0.05rem 0.5rem; vertical-align: 2px;
}

/* --- card list as dictionary entries --- */
.searchbar input {
  width: 100%; padding: 0.6rem 0.8rem; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--ink);
}
.cardlist { list-style: none; margin: 1rem 0; padding: 0; }
.entry {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  border-left: 4px solid var(--yellow);
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.25rem 0.55rem 0.75rem;
}
.entry.archived { opacity: 0.45; border-left-color: var(--line); }
.entry-main { display: flex; gap: 0.75rem; align-items: baseline; text-decoration: none; min-width: 0; }
.headword { font-family: var(--serif); font-weight: bold; font-size: 1.15rem; white-space: nowrap; }
.entry-main:hover .headword { text-decoration: underline; text-decoration-color: var(--yellow); text-decoration-thickness: 3px; }
.gloss { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gloss p { display: inline; margin: 0; }
.gloss br { display: none; }
.entry-meta { display: flex; gap: 0.5rem; align-items: center; flex-shrink: 0; }
.tag {
  font-size: 0.75rem; text-decoration: none; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 0 0.5rem;
}
.tag:hover { border-color: var(--yellow); }
.srs { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
.srs-new { color: var(--easy); }
.srs-learning { color: var(--hard); }

/* --- editor --- */
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1.5rem; }
@media (max-width: 640px) { .editor { grid-template-columns: 1fr; } }
.editor-fields { display: flex; flex-direction: column; gap: 0.35rem; }
.editor-fields label { font-size: 0.85rem; font-weight: 600; margin-top: 0.6rem; }
.editor-fields input[type=text], .editor-fields input:not([type]), .editor-fields textarea {
  padding: 0.55rem 0.7rem; font-size: 1rem; font-family: inherit;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--ink);
}
.editor-fields textarea { resize: vertical; }
.check { font-weight: 400 !important; }
.editor-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
.preview-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

/* --- the card face (shared by preview and review) --- */
.card-face {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 10px solid var(--yellow);
  border-radius: 8px;
  padding: 1.5rem;
  min-height: 10rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-top: 0.4rem;
}
.card-front { font-family: var(--serif); font-weight: bold; font-size: 1.6rem; line-height: 1.25; }
.card-back { margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px dashed var(--line); }
.card-back p { margin: 0.2rem 0; }

/* --- review --- */
.review { display: flex; flex-direction: column; gap: 1.5rem; margin-top: 2rem; }
.flipcard { min-height: 14rem; font-size: 1.1rem; }
.flipcard .card-front { font-size: 2rem; }
.review-controls { display: flex; justify-content: center; }
.big-btn { padding: 0.8rem 2.5rem; font-size: 1.05rem; }
.ratings { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }
.rate { border-bottom-width: 3px; min-width: 6.2rem; }
.rate-again { border-bottom-color: var(--again); }
.rate-hard  { border-bottom-color: var(--hard); }
.rate-good  { border-bottom-color: var(--good); }
.rate-easy  { border-bottom-color: var(--easy); }
kbd {
  font-family: var(--mono); font-size: 0.7rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 0.3rem; margin-left: 0.3rem;
}
.review-done { text-align: center; padding: 2rem 0; }

/* --- buttons, misc --- */
.btn {
  display: inline-block; padding: 0.5rem 1.1rem; font-size: 0.95rem; font-weight: 600;
  color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 6px;
  text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--ink); }
.btn.primary, .btn-add { background: var(--yellow); color: #191919; border-color: var(--yellow); }
.btn.primary:hover, .btn-add:hover { filter: brightness(1.05); border-color: var(--yellow); }
.linklike {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--muted); text-decoration: underline; cursor: pointer;
}
.danger { color: var(--danger); }
.danger-zone { margin-top: 2.5rem; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; }
.empty { text-align: center; padding: 3rem 0; color: var(--muted); }
.foot {
  max-width: 760px; margin: 0 auto; padding: 1rem;
  display: flex; justify-content: space-between;
  color: var(--muted); font-size: 0.85rem;
  border-top: 1px solid var(--line);
}

/* --- login --- */
.login-body { display: grid; place-items: center; min-height: 100vh; margin: 0; }
.login-box { text-align: center; padding: 2rem; max-width: 22rem; }
.login-box form { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1.25rem; }
.login-box input {
  padding: 0.65rem 0.8rem; font-size: 1rem; text-align: center;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--ink);
}

:focus-visible { outline: 3px solid var(--yellow); outline-offset: 1px; }
@media (prefers-reduced-motion: no-preference) {
  .flipcard { transition: transform 0.15s ease; }
  .flipcard.flipping { transform: rotateX(8deg) scale(0.99); }
}
