/* 词卡 — warm paper aesthetic, dark-mode aware, zero dependencies. */
:root {
  --bg: #f6f1e7;
  --ink: #2b2620;
  --dim: #8a8071;
  --card: #fffdf7;
  --card-back: #b03a2e;
  --card-back-ink: #fff6ee;
  --edge: rgba(80, 60, 30, 0.14);
  --shadow: 0 2px 6px rgba(80, 60, 30, 0.10), 0 10px 24px rgba(80, 60, 30, 0.06);
  --accent: #b03a2e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191612;
    --ink: #ece5d8;
    --dim: #9c9184;
    --card: #241f19;
    --card-back: #8e2f25;
    --card-back-ink: #ffe9dd;
    --edge: rgba(255, 235, 200, 0.10);
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.35), 0 10px 24px rgba(0, 0, 0, 0.25);
    --accent: #e06a5a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', 'Noto Serif SC', 'Songti SC', serif;
  line-height: 1.5;
}
.zh { font-family: 'Noto Serif SC', 'Songti SC', 'SimSun', serif; }

.site-header {
  position: fixed; inset: 0 0 auto; z-index: 10;
  padding: 11px 20px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-bottom: 1px solid var(--edge);
  box-shadow: 0 4px 18px rgba(80, 60, 30, 0.06);
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: 1060px; min-height: 42px; margin: 0 auto;
  display: flex; align-items: baseline; justify-content: space-between; gap: 20px;
}
h1 { flex: none; font-size: 28px; line-height: 1.25; margin: 0; letter-spacing: 1px; }
h1 .latin { font-size: 18px; color: var(--dim); font-style: italic; margin-left: 4px; }
.tagline { color: var(--dim); font-size: 14px; margin: 0; text-align: right; }

main { max-width: 1060px; margin: 0 auto; padding: 82px 20px 60px; }
section { margin-top: 40px; }
section h2 {
  font-size: 20px; font-weight: 600; margin: 0 0 14px;
  border-bottom: 1px solid var(--edge); padding-bottom: 8px;
}
section h2 .zh { color: var(--accent); margin-right: 8px; }

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

.card {
  position: relative;
  aspect-ratio: 5 / 3;
  border: none; padding: 0; background: none;
  perspective: 700px;
  font: inherit; color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.card button { font: inherit; color: inherit; cursor: pointer; }
.card .face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: var(--card);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.card .back {
  transform: rotateY(180deg);
  background: var(--card-back);
  color: var(--card-back-ink);
  border-color: transparent;
}
.back-toggle {
  position: absolute; inset: 0; z-index: 0;
  border: 0; border-radius: inherit; background: transparent;
}
.card.flipped .front { transform: rotateY(180deg); }
.card.flipped .back { transform: rotateY(0); }
.card:hover .face { border-color: var(--accent); }

.hanzi {
  font-family: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
  font-size: 32px; line-height: 1.15; text-align: center;
}
.card.long .hanzi { font-size: 18px; }
.pinyin { font-size: 14px; font-style: italic; opacity: 0.95; text-align: center; }
.english { font-size: 12px; text-align: center; opacity: 0.9; }
.back .pinyin, .back .english { position: relative; z-index: 1; pointer-events: none; }

@media (max-width: 620px) {
  .site-header { padding: 9px 16px; }
  .header-inner { min-height: 48px; display: block; }
  h1 { font-size: 23px; }
  h1 .latin { font-size: 15px; }
  .tagline { margin-top: 1px; font-size: 11px; text-align: left; }
  main { padding-top: 80px; }
}

footer { text-align: center; color: var(--dim); padding: 20px 0 48px; }
.dim { color: var(--dim); }

/* ── sign-in modal ── */
dialog {
  border: 1px solid var(--edge); border-radius: 14px;
  background: var(--card); color: var(--ink);
  padding: 26px 28px; width: min(92vw, 360px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(20, 15, 8, 0.45); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 14px; font-size: 20px; }
dialog label { display: block; font-size: 14px; margin-bottom: 12px; color: var(--dim); }
dialog input[type="email"], dialog input[type="password"] {
  display: block; width: 100%; margin-top: 4px;
  padding: 9px 10px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--edge); border-radius: 8px;
}
dialog .remember { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
dialog .remember input { margin: 0; }
dialog .row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
dialog button {
  font: inherit; padding: 8px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--edge); background: var(--bg); color: var(--ink);
}
dialog button[type="submit"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.error { color: var(--accent); font-size: 14px; margin: 4px 0 8px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: rgba(20, 15, 8, 0.9); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; z-index: 50; pointer-events: none;
}

/* in-page app frame (address bar stays at /) */
#appframe { position: fixed; inset: 0; z-index: 1000; background: #fff; }
#appframe iframe { border: 0; width: 100%; height: 100%; display: block; }
body.framed { overflow: hidden; }
