/* ============================================================
   Inkwell · unified design system
   "Midnight ink" palette: deep blue-violet, warm cream highlights.
   This file is loaded by every page (home, library, practice, profile, …).
   ============================================================ */

:root {
  /* surfaces */
  --bg-0:        #0e1018;   /* page bg */
  --bg-1:        #15182280; /* card bg, semi-transparent over gradient */
  --bg-1-solid:  #161a26;
  --bg-2:        #1c2030;
  --bg-3:        #232838;
  --rule:        #2a2f42;
  --rule-soft:   #1e2230;

  /* ink */
  --ink-1:       #f3f0e8;   /* headline, paper-cream tint */
  --ink-2:       #d6d3cb;
  --ink-3:       #9ea2b3;
  --ink-4:       #6b6f82;
  --ink-faint:   #444859;

  /* accents */
  --acc-1:       #b9a8ff;   /* lavender */
  --acc-2:       #8a7bff;   /* deeper lavender */
  --acc-3:       #4d6bff;   /* electric blue */
  --gold:        #ecc15c;   /* warm gold for combos / highlights */
  --gold-soft:   #f4d790;
  --ok:          #6fd39b;
  --ok-soft:     #a4e6c1;
  --bad:         #ff7b7b;
  --bad-soft:    #ffabab;

  /* shadows */
  --sh-sm: 0 1px 2px rgba(0,0,0,0.25), 0 1px 3px rgba(0,0,0,0.3);
  --sh-md: 0 6px 18px rgba(0,0,0,0.32), 0 2px 6px rgba(0,0,0,0.25);
  --sh-lg: 0 20px 50px rgba(0,0,0,0.45), 0 6px 16px rgba(0,0,0,0.3);
  --sh-glow: 0 0 0 1px rgba(185,168,255,0.18), 0 0 24px rgba(138,123,255,0.18);

  /* radii */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 18px;
  --r-xl: 24px;

  /* fonts */
  --serif: "Fraunces", "Newsreader", "Source Serif Pro", "Source Han Serif SC", "Noto Serif SC", ui-serif, Georgia, serif;
  --sans:  "Inter", "Source Han Sans SC", "Noto Sans SC", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:  "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --maxw: 1180px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; color-scheme: dark; }

body {
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink-2);
  background:
    radial-gradient(ellipse 60% 35% at 18% -10%, rgba(138,123,255,0.18), transparent 60%),
    radial-gradient(ellipse 45% 30% at 90% 100%, rgba(77,107,255,0.12), transparent 60%),
    radial-gradient(ellipse 30% 25% at 80% 20%, rgba(236,193,92,0.06), transparent 60%),
    var(--bg-0);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--acc-2); color: #fff; }
:focus-visible { outline: 2px solid var(--acc-1); outline-offset: 2px; border-radius: 3px; }

/* typography */
h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--ink-1);
  font-weight: 500;
  letter-spacing: -0.012em;
  margin: 0 0 0.4em;
}
h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); line-height: 1.08; }
h2 { font-size: clamp(1.5rem, 2.8vw, 2rem); line-height: 1.2; }
h3 { font-size: 1.15rem; }
p  { margin: 0 0 0.85em; color: var(--ink-3); }
small, .small { font-size: 0.85rem; color: var(--ink-3); }
a {
  color: var(--acc-1);
  text-decoration: none;
  transition: color 0.15s;
}
a:hover { color: var(--ink-1); }

code, kbd {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.08em 0.42em;
}
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4rem 0; }

/* layout */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem;
}
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.grid { display: grid; gap: 1.1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 880px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---- top header (shared) ---- */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(1.4) blur(14px);
  background: rgba(14,16,24,0.65);
  border-bottom: 1px solid var(--rule-soft);
}
.top-bar .container {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-1);
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 500;
}
.brand:hover { color: var(--ink-1); }
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--acc-1), var(--acc-3));
  color: #0e1018;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: 700; font-size: 1rem;
  box-shadow: var(--sh-sm);
}
.brand small {
  color: var(--ink-4);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--sans);
}
.nav-main {
  display: flex;
  gap: 1.4rem;
  margin-left: 1.2rem;
}
.nav-main a {
  color: var(--ink-3);
  font-size: 0.93rem;
  padding: 0.3rem 0;
  border-bottom: 1.5px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-main a:hover, .nav-main a.active {
  color: var(--ink-1);
  border-bottom-color: var(--acc-1);
}
@media (max-width: 720px) {
  .nav-main { display: none; }
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.7rem 1.15rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--rule);
  background: var(--bg-2);
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.06s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); border-color: var(--ink-faint); color: var(--ink-1); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--acc-2), var(--acc-3));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 0 1px rgba(185,168,255,0.3), 0 6px 18px rgba(77,107,255,0.25);
}
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.ghost {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink-3);
}
.btn.ghost:hover { background: var(--bg-2); color: var(--ink-1); }
.btn.gold {
  background: linear-gradient(135deg, var(--gold), #d39830);
  color: #1a1610;
  border-color: transparent;
}
.btn.small  { padding: 0.4rem 0.8rem;  font-size: 0.85rem; }
.btn.large  { padding: 0.95rem 1.7rem; font-size: 1.04rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* card */
.card {
  background: var(--bg-1-solid);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r);
  padding: 1.4rem 1.3rem;
  box-shadow: var(--sh-sm);
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.card.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
  border-color: var(--rule);
}
.card h3 { color: var(--ink-1); }

/* tag */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  background: var(--bg-2);
  border: 1px solid var(--rule-soft);
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
}
.tag.acc  { color: var(--acc-1);  border-color: rgba(185,168,255,0.3); background: rgba(138,123,255,0.08); }
.tag.gold { color: var(--gold);   border-color: rgba(236,193,92,0.3);   background: rgba(236,193,92,0.08); }
.tag.ok   { color: var(--ok);     border-color: rgba(111,211,155,0.3);  background: rgba(111,211,155,0.08); }
.tag.bad  { color: var(--bad);    border-color: rgba(255,123,123,0.3);  background: rgba(255,123,123,0.08); }

/* input */
input[type="text"], input[type="password"], input[type="email"], input[type="search"], textarea, select {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink-1);
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 0.7rem 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--acc-1);
  box-shadow: 0 0 0 3px rgba(185,168,255,0.15);
}
::placeholder { color: var(--ink-4); }

/* footer */
.site-foot {
  margin-top: 4rem;
  padding: 2rem 0 2.6rem;
  border-top: 1px solid var(--rule-soft);
  color: var(--ink-4);
  font-size: 0.86rem;
}
.site-foot .container { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: baseline; justify-content: space-between; }
.site-foot a { color: var(--ink-3); }
.site-foot a:hover { color: var(--ink-1); }
.site-foot .col { display: flex; flex-direction: column; gap: 0.3rem; }

/* utility */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.center { text-align: center; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2.5rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2.5rem; }

/* skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-2), var(--bg-3), var(--bg-2));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
  min-height: 1em;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  background: var(--bg-3);
  color: var(--ink-1);
  padding: 0.7rem 1.1rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--rule);
  font-size: 0.9rem;
  box-shadow: var(--sh-md);
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 100;
}
.toast.on { transform: translateX(-50%) translateY(0); opacity: 1; }

/* heatmap */
.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 12px);
  gap: 3px;
  padding: 0.4rem 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.heatmap .cell {
  width: 12px; height: 12px;
  border-radius: 2px;
  background: var(--bg-2);
}
.heatmap .cell[data-l="1"] { background: rgba(138,123,255,0.25); }
.heatmap .cell[data-l="2"] { background: rgba(138,123,255,0.45); }
.heatmap .cell[data-l="3"] { background: rgba(138,123,255,0.7); }
.heatmap .cell[data-l="4"] { background: var(--acc-1); }


/* ============================================================
   Library content pages
   ============================================================ */
.lib-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}
.lib-shell .back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink-3);
  font-size: 0.9rem;
  margin-bottom: 1.4rem;
}
.lib-shell .back:hover { color: var(--ink-1); }
.lib-shell h1 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 3.6vw, 2.4rem);
  margin: 0 0 0.35em;
}
.lib-shell .intro {
  color: var(--ink-3);
  max-width: 46rem;
  margin: 0 0 2rem;
}

.lib-group {
  background: var(--bg-1-solid);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--sh-sm);
}
.lib-group h2 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 500;
  margin: 0 0 0.4rem;
  color: var(--ink-1);
}
.lib-group .rule {
  color: var(--ink-3);
  font-size: 0.92rem;
  line-height: 1.6;
  margin: 0 0 0.9rem;
  padding: 0.55rem 0.85rem;
  background: rgba(138,123,255,0.07);
  border-left: 3px solid var(--acc-1);
  border-radius: 4px;
}

/* phonics / vocab rows */
.pg-row, .vo-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem 1rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--rule-soft);
}
.pg-row:last-child, .vo-row:last-child { border-bottom: 0; }
.pg-ipa { font-family: var(--mono); color: var(--acc-1); font-size: 1.05rem; min-width: 4.5rem; }
.pg-sample { color: var(--ink-1); font-family: var(--serif); font-size: 1.05rem; }
.vo-en { font-family: var(--serif); font-size: 1.1rem; color: var(--ink-1); font-weight: 500; }
.vo-cn { color: var(--ink-3); }
.vo-ex {
  grid-column: 1 / -1;
  color: var(--ink-3);
  font-size: 0.9rem;
  margin-top: 0.1rem;
  line-height: 1.5;
  font-family: var(--serif);
  font-style: italic;
}

/* grammar example row */
.gr-ex {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  align-items: baseline;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--rule-soft);
}
.gr-ex:last-child { border-bottom: 0; }
.gr-ex .en { font-family: var(--serif); font-size: 1.05rem; color: var(--ink-1); line-height: 1.45; }
.gr-ex .cn { color: var(--ink-3); font-size: 0.9rem; }

/* phrases */
.ph-row { padding: 0.6rem 0; border-bottom: 1px dashed var(--rule-soft); }
.ph-row:last-child { border-bottom: 0; }
.ph-en {
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--ink-1);
  margin-bottom: 0.18rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.ph-cn { color: var(--ink-3); font-size: 0.92rem; }

/* reading */
.rd-article {
  padding: 1.4rem 1.5rem;
  background: var(--bg-1-solid);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r);
  margin-bottom: 1rem;
  box-shadow: var(--sh-sm);
}
.rd-article h3 { font-family: var(--serif); margin: 0 0 0.7rem; font-weight: 500; display: flex; align-items: center; gap: 0.5rem; color: var(--ink-1); }
.rd-article .en { font-family: var(--serif); font-size: 1.05rem; line-height: 1.75; color: var(--ink-1); margin-bottom: 0.7rem; }
.rd-article .cn { color: var(--ink-3); font-size: 0.95rem; line-height: 1.75; padding-top: 0.7rem; border-top: 1px dashed var(--rule-soft); }

/* verbs */
.vb-table {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1.4fr 1fr auto;
  gap: 0.4rem 1.2rem;
  align-items: center;
}
.vb-head {
  font-size: 0.7rem;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
}
.vb-row { display: contents; }
.vb-row > * { padding: 0.4rem 0; border-bottom: 1px dashed var(--rule-soft); }
.vb-cell { font-family: var(--serif); font-size: 1rem; color: var(--ink-1); cursor: pointer; }
.vb-cell:hover { color: var(--acc-1); }
.vb-cn { color: var(--ink-3); font-size: 0.85rem; font-family: var(--sans); }
@media (max-width: 640px) {
  .vb-table { grid-template-columns: 1fr 1fr 1fr auto; }
  .vb-cn    { display: none; }
}

/* play button */
.play-btn {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--bg-2);
  color: var(--ink-2);
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.65rem;
  flex-shrink: 0;
  transition: all 0.12s;
}
.play-btn:hover { background: var(--acc-2); color: #fff; border-color: var(--acc-2); }
.play-btn.playing {
  background: var(--acc-1); color: #0e1018; border-color: var(--acc-1);
  animation: play-pulse 1.1s ease-in-out infinite;
}
@keyframes play-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185,168,255,0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(185,168,255,0); }
}


/* ============================================================
   icons + book covers (no emoji)
   ============================================================ */
.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  vertical-align: middle;
  line-height: 0;
  color: inherit;
}
.ico svg { display: block; }

/* book cover (used in pickers + library) */
.cover {
  position: relative;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  overflow: hidden;
  background: var(--cover-bg, linear-gradient(135deg, #b9a8ff, #4d6bff));
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 0.7rem 0.8rem;
  color: rgba(0,0,0,0.78);
  box-shadow: var(--sh-sm);
}
.cover .cover-glyph {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.18);
  display: inline-flex;
  align-items: center; justify-content: center;
  color: rgba(0,0,0,0.85);
}
.cover .cover-meta { display: flex; flex-direction: column; gap: 0.1rem; }
.cover .cover-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 0.92rem;
  line-height: 1.2;
}
.cover .cover-sub {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: rgba(0,0,0,0.55);
}

/* ============================================================
   membership badges + page
   ============================================================ */
.membership-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  font-family: var(--sans);
  font-weight: 500;
}
.membership-pill.free   { background: var(--bg-2); color: var(--ink-3); border: 1px solid var(--rule); }
.membership-pill.gold   { background: linear-gradient(135deg, rgba(236,193,92,0.2), rgba(236,193,92,0.05)); color: var(--gold); border: 1px solid rgba(236,193,92,0.35); }
.membership-pill.streak { background: linear-gradient(135deg, rgba(255,123,123,0.2), rgba(236,193,92,0.1)); color: #ffa37c; border: 1px solid rgba(255,123,123,0.35); }

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
  max-width: 760px;
  margin: 0 auto;
}
@media (max-width: 720px) { .plan-grid { grid-template-columns: 1fr; } }
.plan {
  position: relative;
  border-radius: 18px;
  border: 1px solid var(--rule);
  background: var(--bg-1-solid);
  padding: 1.8rem 1.6rem 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow: hidden;
}
.plan.featured {
  border-color: rgba(236,193,92,0.4);
  background:
    radial-gradient(ellipse 60% 40% at 80% 0%, rgba(236,193,92,0.18), transparent 60%),
    var(--bg-1-solid);
  box-shadow: 0 0 0 1px rgba(236,193,92,0.18), var(--sh-md);
}
.plan h3 { margin: 0; font-family: var(--serif); font-size: 1.4rem; }
.plan .price {
  font-family: var(--serif);
  font-size: 2.6rem;
  line-height: 1;
  color: var(--ink-1);
  margin: 0.6rem 0 0.2rem;
}
.plan .price small { font-size: 1rem; color: var(--ink-3); margin-left: 0.3rem; }
.plan .feat-list {
  list-style: none; padding: 0; margin: 1.2rem 0; display: grid; gap: 0.55rem;
  color: var(--ink-2); font-size: 0.95rem;
}
.plan .feat-list li {
  display: flex; align-items: flex-start; gap: 0.55rem;
  line-height: 1.45;
}
.plan .feat-list .ok  { color: var(--ok); flex-shrink: 0; margin-top: 0.1rem; }
.plan .feat-list .x   { color: var(--ink-faint); flex-shrink: 0; margin-top: 0.1rem; }
.plan .ribbon {
  position: absolute;
  top: 0; right: 0;
  background: linear-gradient(135deg, #ecc15c, #d39830);
  color: #1a1610;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 0.32rem 0.7rem;
  border-bottom-left-radius: 10px;
}

.streak-pact {
  border-radius: 14px;
  border: 1px dashed rgba(236,193,92,0.4);
  background: linear-gradient(135deg, rgba(255,123,123,0.06), rgba(236,193,92,0.06));
  padding: 1.2rem 1.3rem;
  margin: 2rem auto 0;
  max-width: 760px;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.streak-pact .pact-icon {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: rgba(255,163,124,0.18);
  color: #ffa37c;
  display: inline-flex; align-items: center; justify-content: center;
}
.streak-pact h4 { margin: 0 0 0.25rem; color: var(--ink-1); font-family: var(--serif); font-weight: 500; }
.streak-pact p { margin: 0; color: var(--ink-3); font-size: 0.92rem; }
