:root {
  --page: #17130f;
  --paper: #efe1c8;
  --ink: #251a12;
  --muted: #76634f;
  --accent: #7b3f1d;
  --accent-soft: #f8d8a8;
  --line: rgba(37, 26, 18, 0.18);
  --reader-size: 22px;
  --reader-line: 1.65;
  --reader-width: 42ch;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--page); color: var(--ink); }
body {
  margin: 0;
  min-height: 100svh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #30251a 0, var(--page) 42rem);
}
button, textarea, input { font: inherit; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 0.9rem;
  color: #f6ecd9;
  background: rgba(23, 19, 15, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.eyebrow { margin: 0 0 0.15rem; color: #d6b98b; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; }
h1 { margin: 0; font-size: 1.15rem; line-height: 1.1; }
main { display: grid; gap: 1rem; width: min(100%, 980px); margin: 0 auto; padding: 1rem 0.85rem 4rem; }
.composer, .reader-shell { border: 1px solid rgba(255,255,255,0.10); border-radius: 1.2rem; overflow: hidden; box-shadow: 0 18px 40px rgba(0,0,0,0.28); }
.composer { padding: 1rem; color: #f4e7d0; background: rgba(255,255,255,0.045); }
.composer label { display: block; margin-bottom: 0.5rem; font-weight: 700; }
textarea { width: 100%; min-height: 7rem; padding: 0.85rem; resize: vertical; color: #f6ecd9; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.14); border-radius: 0.85rem; }
.button-row { display: flex; gap: 0.65rem; flex-wrap: wrap; margin-top: 0.75rem; }
button { border: 0; border-radius: 999px; padding: 0.7rem 1rem; color: #fff7ea; background: var(--accent); cursor: pointer; }
button.secondary { color: #f6ecd9; background: rgba(255,255,255,0.12); }
.icon-button { width: 2.75rem; height: 2.75rem; padding: 0; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.16); }
.hint { margin: 0.7rem 0 0; color: #d8c6aa; font-size: 0.9rem; line-height: 1.45; }
.reader-shell { background: var(--paper); }
.reader-toolbar { position: sticky; top: 4.65rem; z-index: 4; display: flex; gap: 0.5rem; padding: 0.7rem; background: color-mix(in srgb, var(--paper) 86%, white); border-bottom: 1px solid var(--line); }
.pill { color: var(--ink); background: transparent; border: 1px solid var(--line); padding: 0.55rem 0.85rem; }
.pill.active { background: var(--accent); color: white; border-color: transparent; }
.reader { max-width: var(--reader-width); margin: 0 auto; padding: 1.2rem 1.05rem 2rem; font-family: Georgia, Garamond, "Times New Roman", serif; font-size: var(--reader-size); line-height: var(--reader-line); }
.sentence { display: inline; border-radius: 0.35rem; padding: 0.05rem 0.06rem; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(123, 63, 29, 0.28); text-decoration-thickness: 0.08em; text-underline-offset: 0.16em; }
.sentence:focus, .sentence:hover { outline: 0; background: var(--accent-soft); }
.translation-card, .glossary-card { margin: 0 0 1rem; padding: 1rem; background: rgba(255,255,255,0.32); border: 1px solid var(--line); border-radius: 0.9rem; }
.translation-card h3, .glossary-card h3 { margin: 0 0 0.55rem; font-size: 1rem; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.translation-card p, .glossary-card p { margin: 0; }
.translation-card .literal { color: var(--muted); font-size: 0.92em; margin-top: 0.45rem; }
.glossary-list { display: grid; gap: 0.7rem; margin: 0; }
.glossary-list div { padding-bottom: 0.7rem; border-bottom: 1px solid var(--line); }
.glossary-list div:last-child { border-bottom: 0; padding-bottom: 0; }
.glossary-list dt { font-weight: 700; }
.glossary-list dd { margin: 0.1rem 0 0; color: var(--muted); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 0.95rem; line-height: 1.35; }
.note-popover { position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100vw - 1.4rem), 30rem); max-height: 55svh; overflow: auto; z-index: 10; padding: 1rem; color: var(--ink); background: #fff3da; border: 1px solid var(--line); border-radius: 1.1rem; box-shadow: 0 22px 60px rgba(0,0,0,0.42); }
.note-popover h2 { margin: 0 0 0.45rem; font-size: 1.05rem; }
.note-popover p { margin: 0.45rem 0; line-height: 1.42; }
.note-popover ul { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.note-popover li { margin: 0.25rem 0; }
.note-popover small { color: var(--muted); }
.settings-panel { position: fixed; inset: 0; z-index: 20; display: grid; place-items: end center; padding: 1rem; background: rgba(0,0,0,0.45); }
.panel-card { width: min(100%, 28rem); padding: 1.2rem; color: #f6ecd9; background: #241b14; border: 1px solid rgba(255,255,255,0.14); border-radius: 1.2rem; }
.panel-card h2 { margin: 0 0 1rem; }
.panel-card label { display: grid; gap: 0.35rem; margin: 0.85rem 0; }
.close-button { float: right; width: 2.35rem; height: 2.35rem; padding: 0; background: rgba(255,255,255,0.12); }
@media (min-width: 800px) { main { grid-template-columns: 330px 1fr; align-items: start; } .composer { position: sticky; top: 5.8rem; } }