:root {
  --bg: #f6f1e7;
  --surface: #fffaf1;
  --ink: #1f1b16;
  --muted: #6b6258;
  --faint: #a2988b;
  --line: #e4dccd;
  --accent: #c8643b;
  --accent-ink: #9a4a2f;
  --accent-soft: #f3dccd;
  --on-accent: #fffaf1;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 12px 40px -12px rgba(60, 40, 20, .18);
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130f;
    --surface: #1f1b16;
    --ink: #efe7da;
    --muted: #b3a797;
    --faint: #7d7266;
    --line: #342e27;
    --accent: #e08a5f;
    --accent-ink: #f0a67f;
    --accent-soft: #3a2a20;
    --on-accent: #1a120c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 48px -16px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16130f; --surface: #1f1b16; --ink: #efe7da; --muted: #b3a797; --faint: #7d7266; --line: #342e27;
  --accent: #e08a5f; --accent-ink: #f0a67f; --accent-soft: #3a2a20; --on-accent: #1a120c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 48px -16px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* Header */
.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 760px; width: 100%; margin: 0 auto; padding: 18px 16px 0;
}
.brand { display: flex; flex-direction: column; gap: 4px; text-decoration: none; }
.logo { font: 600 26px/1 var(--serif); letter-spacing: -.02em; white-space: nowrap; }
.logo-your { font-style: italic; font-weight: 500; }
.logo-day { color: var(--accent); }
.tagline { font: italic 400 13px/1 var(--serif); color: var(--muted); letter-spacing: .01em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); }
.lang button {
  border: 0; background: none; padding: 5px 11px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .03em;
}
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.icon-btn {
  position: relative; display: grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}

/* Stage */
.stage { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 20px 16px 24px; }
.today {
  margin: 4px 0 14px; font-size: 14px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
}
.today strong { color: var(--accent-ink); font-weight: 600; }

.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow); padding: clamp(24px, 5vw, 48px);
  min-height: 300px; display: flex; flex-direction: column; gap: 18px;
  touch-action: pan-y; user-select: text;
  transition: opacity .22s ease, transform .22s ease;
}
.card.leaving { opacity: 0; transform: translateX(-18px); }
.card.entering { opacity: 0; transform: translateX(18px); transition: none; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.orig { font-size: 12px; color: var(--faint); font-style: italic; }
.cat {
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent-soft); padding: 5px 10px; border-radius: 999px;
}
.quote { margin: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.quote p {
  margin: 0; font-family: var(--serif); font-weight: 450; letter-spacing: -.01em;
  font-size: clamp(22px, 4.2vw, 34px); line-height: 1.32; text-wrap: pretty; white-space: pre-line;
}
.quote p::before { content: '„'; color: var(--accent); margin-right: .04em; }
.quote p::after { content: '”'; color: var(--accent); margin-left: .02em; }
.quote.long p { font-size: clamp(19px, 3vw, 25px); }
.quote.poem p { font-style: italic; }
.quote.plain p::before, .quote.plain p::after { content: none; }
.quote .skeleton { color: var(--faint); }
.quote .skeleton::before, .quote .skeleton::after { content: none; }
.translation {
  margin: -2px 0 0; padding: 12px 0 2px 16px; border-left: 3px solid var(--accent-soft);
}
.tr-label {
  margin: 0 0 6px; font: 600 11px/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink);
}
.tr-engine { font-weight: 500; letter-spacing: .04em; color: var(--faint); text-transform: none; }
.tr-engine::before { content: '· '; }
.translation p {
  margin: 0; font: italic 400 clamp(17px, 2.6vw, 21px)/1.4 var(--serif); color: var(--muted);
  white-space: pre-line; text-wrap: pretty;
}
.attrib { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px; }
.who { font-size: 16px; font-weight: 500; }
.who:not(:empty)::before { content: '— '; color: var(--faint); }
.who em { font-style: italic; font-weight: 400; color: var(--muted); }
.src { font-size: 13px; color: var(--faint); text-decoration: none; border-bottom: 1px dotted var(--faint); }
.src:hover { color: var(--muted); }

/* Share */
.share { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 14px; font-weight: 500; text-decoration: none; color: var(--ink);
}
.pill:hover { border-color: var(--faint); }
.pill svg { width: 16px; height: 16px; }
.heart[aria-pressed="true"] { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft); }
.heart[aria-pressed="true"] svg, #fav-open svg { fill: currentColor; fill-opacity: .0; }
.heart[aria-pressed="true"] svg { fill-opacity: 1; }

/* Main button */
.go { display: flex; gap: 10px; margin: 26px 0 16px; }
.big {
  flex: 1; border: 0; border-radius: 18px; padding: 20px 24px;
  background: var(--accent); color: var(--on-accent);
  font: 600 clamp(22px, 5vw, 28px)/1 var(--serif); letter-spacing: -.01em;
  box-shadow: 0 10px 28px -12px var(--accent);
  transition: transform .12s ease, filter .12s ease;
}
.big:hover { filter: brightness(1.05); }
.big:active { transform: scale(.985); }
.big[aria-busy="true"] { filter: saturate(.7); }
.back {
  width: 64px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
  display: grid; place-items: center;
}
.back:disabled { opacity: .4; cursor: default; }
.back svg { width: 22px; height: 22px; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: 8px 14px; font-size: 14px; font-weight: 500; color: var(--muted);
}
.chips button[aria-checked="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Search */
.search { margin-top: 28px; }
.search label { display: block; font: 500 18px/1.3 var(--serif); margin-bottom: 8px; }
.search-row {
  display: flex; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden;
}
.search-row:focus-within { border-color: var(--accent); }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 13px 14px;
  font: inherit; color: var(--ink); outline: none;
}
.search input::placeholder { color: var(--faint); }
.search button { border: 0; background: transparent; padding: 0 16px; color: var(--muted); }
.search-note { margin: 8px 2px 0; font-size: 14px; color: var(--muted); }
.search-note button { border: 0; background: none; padding: 0; text-decoration: underline; color: var(--accent-ink); }

.hint { margin-top: 26px; font-size: 13px; color: var(--faint); }
kbd {
  font: 500 11px/1 var(--sans); padding: 3px 6px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; background: var(--surface); color: var(--muted);
}
@media (hover: none) { .hint { display: none; } }

/* Favorites */
.favs {
  width: min(560px, calc(100vw - 32px)); max-height: min(80dvh, 720px); padding: 0;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow);
}
.favs::backdrop { background: rgba(20, 14, 8, .45); }
.favs-head {
  position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 16px 16px 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.favs h2 { margin: 0; font: 600 22px/1 var(--serif); }
#fav-list { list-style: none; margin: 0; padding: 6px 12px 12px; }
#fav-list li { display: flex; gap: 10px; padding: 12px 8px; border-bottom: 1px solid var(--line); }
#fav-list li:last-child { border-bottom: 0; }
#fav-list a { flex: 1; text-decoration: none; font-family: var(--serif); font-size: 17px; line-height: 1.35; }
#fav-list .fav-tr { display: block; margin-top: 4px; font-style: italic; font-size: 15px; color: var(--muted); }
#fav-list small { display: block; margin-top: 4px; font-family: var(--sans); font-size: 13px; color: var(--muted); }
#fav-list button { align-self: flex-start; border: 0; background: none; color: var(--faint); padding: 4px; }
.empty { padding: 8px 20px 24px; color: var(--muted); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.bottom { text-align: center; padding: 16px 16px 28px; font-size: 13px; color: var(--faint); }
.bottom a { color: var(--muted); text-decoration: none; }
.bottom a:hover { text-decoration: underline; }

@media (max-width: 520px) {
  .logo { font-size: 22px; }
  .card { min-height: 260px; border-radius: 18px; }
  .pill { padding: 8px 11px; font-size: 13px; }
  .go { margin-top: 20px; }
  .big { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .big, .toast { transition: none; }
}
