/* Aurum Live — one fixed screen, built for phones.
   Layout: a single column that always fits the screen exactly; the chart takes whatever height is left. */
:root {
  --bg: #0f0e0b;
  --bg-glow: #2a2213;
  --surface: #181611;
  --surface-2: #211e17;
  --line: #2e2a21;
  --text: #f2ecdf;
  --muted: #9b927f;
  --dim: #645d4f;
  --gold: #e4c07a;
  --gold-deep: #b98a3a;
  --up: #4cc493;
  --down: #f06d5e;
  --warn: #f2a541;

  --f-display: "Unbounded", "Manrope", system-ui, sans-serif;
  --f-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r: 14px;
  --gap: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 500 14px/1.35 var(--f-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
body {
  background:
    radial-gradient(120% 55% at 50% -12%, var(--bg-glow) 0%, transparent 60%),
    var(--bg);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0; }
[hidden] { display: none !important; }

/* ---------- App frame ---------- */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px calc(env(safe-area-inset-bottom, 0px) + 12px);
  transition: filter .35s ease;
}
body.locked #app { filter: blur(14px) saturate(.6); pointer-events: none; }

/* Session timer line */
.timer {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 0; right: 0;
  height: 3px;
  background: rgba(228, 192, 122, .12);
  z-index: 5;
}
.timer i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
  box-shadow: 0 0 10px rgba(228, 192, 122, .55);
  transition: transform 1s linear, background .4s;
}
.timer.low i { background: linear-gradient(90deg, #c4561f, var(--warn)); box-shadow: 0 0 10px rgba(242, 165, 65, .6); }

/* ---------- Header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 2px; }
.brand { display: flex; align-items: center; gap: 8px; font: 500 15px var(--f-display); letter-spacing: .02em; }
.brand b { font-weight: 700; color: var(--gold); margin-left: 3px; }
.ingot { width: 26px; height: 16px; }
.status { display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px 5px 8px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
.pill em { font-style: normal; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.pill.live { color: var(--up); }
.pill.live i { background: var(--up); animation: beat 1.6s ease-out infinite; }
.pill.closed { color: var(--warn); }
.pill.closed i { background: var(--warn); }
.pill.err { color: var(--down); }
.pill.err i { background: var(--down); }
@keyframes beat { 0% { box-shadow: 0 0 0 0 rgba(76, 196, 147, .6); } 70%, 100% { box-shadow: 0 0 0 7px rgba(76, 196, 147, 0); } }
.clock {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: transparent;
  font: 500 12px var(--f-num);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.clock svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 1.5; fill: none; }
.clock.low { color: var(--warn); border-color: rgba(242, 165, 65, .4); }

/* ---------- Hero price ---------- */
.hero { display: grid; gap: 4px; }
.hero-label { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.hero-label span { color: var(--dim); font-weight: 600; letter-spacing: .06em; text-transform: none; }
.hero-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.hero-price {
  font: 600 clamp(36px, 11.5vw, 50px)/1 var(--f-num);
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fbefcf 0%, var(--gold) 55%, var(--gold-deep) 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  white-space: nowrap;
}
.hero-price .dec { font-size: .55em; letter-spacing: -.01em; }
.hero-price.up, .hero-price.down { transition: none; }
.hero-price.up { background: linear-gradient(180deg, #d9fbea, var(--up)); -webkit-background-clip: text; background-clip: text; }
.hero-price.down { background: linear-gradient(180deg, #ffe0db, var(--down)); -webkit-background-clip: text; background-clip: text; }
.chg {
  flex: none;
  font: 600 12.5px var(--f-num);
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chg.up { color: var(--up); background: rgba(76, 196, 147, .1); }
.chg.down { color: var(--down); background: rgba(240, 109, 94, .1); }
.quote-line { display: flex; gap: 12px; font-size: 11.5px; color: var(--dim); align-items: baseline; }
.quote-line b { font: 500 12px var(--f-num); color: var(--muted); margin-left: 3px; font-variant-numeric: tabular-nums; }
.tick { margin-left: auto; font: 500 11px var(--f-num); color: var(--dim); }

/* ---------- Price board ---------- */
.board {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  column-gap: 10px;
  row-gap: 0;
  padding: 4px 12px 8px;
  border-radius: var(--r);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
}
.board > div { min-width: 0; }
.b-head {
  padding: 6px 0 5px;
  text-align: right;
  font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold);
  border-bottom: 1px solid var(--line);
}
.b-head small { display: block; font: 500 9.5px var(--f-num); letter-spacing: 0; color: var(--dim); text-transform: none; margin-top: 1px; }
.b-cur {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 0;
  font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em;
  border-bottom: 1px solid var(--line);
}
.sym {
  display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 6px;
  background: rgba(228, 192, 122, .1);
  color: var(--gold);
  font: 600 11px var(--f-num);
}
.b-val {
  padding: 8px 0;
  text-align: right;
  font: 500 14.5px var(--f-num);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--line);
  transition: color .7s ease;
}
.b-val small { display: block; font: 500 9.5px var(--f-num); color: var(--dim); margin-top: 1px; }
.b-val.up { color: var(--up); transition: none; }
.b-val.down { color: var(--down); transition: none; }
.board > div:nth-last-child(2), .board > div:nth-last-child(3), .board > div:nth-last-child(4) { border-bottom: 0; }
.b-foot {
  grid-column: 1 / -1;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  font: 500 10px var(--f-num);
  color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Chart ---------- */
.chart { flex: 1 1 auto; min-height: 64px; display: flex; flex-direction: column; gap: 4px; }
.chart-meta { display: flex; justify-content: space-between; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.chart-meta b { color: var(--muted); font-weight: 700; }
.legend { display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 10px; height: 2px; border-radius: 2px; }
.l-price { background: var(--gold); }
.l-ema { background: var(--muted); opacity: .6; margin-left: 4px; }
#chart { flex: 1 1 auto; width: 100%; min-height: 0; display: block; }

/* ---------- Signal desk ---------- */
.desk {
  flex: none;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
}
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.tabs button {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 4px 9px;
  border: 0; background: transparent;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--dim);
}
.tabs button[aria-selected="true"] { color: var(--gold); }
.tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; left: 22%; right: 22%; bottom: -1px; height: 2px; border-radius: 2px; background: var(--gold);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.count { font: 600 10px var(--f-num); font-style: normal; padding: 1px 5px; border-radius: 99px; background: rgba(228, 192, 122, .15); color: var(--gold); }
.panel { padding: 11px 12px 12px; height: 118px; display: flex; flex-direction: column; gap: 10px; }

.sig { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.sig-dir {
  flex: none;
  min-width: 92px;
  padding: 8px 10px;
  border-radius: 10px;
  text-align: center;
  font: 700 19px/1 var(--f-display);
  letter-spacing: .04em;
  background: var(--surface-2);
  color: var(--muted);
}
.sig-dir[data-dir="BUY"] { color: #062b1c; background: linear-gradient(180deg, #6fe0b0, var(--up)); }
.sig-dir[data-dir="SELL"] { color: #350b06; background: linear-gradient(180deg, #ff9a8c, var(--down)); }
.sig-dir[data-dir="WAIT"] { color: var(--gold); background: rgba(228, 192, 122, .12); }
.sig-dir[data-dir="CLOSED"] { color: var(--warn); background: rgba(242, 165, 65, .1); font-size: 14px; padding: 11px 10px; }
.sig-dir.pop { animation: pop .5s ease; }
@keyframes pop { 30% { transform: scale(1.08); } }
.sig-side { flex: 1; min-width: 0; display: grid; gap: 6px; }
.meter { height: 5px; border-radius: 9px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: 9px; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); transition: width .6s ease; }
.sig-note { font-size: 11.5px; color: var(--muted); line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sig-time { font: 500 10.5px var(--f-num); color: var(--dim); }

.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.levels div { padding: 6px 7px; border-radius: 8px; background: var(--surface-2); min-width: 0; }
.levels span { display: block; font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.levels b { display: block; font: 500 12.5px var(--f-num); font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.levels b.up { color: var(--up); }
.levels b.dn { color: var(--down); }

.alert-form { display: flex; gap: 8px; }
.alert-form input {
  flex: 1; min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font: 500 14px var(--f-num);
  -webkit-user-select: text; user-select: text;
}
.alert-form input::placeholder { color: var(--dim); font-family: var(--f-body); font-size: 12.5px; }
.alert-form button {
  padding: 0 16px;
  border: 0; border-radius: 10px;
  background: linear-gradient(180deg, #f2d496, var(--gold-deep));
  color: #2b1d05;
  font-weight: 700; font-size: 13px;
}
.alert-list { display: flex; flex-wrap: wrap; gap: 6px; overflow: hidden; max-height: 58px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font: 500 12px var(--f-num);
}
.chip .arr { color: var(--gold); font-size: 11px; }
.chip button { border: 0; background: transparent; color: var(--dim); width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; padding: 0; font-size: 13px; line-height: 1; }
.alert-hint { font-size: 11px; color: var(--dim); }

/* ---------- Lock screen ---------- */
.lock {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: 20px 16px;
  background: rgba(10, 9, 7, .55);
  opacity: 0; visibility: hidden;
  transition: opacity .3s ease, visibility 0s linear .3s;
}
body.locked .lock { opacity: 1; visibility: visible; transition: opacity .3s ease; }
.lock-card { width: min(320px, 100%); display: grid; justify-items: center; gap: 10px; }
.lock-ingot { width: 64px; height: 40px; filter: drop-shadow(0 8px 24px rgba(228, 192, 122, .35)); }
.lock h1 { margin: 6px 0 0; font: 700 22px var(--f-display); letter-spacing: .02em; }
.lock p { margin: 0; color: var(--muted); font-size: 13px; }
#lockMsg.err { color: var(--down); }
.dots { display: flex; gap: 12px; height: 18px; align-items: center; margin: 6px 0 4px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--gold-deep); }
.dots i.on { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 10px rgba(228, 192, 122, .5); }
.dots.shake { animation: shake .4s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; margin-top: 6px; }
.pad button {
  height: clamp(52px, 8.5vh, 64px);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  font: 500 22px var(--f-num);
  transition: transform .08s ease, background .15s;
}
.pad button:active { transform: scale(.95); background: var(--surface-2); }
.pad .soft { background: transparent; border-color: transparent; }
.pad .soft svg { width: 26px; height: 26px; stroke: var(--muted); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.pad .go { font: 700 13px var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: #2b1d05; border: 0; background: linear-gradient(180deg, #f2d496, var(--gold-deep)); }
.pad .go:disabled { opacity: .5; }
.lock-foot { font-size: 11px !important; color: var(--dim) !important; margin-top: 6px !important; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 30;
  left: 50%; top: calc(env(safe-area-inset-top, 0px) + 14px);
  transform: translateX(-50%);
  width: min(440px, calc(100% - 28px));
  padding: 12px 14px;
  border-radius: 12px;
  background: #2a2417;
  border: 1px solid var(--gold-deep);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  font-weight: 600; font-size: 13px;
  animation: drop .35s ease;
}
@keyframes drop { from { transform: translate(-50%, -20px); opacity: 0; } }

/* ---------- Short screens (e.g. iPhone SE with browser bars) ---------- */
@media (max-height: 640px) {
  :root { --gap: 7px; }
  #app { padding-top: calc(env(safe-area-inset-top, 0px) + 9px); padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); }
  .hero-price { font-size: clamp(30px, 9.5vw, 40px); }
  .b-cur, .b-val { padding: 5px 0; }
  .b-val { font-size: 13.5px; }
  .panel { height: 112px; padding: 9px 11px 10px; gap: 8px; }
  .tabs button { padding: 8px 4px 7px; }
  .sig-dir { font-size: 16px; min-width: 80px; }
  .quote-line { display: none; }
}
@media (max-width: 350px) {
  .b-val { font-size: 12.5px; }
  .levels b { font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
