:root {
  --paper: #ffffff;
  --tint: #f5f4f2;
  --ink: #1f1b16;
  --muted: #6f665a;
  --seal: #b3261e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14120f;
    --tint: #1c1915;
    --ink: #eee6d6;
    --muted: #a39886;
    --seal: #e0584c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem max(2rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
}

main {
  width: 100%;
  max-width: 40rem;
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card {
  padding: 1.75rem 1.25rem 2rem;
  text-align: center;
}

.eyebrow {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
/* negative margin cancels the trailing letter-spacing so the line stays centered */
.eyebrow .zh { display: block; font-size: 1.2em; letter-spacing: 0.3em; margin-right: -0.3em; }
.date {
  margin: 0.5rem 0 0;
  font-size: 1.02rem;
  line-height: 1.3;
  color: var(--muted);
}

.idiom {
  display: flex;
  justify-content: center;
  gap: 0.08em;
  margin: 1.75rem 0 1.5rem;
  /* four glyphs + gaps must fit inside body + card padding (~5rem total) */
  font-size: min(8rem, calc((100vw - 5.5rem) / 4.4));
}
.char {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 1em;
}
.char .py {
  font-family: "EB Garamond", serif;
  font-size: max(1rem, 0.19em);
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.char .hz {
  font-family: "Ma Shan Zheng", "STKaiti", "KaiTi", "Kaiti SC", serif;
  line-height: 1.1;
  font-weight: 400;
  color: var(--seal);
}

.meaning {
  margin: 1rem auto 0.9rem;
  max-width: 30rem;
  font-size: 1.05rem;
  line-height: 1.8;
}
.translation {
  margin: 0 auto;
  max-width: 30rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.explanation {
  margin: 1.5rem auto 0;
  max-width: 30rem;
  font-size: 0.9rem;
  line-height: 1.7;
  text-align: left;
}

.example {
  margin: 1.5rem auto 0;
  max-width: 30rem;
  padding: 1rem 1.1rem;
  border-radius: 0.75rem;
  background: var(--tint);
  text-align: left;
}
.example .label {
  margin: 0 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.example .label .zh { letter-spacing: 0.3em; margin-right: 0.35em; }
.example .zh-sentence {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  line-height: 1.8;
}
.example mark {
  background: none;
  color: var(--seal);
  font-weight: 600;
}
.example .en-sentence {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.status {
  color: var(--muted);
  font-size: 0.95rem;
  padding: 3rem 0;
}

@media (min-width: 640px) {
  body { padding-top: 3rem; }
  .card { padding: 2.5rem 2.5rem 3rem; }
  .idiom { font-size: min(8rem, calc((100vw - 8rem) / 4.4)); }
  .meaning { font-size: 1.15rem; }
  .translation { font-size: 1rem; }
}

/* ?context=iframe: only the idiom, scaled to fit the frame and centered */
html.iframe body {
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  justify-content: center;
}
html.iframe main { flex: none; max-width: none; }
html.iframe .card { padding: 0; }
html.iframe .eyebrow,
html.iframe .date,
html.iframe .status { display: none; }
html.iframe .idiom {
  margin: 0;
  gap: 0;
  /* font-size is set by fitIframe() in app.js */
}
/* Pinyin in Inter, larger than on the regular page: Garamond's small x-height
   is hard to read at iframe sizes. Scales with the glyphs (no 1rem floor). */
html.iframe .char .py {
  order: 1;
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 500;
  font-size: 0.24em;
  letter-spacing: 0;
  margin-top: 0.5em;
}

/* very narrow screens (regular page only): drop the " · 4" tone suffix */
@media (max-width: 299.98px) {
  html:not(.iframe) .char .py .tone { display: none; }
}
