:root {
  --bg: #efe8dc;
  --ink: #1c1915;
  --muted: #5e574c;
  --card: #fffdf8;
  --line: #e0d6c6;
  --accent: #8c3b16;
  --accent-ink: #fff8f3;
  --ok: #1d5c3d;
  --warn: #8a5a10;
  --danger: #8b2e2e;
  --nav-bar: 56px;
  --nav-fab: 56px;
  --nav-fab-lift: 18px;
  --nav-clearance: calc(var(--nav-bar) + var(--nav-fab-lift));
  --nav: var(--nav-clearance);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

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

.app {
  max-width: 32rem;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(0.75rem + env(safe-area-inset-top)) 1rem calc(var(--nav) + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}

.brand {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
}

h1, h2, h3 {
  font-family: Georgia, "Iowan Old Style", Palatino, "Palatino Linotype", serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 {
  margin: 0.15rem 0 0;
  font-size: 1.55rem;
  line-height: 1.2;
}

h2 { margin: 0 0 0.4rem; font-size: 1.35rem; line-height: 1.25; }
h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }

.back {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  flex: 0 0 auto;
}

.banner {
  background: #f4e4d4;
  color: #6a3414;
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem;
  margin: 0 0 0.8rem;
}

.lead, .hint, .meta { color: var(--muted); margin: 0 0 0.8rem; }
.hint { font-size: 0.92rem; }

.card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.95rem 1rem;
  margin: 0 0 0.8rem;
}

label { display: block; font-weight: 650; margin-bottom: 0.35rem; }

textarea, input[type="tel"] {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 0.75rem;
  padding: 0.75rem 0.8rem;
}

textarea { min-height: 8.5rem; resize: vertical; }

textarea:focus, input:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.actions, .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn, .ghost {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.72rem 1rem;
}

.btn {
  background: var(--accent);
  color: var(--accent-ink);
  width: 100%;
  font-weight: 700;
}

.btn:disabled { opacity: 0.55; }

.ghost {
  background: transparent;
  border-color: var(--line);
}

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  margin: 0.2rem 0 0.7rem;
}

.warn {
  color: var(--warn);
  background: #f8efd8;
  border-radius: 0.7rem;
  padding: 0.65rem 0.75rem;
  margin: 0.6rem 0 0;
}

.error {
  color: var(--danger);
  margin: 0.6rem 0 0;
}

.ok-title { color: var(--ok); }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  background: #f3e6da;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.list-btn, .settings-btn {
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  margin: 0 0 0.65rem;
}

.list-btn strong, .settings-btn strong { display: block; }

.note { white-space: pre-wrap; margin: 0.4rem 0 0; }

.history { list-style: none; padding: 0; margin: 0; }
.history li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}
.history time { color: var(--muted); flex: 0 0 auto; }

.rules { white-space: pre-wrap; }

.lang-pick { display: grid; gap: 0.5rem; }
.lang-pick button[aria-pressed="true"] {
  border-color: var(--accent);
  background: #f8efe8;
}

.nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(32rem, 100%);
  height: calc(var(--nav-bar) + env(safe-area-inset-bottom, 0px));
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  display: grid;
  grid-template-columns: 1fr var(--nav-fab) 1fr;
  align-items: end;
  transform: translateX(-50%);
  background: rgba(255, 253, 248, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
  overflow: visible;
}

.nav .tab-side,
.nav .tab-fab {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  -webkit-appearance: none;
}

.nav .tab-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--nav-bar);
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding: 6px 4px 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.15;
}

.nav .tab-side .tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.nav .tab-side .tab-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav .tab-side[aria-current="page"] {
  color: var(--accent);
  background: transparent;
}

.nav .tab-fab {
  position: relative;
  z-index: 1;
  width: var(--nav-fab);
  height: var(--nav-fab);
  margin: 0 auto var(--nav-fab-lift);
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 16px rgba(140, 59, 22, 0.32);
}

.nav .tab-fab .tab-fab-mark {
  font-size: 2rem;
  font-weight: 500;
  line-height: 1;
  margin-top: -2px;
}

.nav .tab-fab[aria-current="page"] {
  background: #6f2e11;
  box-shadow: 0 6px 18px rgba(140, 59, 22, 0.42);
}

audio { width: 100%; margin-top: 0.6rem; }

/* Same spotlight pattern as master Mini App; client storage key is separate. */
.tour {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}
.tour[hidden] { display: none !important; }
.tour-hole {
  position: absolute;
  border-radius: 18px;
  box-shadow: 0 0 0 9999px rgba(28, 25, 21, 0.5);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  pointer-events: none;
  transition: top 0.2s ease, left 0.2s ease, width 0.2s ease, height 0.2s ease;
}
.tour-tip {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-clearance) + 20px + env(safe-area-inset-bottom, 0px));
  width: calc(100% - 32px);
  max-width: 28rem;
  max-height: calc(100vh - var(--nav-clearance) - 96px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: 0 8px 24px rgba(28, 25, 21, 0.16);
  pointer-events: auto;
  z-index: 51;
}
.tour-tip.tour-tip-top {
  bottom: auto;
  top: calc(72px + env(safe-area-inset-top, 0px));
  max-height: calc(100vh - var(--nav-clearance) - 96px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}
.tour-step {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}
.tour-title {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.tour-text {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 0.96rem;
  overflow-wrap: anywhere;
}
.tour-actions {
  display: flex;
  gap: 10px;
}
.tour-actions .btn,
.tour-actions .ghost {
  flex: 1;
  text-align: center;
  padding: 12px 10px;
}
