:root {
  --bg: #0c0a06;
  --surface: #17130b;
  --rule: #33291a;
  --rule-soft: #26200f;
  --ink: #f2ead6;
  --muted: #9c8f6e;
  --muted-dim: #6b5f47;
  --gold: #d4af6a;
  --gold-soft: rgba(212, 175, 106, 0.14);
  --buy: #4caf7d;
  --sell: #d65c5c;
  --serif: "Didot", "Bodoni MT", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
  --sans: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

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

#app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: max(28px, env(safe-area-inset-top)) 22px max(22px, env(safe-area-inset-bottom));
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.32s ease, transform 0.32s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .screen { transition: opacity 0.15s linear; transform: none; }
}

/* ---- splash ---- */
#screen-splash { align-items: center; justify-content: center; background: #050402; }

.splash-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; }

.splash-logo-wrap {
  position: relative;
  width: min(52vw, 200px);
  overflow: hidden;
  opacity: 0;
  transform: scale(0.92);
  animation: splashLogoIn 3s cubic-bezier(0.5, 0, 0.4, 1) forwards;
}

.splash-logo-wrap img { display: block; width: 100%; height: auto; }

.splash-logo-wrap::after {
  content: "";
  position: absolute;
  top: -20%; left: -60%;
  width: 40%; height: 140%;
  background: linear-gradient(100deg, transparent 20%, rgba(255,244,214,0.55) 50%, transparent 80%);
  mix-blend-mode: overlay;
  transform: skewX(-18deg);
  animation: splashSheen 3s ease-in-out forwards;
}

.splash-hairline {
  width: 0;
  height: 1px;
  opacity: 1;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: splashHairline 3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes splashLogoIn {
  0%   { opacity: 0; transform: scale(0.92); }
  15%  { opacity: 1; transform: scale(1); }
  60%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(2.6); }
}
@keyframes splashSheen {
  0%, 15%   { left: -60%; }
  42%, 100% { left: 140%; }
}
@keyframes splashHairline {
  0%, 18%  { width: 0; opacity: 1; }
  38%, 56% { width: min(30vw, 120px); opacity: 1; }
  70%      { width: min(30vw, 120px); opacity: 0; }
  100%     { width: min(30vw, 120px); opacity: 0; }
}

/* splash intentionally always plays in full, regardless of prefers-reduced-motion */

/* ---- shared centered stage (language / login) ---- */
.center-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
}

.brandmark { width: min(64vw, 260px); height: auto; display: block; }
.brandmark.small { width: min(58vw, 225px); }
.brandmark.tiny { width: 30px; height: auto; }

.lang-list { width: 100%; display: flex; flex-direction: column; gap: 10px; }

.lang-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 15px 18px; border-radius: 6px;
  border: 1px solid var(--rule); background: var(--surface);
  color: var(--ink); font-size: 15px; text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.lang-row[aria-checked="true"] {
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--gold-soft), rgba(212,175,106,0.02));
}

.lang-code { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }

#login-form { width: 100%; }

.field-label {
  font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px; display: block;
}

.field {
  width: 100%; padding: 13px 14px; border-radius: 6px;
  border: 1px solid var(--rule); background: var(--surface);
  color: var(--ink); font-size: 14.5px; margin-bottom: 16px;
}

.field:focus { border-color: var(--gold); }

.field-error {
  color: var(--sell); font-size: 12.5px; margin: -8px 0 14px;
}

.btn {
  width: 100%; padding: 14px; border-radius: 6px; border: none;
  background: linear-gradient(180deg, #e6c988, #b8903f); color: #17130b;
  font-weight: 700; font-size: 14px; letter-spacing: 0.03em;
}

.btn:disabled { opacity: 0.4; }

.btn.ghost {
  background: transparent; border: 1px solid var(--rule); color: var(--ink);
  margin-top: 14px;
}

.hairline-note {
  font-size: 12px; color: var(--muted); text-align: center;
  margin-top: 16px; line-height: 1.55; max-width: 32ch;
}

/* ---- disclaimers ---- */
.disclaimer-stage {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  width: 100%; max-width: 480px; margin: 0 auto;
}

.disclaimer-scroll {
  flex: 1; overflow-y: auto; font-size: 13.5px; line-height: 1.62; color: #c9bd9e;
  padding: 16px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--surface); margin: 8px 0 16px;
}

.disclaimer-scroll p { margin: 0 0 11px; }
.disclaimer-scroll p:last-child { margin-bottom: 0; }
.disclaimer-scroll h3 {
  font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--gold); margin: 18px 0 9px; font-weight: 700;
}
.disclaimer-scroll h3:first-child { margin-top: 0; }
.disclaimer-scroll ul, .disclaimer-scroll ol { margin: 0 0 11px; padding-left: 20px; }
.disclaimer-scroll li { margin-bottom: 7px; }
.disclaimer-scroll .rule-label { color: var(--ink); font-weight: 600; }

.checkline {
  display: flex; align-items: flex-start; gap: 10px; font-size: 13px;
  color: #c9bd9e; margin-bottom: 16px; cursor: pointer;
}
.checkline input[type="checkbox"] {
  width: 18px; height: 18px; margin-top: 1px; accent-color: var(--gold);
  flex: 0 0 auto;
}

.validity-note {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  text-align: center; margin-top: 12px; letter-spacing: 0.02em;
}

/* ---- dashboard ---- */
#screen-dashboard { padding-left: 0; padding-right: 0; }

.dashboard-stage {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  width: 100%; max-width: 520px; margin: 0 auto; padding: 0 18px;
}

.top-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }

.lang-chip {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  border: 1px solid var(--rule); border-radius: 4px; padding: 5px 11px;
  background: transparent;
}

.feed-stack { display: flex; flex-direction: column; gap: 14px; flex: 1; padding-bottom: 200px; }

.feed-card {
  border: 1px solid var(--rule); background: var(--surface); border-radius: 8px;
  padding: 16px; display: flex; flex-direction: column;
  transition: border-color 0.4s ease, background 0.4s ease;
}

.feed-card.is-live {
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--gold-soft) 0%, var(--surface) 70%);
}

.feed-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.feed-title { font-size: 13.5px; font-weight: 600; letter-spacing: 0.01em; }

.status-pill {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 4px; display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); border: 1px solid var(--rule);
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.status-pill.listening .dot { background: var(--gold); animation: pulse 1.8s ease-in-out infinite; }
.status-pill.listening { color: var(--gold); border-color: #4a3d24; }

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(212,175,106,0.5); }
  50% { opacity: 0.55; box-shadow: 0 0 0 4px rgba(212,175,106,0); }
}
@media (prefers-reduced-motion: reduce) { .status-pill.listening .dot { animation: none; } }

.waiting-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--muted-dim); font-size: 13px; text-align: center; padding: 22px 0;
}

.trade-view { animation: tradeIn 0.35s ease; }
@keyframes tradeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .trade-view { animation: none; } }

.trade-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 11px; }
.trade-symbol { font-family: var(--mono); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.side-badge { font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; padding: 4px 10px; border-radius: 4px; }
.side-badge.buy { background: rgba(76,175,125,0.16); color: #6fcf9e; }
.side-badge.sell { background: rgba(214,92,92,0.16); color: #e0847f; }

.trade-meta { display: flex; gap: 18px; margin-bottom: 13px; }
.meta-block dt { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-dim); margin: 0 0 3px; }
.meta-block dd { margin: 0; font-family: var(--mono); font-size: 13.5px; font-variant-numeric: tabular-nums; }

.sltp-row { display: flex; gap: 8px; margin-bottom: 10px; }
.sltp-chip { font-family: var(--mono); font-size: 10.5px; padding: 4px 9px; border-radius: 4px; border: 1px solid var(--rule); color: var(--muted); }
.sltp-chip.set { color: var(--gold); border-color: #4a3d24; background: rgba(212,175,106,0.08); }

.pager-row {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--rule-soft);
}
.pager-arrow {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid #4a3d24;
  color: var(--gold); background: transparent; font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.pager-arrow:disabled { opacity: 0.25; }
.pager-dots { display: flex; gap: 6px; }
.pdot { width: 6px; height: 6px; border-radius: 50%; background: #4a3d24; transition: all 0.2s ease; }
.pdot.active { background: var(--gold); width: 16px; border-radius: 3px; }
.pager-label { font-family: var(--mono); font-size: 10px; color: var(--muted-dim); letter-spacing: 0.03em; }

/* ---- toast (in-page stand-in for OS push) ---- */
.toast-stack {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  z-index: 50; pointer-events: none; padding: 0 16px;
}

.toast {
  width: 100%; max-width: 380px;
  background: rgba(23, 19, 11, 0.94); backdrop-filter: blur(14px);
  border: 1px solid rgba(212,175,106,0.22); border-radius: 14px; padding: 13px 15px;
  display: flex; gap: 12px; box-shadow: 0 20px 40px -14px rgba(0,0,0,0.7);
  animation: toastIn 0.35s cubic-bezier(0.22,1,0.36,1) forwards, toastOut 0.35s ease forwards 3.6s;
}

@keyframes toastIn { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; opacity: 1; }
}

.toast-icon {
  width: 34px; height: 34px; border-radius: 8px; flex: 0 0 auto;
  background: linear-gradient(160deg, #e6c988, #a97f36);
  display: flex; align-items: center; justify-content: center;
}
.toast-body { flex: 1; min-width: 0; }
.toast-app-row {
  display: flex; justify-content: space-between; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px;
}
.toast-title { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
.toast-text { font-size: 12px; color: #c9bd9e; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---- dev panel ---- */
.devpanel {
  position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom));
  max-width: 496px; margin: 0 auto;
  background: rgba(12,10,6,0.96); backdrop-filter: blur(10px);
  border: 1px dashed #6b5f2a; border-radius: 10px; z-index: 40;
}

.devpanel-toggle {
  width: 100%; background: transparent; border: none; color: var(--gold);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 10px 14px; text-align: left;
}

.devpanel-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.devpanel.collapsed .devpanel-body { display: none; }

.devpanel-hint { font-size: 11px; color: var(--muted-dim); margin: 0 0 4px; }

.devpanel-row { display: flex; gap: 8px; }
.devpanel-row button {
  flex: 1; background: var(--surface); border: 1px solid var(--rule); color: var(--ink);
  font-size: 11.5px; padding: 9px 8px; border-radius: 6px;
}
.devpanel-row button:active { border-color: var(--gold); }

/* ---- language overlay ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(5,4,2,0.72);
  display: flex; align-items: flex-end; z-index: 60;
}
.overlay[hidden] { display: none; }
.overlay-card {
  width: 100%; background: var(--bg); border-top: 1px solid var(--rule);
  border-radius: 18px 18px 0 0; padding: 22px 20px max(22px, env(safe-area-inset-bottom));
}

@media (min-width: 640px) {
  .screen { align-items: center; }
  .disclaimer-stage, .dashboard-stage { max-width: 460px; }
}
