/* Rapport — phone-first phrasebook, theme-able.
 *
 * Themes swap the nine core colors below; soft tints derive via color-mix.
 * Semantic meaning never moves between themes: --accent is brand/interactive,
 * --down marks the "don't say this" lines (wrong thing to say).
 */

:root {                    /* default: Royal — royal blue & gold */
  --bg: #0d1322; --panel: #15203a; --panel2: #1d2b4e; --line: #2b3c66;
  --text: #e9ecf5; --muted: #96a2c4; --accent: #d9b45b;
  --up: #66c98a; --down: #e0716f;
}
html[data-theme="ember"] {
  --bg: #111318; --panel: #191c24; --panel2: #222633; --line: #2a2f3c;
  --text: #eae7e0; --muted: #9298a8; --accent: #e5a558;
  --up: #69c98a; --down: #e0716f;
}
html[data-theme="ice"] {
  --bg: #0d1418; --panel: #141d23; --panel2: #1c2830; --line: #263540;
  --text: #e4ebee; --muted: #8fa3ad; --accent: #56c3dc;
  --up: #69c98a; --down: #e0716f;
}
html[data-theme="nocturne"] {
  --bg: #141020; --panel: #1c1730; --panel2: #262040; --line: #322a52;
  --text: #eae6f2; --muted: #9d94b8; --accent: #a78bda;
  --up: #69c98a; --down: #e0716f;
}
html[data-theme="paper"] { /* light */
  --bg: #f5f2ec; --panel: #fdfbf7; --panel2: #ece6d8; --line: #d8d1c0;
  --text: #29261f; --muted: #7a7468; --accent: #8a6d1d;
  --up: #1a8f4a; --down: #c04543;
}
:root {
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --up-soft: color-mix(in srgb, var(--up) 14%, transparent);
  --down-soft: color-mix(in srgb, var(--down) 14%, transparent);
  --radius: 14px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px)
           calc(env(safe-area-inset-right) + 16px)
           calc(env(safe-area-inset-bottom) + 28px)
           calc(env(safe-area-inset-left) + 16px);
  -webkit-tap-highlight-color: transparent;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.theme-row { margin-top: 26px; display: flex; align-items: center; gap: 12px; justify-content: center; }
.theme-label { color: var(--muted); font-size: 0.75rem; }
.theme-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); padding: 0; }
.theme-dot.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.foot-note { color: var(--muted); font-size: 0.72rem; text-align: center; margin-top: 8px; line-height: 1.5; }

/* ---------------------------------------------------------------- shell */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  margin: 2px 0 10px;
}
.brand { font-size: 1.45rem; letter-spacing: 0.01em; }
.back { color: var(--muted); font-size: 0.9rem; padding: 8px 0; }
.back:active { color: var(--text); }
.nav { display: flex; gap: 6px; }
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
}
.nav-btn svg { width: 15px; height: 15px; }
.nav-btn svg path { fill: none; stroke: currentColor; stroke-width: 2; }
.nav-btn.has svg path { fill: currentColor; }
.nav-btn.sel { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.nav-count { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tagline { color: var(--muted); font-size: 0.85rem; margin: 0 2px 14px; }
.view-title { font-size: 1.3rem; margin: 6px 2px 12px; }
.muted { color: var(--muted); font-size: 0.8rem; }

/* ---------------------------------------------------------------- home */
.search {
  width: 100%;
  font-size: 16px;                 /* ≥16px stops iOS focus zoom */
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  text-transform: uppercase;
  font-family: var(--mono);
  letter-spacing: 0.04em;
}
.search::placeholder { color: var(--muted); text-transform: none; font-family: inherit; letter-spacing: 0; }
.search:focus { border-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  aspect-ratio: 1 / 1.05;
  padding: 8px 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tile:active { background: var(--panel2); }
.tile-code { font-family: var(--mono); font-weight: 700; font-size: 1.02rem; letter-spacing: 0.02em; }
.tile-wants { color: var(--muted); font-size: 0.6rem; text-align: center; line-height: 1.2; }
@media (min-width: 420px) {
  .tile-code { font-size: 1.12rem; }
  .tile-wants { font-size: 0.68rem; }
}

.empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ---------------------------------------------------------------- type card */
.type-head { margin: 4px 2px 14px; }
.type-code-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.type-code { font-family: var(--mono); font-size: 1.9rem; font-weight: 700; letter-spacing: 0.03em; }
.type-wants { color: var(--accent); font-size: 0.86rem; }
.type-read { color: var(--muted); font-size: 0.88rem; margin-top: 4px; line-height: 1.45; }

/* tab strip bleeds to the screen edge so it reads as scrollable */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px 12px;
  padding: 0 16px 4px;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}
.tab.sel { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.lines { display: flex; flex-direction: column; gap: 8px; }
.line {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px 6px 2px 14px;
  transition: background 0.25s, border-color 0.25s;
}
.line.copied { background: var(--accent-soft); border-color: var(--accent); }
.line.avoid { border-left: 3px solid var(--down); padding-left: 12px; }
.line-top { display: flex; align-items: flex-start; gap: 4px; }
.line-main { flex: 1; min-width: 0; text-align: left; padding: 11px 0 4px; }
.say { font-size: 1rem; line-height: 1.4; }
.say::before { content: "\201C"; color: var(--accent); }
.say::after { content: "\201D"; color: var(--accent); }
.line.avoid .say::before, .line.avoid .say::after { color: var(--down); }
.line-meta { color: var(--muted); font-size: 0.74rem; margin-top: 5px; }

.heart {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  margin-top: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--muted);
}
.heart svg { width: 20px; height: 20px; }
.heart svg path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.heart.on { color: var(--accent); }
.heart.on svg path { fill: currentColor; }
.heart:active { transform: scale(0.88); }

.why-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0 9px;
  color: var(--muted);
  font-size: 0.74rem;
}
.why-btn::after { content: "\25BE"; font-size: 0.7rem; transition: transform 0.15s; }
.why-btn.open::after { transform: rotate(180deg); }
.why { color: var(--muted); font-size: 0.84rem; line-height: 1.45; padding: 0 8px 11px 0; }
.why[hidden] { display: none; }
.hint { color: var(--muted); font-size: 0.74rem; text-align: center; margin-top: 16px; }

/* ---------------------------------------------------------------- favorites */
.fav-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.fav-group-head { display: flex; align-items: baseline; gap: 10px; text-align: left; padding: 6px 2px 0; }
.fav-group-head .mono { font-weight: 700; font-size: 1.05rem; }

/* ---------------------------------------------------------------- surprise */
.surprise-card {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.surprise-head { display: flex; align-items: baseline; gap: 10px; text-align: left; padding: 2px 2px 10px; }
.surprise-code { font-weight: 700; font-size: 1.3rem; }
.surprise-card .line { background: var(--panel); }
.actions { display: flex; gap: 10px; margin-top: 12px; }
.btn {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
.btn.ghost { background: var(--panel); border-color: var(--line); color: var(--text); font-weight: 600; }
.btn:active { transform: scale(0.99); }

/* ---------------------------------------------------------------- theme + toast */
.theme-auto { color: var(--muted); font-size: 0.75rem; padding: 4px 6px; border-radius: 8px; }
.theme-auto.sel { color: var(--accent); }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translate(-50%, 12px);
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
