/* Velvet Vault — dark, minimal. One accent color. */

:root {
  --bg: #0c0b10;
  --panel: #14131a;
  --panel-2: #1a1922;
  --border: #262433;
  --text: #edeaf4;
  --muted: #9b95ad;
  --accent: #a855f7;          /* the one accent color */
  --accent-dim: rgba(168, 85, 247, 0.14);
  --accent-ink: #160a26;
  --danger: #f87171;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win: #auth-screen sets display:flex,
   which otherwise overrides it and leaves the invite gate visible on top
   of the app after sign-in (found 2026-11-06). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Auth screen ---------- */

.screen { min-height: 100vh; }

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.5px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.tagline {
  color: var(--muted);
  font-size: 14px;
  margin: 12px 0 20px;
}

#redeem-form { display: flex; flex-direction: column; gap: 10px; }

#invite-code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 18px;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase;
  padding: 14px 12px;
  width: 100%;
}

#invite-code:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

button {
  font-family: var(--font);
  cursor: pointer;
}

#redeem-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 14px;
  width: 100%;
}

#redeem-btn:disabled { opacity: 0.55; cursor: wait; }

.error {
  color: var(--danger);
  font-size: 14px;
  margin: 12px 0 0;
}

.muted { color: var(--muted); font-size: 14px; }

/* ---------- App shell ---------- */

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 12px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.brand.small .brand-mark { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }
.brand.small .brand-name { font-weight: 700; font-size: 17px; }

.balance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  padding: 8px 14px;
}

.balance .coin { color: var(--accent); font-size: 16px; }

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 14px;
  white-space: nowrap;
}

.tab[aria-selected="true"] {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text);
}

.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Panels & fields ---------- */

.panel { padding: 20px 4px 0; animation: fade 0.15s ease-in; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.panel h2 { margin: 0 0 14px; font-size: 20px; }
.panel h3.sub { margin: 22px 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; }

.field { margin-bottom: 18px; }

.field > label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 8px;
}

.hint { font-weight: 400; text-transform: none; letter-spacing: 0; }
.req { color: var(--accent); }

/* Lane toggle — segmented control */
.lane-toggle {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 18px;
}

.lane {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  padding: 10px;
}

.lane[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.chip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  padding: 8px 14px;
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text);
}

.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Emotion chips carry a LOW/MED/HIGH dial */
.emotion-wrap { display: inline-flex; flex-direction: column; gap: 4px; }

.dial {
  display: flex;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}

.dial button {
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 8px;
}

.dial button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

/* Text inputs */
.custom, .voice, .brief {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 12px;
  margin-top: 4px;
}

.custom::placeholder, .voice::placeholder, .brief::placeholder { color: #5d5871; }

.custom:focus, .voice:focus, .brief:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.voice, .brief { resize: vertical; }

/* Count stepper + generate row */
.action-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin: 4px 0 18px;
}

.stepper {
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stepper button {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  width: 44px;
  height: 100%;
  min-height: 50px;
}

.stepper button:active { background: var(--panel-2); }
.stepper button:disabled { opacity: 0.3; }

.stepper .count-val {
  min-width: 34px;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
}

.generate {
  flex: 1;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  padding: 14px 16px;
}

.generate:disabled { opacity: 0.55; cursor: wait; }

/* ---------- Results ---------- */

.results { margin-top: 8px; }

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.results-head h3 { margin: 0; font-size: 16px; }

.copy-all {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
}

.copy-all.copied { border-color: var(--accent); color: var(--accent); }

.outputs { display: flex; flex-direction: column; gap: 10px; }

.output {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}

/* Full-mode pack cards: one card per pack, labeled sections with per-part Copy */
.pack-card { white-space: normal; }
.pack-part { margin-bottom: 12px; }
.pack-part:last-child { margin-bottom: 0; }
.pack-part-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.pack-part-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.copy-one {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
}
.copy-one.copied { border-color: var(--accent); color: var(--accent); }
.pack-part-text { white-space: pre-wrap; word-break: break-word; }

/* Inline link inside errors (e.g. "out of coins" -> wallet) */
.linklike {
  background: none;
  border: none;
  color: var(--accent);
  font-size: inherit;
  font-weight: 700;
  padding: 0;
  text-decoration: underline;
}

/* ---------- Wallet ---------- */

.wallet-balance {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.wb-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 700; }
.wb-num { font-size: 26px; font-weight: 800; }

.packs { display: flex; flex-direction: column; gap: 12px; }

.pack {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pack-info { display: flex; flex-direction: column; gap: 2px; }
.pack-name { font-weight: 800; font-size: 16px; }
.pack-price { color: var(--muted); font-size: 13px; }
.pack-coins { color: var(--accent); font-weight: 700; font-size: 14px; }

.buy {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  padding: 12px 20px;
  flex: 0 0 auto;
}

.buy:disabled { opacity: 0.55; cursor: wait; }

.fine { color: var(--muted); font-size: 13px; margin-top: 16px; }

/* ---------- Stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 6px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-num { font-size: 30px; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 13px; }

.stat-modes { display: flex; flex-direction: column; gap: 8px; }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
}

.stat-row .mode-name { font-weight: 700; text-transform: capitalize; }
.stat-row .mode-count { color: var(--accent); font-weight: 800; }

/* ---------- Small screens ---------- */

@media (max-width: 420px) {
  .action-row { flex-direction: column; }
  .stepper { justify-content: space-between; }
  .stepper button { min-height: 48px; }
  .generate { padding: 16px; }
  .pack { flex-direction: column; align-items: stretch; text-align: center; }
  .pack-info { align-items: center; }
}
