:root {
  --bg: #0c0e12;
  --ink: #e8e4db;
  --ink-soft: #c9c3b6;
  --muted: #8f897e;
  --amber: #c6a56a;
  --amber-2: #f0e6d2;
  --clay: #d7a08a;
  --rose: #c97b8a;
  --line: rgba(232, 228, 219, 0.12);
  --line-strong: rgba(232, 228, 219, 0.28);
  --serif: "EB Garamond", "Palatino Linotype", Palatino, "Noto Serif", "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", "Noto Sans", sans-serif;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html { scroll-behavior: smooth; }

html.booting body { visibility: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.45;
  background:
    radial-gradient(1px 1px at 18% 8%, rgba(232, 228, 219, 0.7), transparent),
    radial-gradient(1.4px 1.4px at 82% 14%, rgba(198, 165, 106, 0.85), transparent),
    radial-gradient(1px 1px at 70% 4%, rgba(232, 228, 219, 0.45), transparent),
    radial-gradient(1px 1px at 8% 42%, rgba(232, 228, 219, 0.35), transparent),
    radial-gradient(900px 420px at 50% -8%, rgba(198, 165, 106, 0.07), transparent 55%),
    var(--bg);
}

button, input, textarea { font: inherit; color: inherit; }

button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 12px;
  top: 8px;
  transform: translateY(-140%);
  background: var(--ink);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: 999px;
  z-index: 30;
}

.skip:focus { transform: none; }

.app {
  width: min(640px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 0 calc(108px + env(safe-area-inset-bottom));
}

.top { padding: 4px 0 0; }

.lang {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.lang select {
  min-width: 132px;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #12141a;
  color: var(--ink-soft);
  padding: 0 30px 0 12px;
  font-size: 0.84rem;
  font-weight: 600;
  text-align: start;
  accent-color: var(--rose);
}

[dir="rtl"] .lang select {
  padding: 0 12px 0 30px;
}

.lang select:focus-visible {
  border-color: var(--rose);
}

.moon {
  width: 36px;
  height: 36px;
  margin: 8px 0 10px;
  color: var(--ink);
  display: block;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  color: var(--amber-2);
}

h1 .name,
h1 .rest {
  line-height: 1.05;
}

h1 .name {
  font-size: clamp(2.15rem, 8.6vw, 3.45rem);
  letter-spacing: -0.02em;
}

h1 .rest {
  font-size: clamp(1.02rem, 3.3vw, 1.24rem);
  font-weight: 500;
  color: var(--ink-soft);
}

.mark {
  color: var(--rose);
  font-size: 0.9em;
  white-space: nowrap;
}

.greek-name {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--ink);
}

.tagline,
.gift {
  margin: 10px 0 0;
  max-width: 36rem;
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.35;
}

.tagline {
  font-size: 1.02rem;
  color: var(--ink-soft);
}

.gift {
  margin-top: 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

.blurb {
  margin: 12px 0 0;
  max-width: 36rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.4;
}

.blurb + .blurb { margin-top: 8px; }

.meander {
  width: min(168px, 46%);
  height: 12px;
  margin: 16px 0 0;
  color: var(--rose);
  opacity: 0.72;
}

.steps {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
}

.steps li {
  display: grid;
  grid-template-columns: 7.6rem minmax(0, 1fr);
  gap: 10px 12px;
  align-items: baseline;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}

.step-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.15;
  color: var(--amber-2);
}

.steps p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.composer-note,
.hint,
.fine {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.composer-note { font-size: 0.86rem; }

.writer { margin-top: 8px; }

.banner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  padding-top: 12px;
}

.banner p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--ink);
}

.word.is-hz-only { justify-content: flex-start; }
.word.is-hz-only .word-text { display: none; }

textarea {
  display: block;
  width: 100%;
  min-height: 5.4rem;
  resize: vertical;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 14px 0 8px;
  background: transparent;
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1.3;
}

textarea::placeholder {
  color: #6f6a61;
  font-style: italic;
  font-weight: 400;
}

.toolbar, .share-actions, .bit-row, .phi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar { margin-top: 4px; }

.phi-row { justify-content: space-between; margin-top: 2px; }

.phi-row .hint { margin: 0; flex: 1; min-width: 12rem; }

.text-btn, .ghost, .solid {
  min-height: 44px;
  border-radius: 999px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
}

.text-btn {
  padding: 0 8px;
  border-color: transparent;
  color: var(--amber);
  font-size: 0.95rem;
}

.solid {
  background: #efeae2;
  border-color: #efeae2;
  color: #16140f;
  font-weight: 600;
}

.ghost { background: transparent; }

.solid.wide {
  display: block;
  width: 100%;
  margin-top: 18px;
}

button:disabled { opacity: 0.4; }

.counted {
  margin: 14px 0 0;
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

.counted-label {
  display: block;
  margin-bottom: 2px;
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
}

.counted mark {
  background: none;
  color: var(--amber-2);
  font-weight: 500;
}

.history { margin-top: 22px; }

.history-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 12px;
}

.history .section-title { font-size: 1.35rem; }

.history-empty { margin-top: 8px; font-family: var(--serif); font-style: italic; font-size: 1.05rem; }

.history-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 16.5rem;
  overflow: auto;
}

.history-item {
  display: block;
  width: 100%;
  scroll-margin-bottom: 120px;
  min-height: 44px;
  margin: 0;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  overflow-wrap: anywhere;
}

.history-item:hover,
.history-item:focus-visible {
  color: var(--ink);
}

.voices { margin-top: 28px; }

.voices-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.section-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 500;
  color: var(--ink);
}

.section-title span {
  color: var(--muted);
  font-size: 0.78em;
}

.exact {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.exact strong {
  color: var(--amber-2);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.invite {
  margin: 18px 0;
  color: var(--muted);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
}

.word {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 13px 8px 13px 10px;
  border-bottom: 1px solid var(--line);
}

.word.is-on {
  background: linear-gradient(90deg, rgba(198, 165, 106, 0.16), transparent 72%);
  box-shadow: inset 2px 0 0 var(--amber);
}

.word-text { min-width: 0; }

.word-name {
  display: block;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.word-from {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.word-hz {
  flex: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
}

.hz-num {
  font-weight: 600;
  font-size: 1.05rem;
}

.hz-unit {
  margin-left: 4px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.hz-note {
  display: block;
  max-width: 8rem;
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.15;
  color: var(--clay);
}

.word-hz.is-zero,
.word-hz.is-closed { color: var(--muted); }

.word-hz.is-closed .hz-note { color: var(--muted); }

.word-count {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.above-note { color: var(--clay); }

.systems-note { max-width: 38rem; }

.languages {
  margin-top: 32px;
  padding-top: 4px;
}

.languages p {
  margin: 8px 0 0;
  max-width: 38rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.gate {
  margin-top: 36px;
  padding-top: 8px;
}

canvas#wave {
  width: 100%;
  height: 56px;
  display: block;
  margin: 12px 0 8px;
}

.kicker {
  margin: 0 0 8px;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}

.field { margin: 16px 0; }

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.seg button {
  flex: 1 1 40%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-soft);
  padding: 0 8px;
}

.seg button[aria-pressed="true"] {
  background: rgba(232, 228, 219, 0.08);
  color: var(--amber-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.slider-row { margin: 14px 0; }

.slider-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.slider-label span {
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 36px;
  background: transparent;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: rgba(232, 228, 219, 0.28);
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--amber-2);
  border: 0;
}

input[type="range"]::-moz-range-track {
  height: 2px;
  background: rgba(232, 228, 219, 0.28);
  border-radius: 999px;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--amber-2);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.switch {
  position: relative;
  width: 64px;
  height: 44px;
  flex: none;
  border: 0;
  padding: 0;
  background: transparent;
}

.switch::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: 8px;
  bottom: 8px;
  border-radius: 999px;
  background: #12141a;
  border: 1px solid var(--line-strong);
}

.switch::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  top: 11px;
  left: 10px;
  border-radius: 50%;
  background: var(--ink-soft);
  transition: transform 160ms ease;
}

.switch[aria-checked="true"]::before {
  background: #3a3428;
  border-color: rgba(198, 165, 106, 0.55);
}

.switch[aria-checked="true"]::after {
  transform: translateX(22px);
  background: var(--amber-2);
}

.switch:disabled { opacity: 0.45; }

.footer {
  text-align: left;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 28px 0 8px;
}

.footer p {
  margin: 5px 0 0;
}

.footer-gift {
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 0.98rem;
  letter-spacing: 0;
}

.footer-signature {
  color: var(--rose);
  font-family: var(--serif);
  font-size: 1rem;
  letter-spacing: 0;
}

.footer-read a {
  color: var(--muted);
  text-decoration-color: rgba(143, 137, 126, 0.45);
  text-underline-offset: 3px;
}

.footer-device {
  color: var(--muted);
  font-size: 0.72rem;
}

.mute-tip {
  position: fixed;
  z-index: 21;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(640px, calc(100% - 16px));
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  background: #16181e;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}

.mute-tip p {
  margin: 0;
  flex: 1;
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--ink-soft);
}

.mute-tip button {
  flex: none;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--amber-2);
  padding: 0 12px;
}

.dock {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(640px, calc(100% - 12px));
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(12, 14, 18, 0.94);
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.35);
}

.transport {
  display: grid;
  grid-template-columns: 1.25fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.status {
  grid-column: 1 / -1;
  margin: 0;
  min-height: 1.2em;
  color: var(--amber);
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#play, #loop, #stop {
  min-height: 46px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  padding: 0 12px;
  font-weight: 600;
}

#play {
  background: #efeae2;
  color: #16140f;
  border-color: #efeae2;
}

#loop, #stop { background: transparent; color: var(--ink); }

#loop[aria-pressed="true"] {
  background: rgba(198, 165, 106, 0.18);
  border-color: rgba(198, 165, 106, 0.7);
  color: var(--amber-2);
}

body.is-playing #play[aria-pressed="true"] {
  box-shadow: 0 0 0 4px rgba(232, 228, 219, 0.12);
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  width: min(520px, 100%);
  max-height: none;
  margin: auto auto 0;
}

dialog::backdrop { background: rgba(6, 7, 10, 0.72); }

.sheet {
  max-height: min(92vh, 860px);
  overflow: auto;
  background: #14171c;
  border: 1px solid var(--line-strong);
  border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.sheet h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.7rem;
  color: var(--amber-2);
}

.choice {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.choice h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--amber-2);
}

.filename {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.filename strong { color: var(--ink); font-weight: 600; }

.share-actions { margin-top: 10px; }

.share-actions .solid,
.share-actions .ghost { flex: 1; }

.bit-row { margin-top: 12px; }

.bit-row > span { color: var(--muted); font-size: 0.9rem; }

.bit-row .seg { flex: 1; }

.bit-row .seg button { flex: 1 1 30%; }

.about-body p { margin: 0 0 12px; color: var(--ink-soft); }

#share-status { min-height: 1.3em; margin-top: 12px; }

.noscript {
  width: min(640px, calc(100% - 32px));
  margin: 24px auto;
  color: var(--ink-soft);
}

@media (min-width: 720px) {
  .app { padding-top: 28px; }
  .moon { margin-left: 0; }
  dialog { margin: auto; }
  .sheet { border-radius: 22px; }
  .voices-head {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }
}

@media (max-width: 380px) {
  .transport { grid-template-columns: 1fr 1fr; }
  #stop { grid-column: 1 / -1; }
  .steps li { grid-template-columns: 1fr; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .switch::after { transition: none; }
}
