/* Marketbar Remote
   Palette lifted from Barista/UI/Theme.swift so the phone and the menu bar
   read as one product. Sized for touch, not for a shrunken desktop popover. */

:root {
  --bg: #0e0c12;
  --card: rgba(255, 255, 255, 0.045);
  --card-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.18);
  --input-bg: rgba(0, 0, 0, 0.3);
  --divider: rgba(255, 255, 255, 0.05);

  --text: rgba(255, 255, 255, 0.96);
  --text-2: rgba(255, 255, 255, 0.86);
  --muted: rgba(255, 255, 255, 0.54);
  --faint: rgba(255, 255, 255, 0.36);
  --ghost: rgba(255, 255, 255, 0.22);

  --amber: #f5a73b;
  --amber-bright: #f8b84e;
  --cyan: #5de0e6;
  --green: #7cd8a0;
  --red: #f08a8a;
  --yellow: #f2d159;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;

  /* Home-screen PWAs sit under the notch and over the home indicator. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  /* Stops iOS bouncing the whole document while a list scrolls inside it. */
  overscroll-behavior-y: none;
}

body {
  padding-top: var(--safe-top);
  min-height: 100vh;
  min-height: 100dvh;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { background: none; border: none; padding: 0; cursor: pointer; }

/* Inputs must be at least 16px or iOS zooms the page when they focus. */
input, select { font-size: 16px; }

.hidden { display: none !important; }

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

#screens {
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
}

.screen { display: none; }
.screen.active { display: block; }

/* ---------- Header ---------- */

header.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 10px;
  background: rgba(14, 12, 18, 0.86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--divider);
}

.bar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
  transition: background 0.3s;
}
.status-dot.stale { background: var(--yellow); }
.status-dot.offline { background: var(--red); }

.session {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.session.open { color: var(--green); border-color: rgba(124, 216, 160, 0.3); }
.session.preMarket, .session.afterHours { color: var(--amber); border-color: rgba(245, 167, 59, 0.3); }

/* ---------- Cards & rows ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin: 12px 16px;
  overflow: hidden;
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 14px 16px 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  /* Touch targets stay comfortable even when the content is one line. */
  min-height: 60px;
}
.row:last-child { border-bottom: none; }
.row:active { background: var(--card-hover); }

.row-main { flex: 1; min-width: 0; }

.symbol {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-right { text-align: right; flex: none; }

.price {
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.change {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  margin-top: 3px;
}

.up { color: var(--green); }
.down { color: var(--red); }
.flat { color: var(--muted); }

.spark { flex: none; width: 64px; height: 28px; opacity: 0.9; }

.stale-tag {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--yellow);
  letter-spacing: 0.06em;
}

.ext-tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  border: 1px solid rgba(245, 167, 59, 0.3);
  border-radius: 4px;
  padding: 1px 4px;
  margin-left: 6px;
  vertical-align: 1px;
}

/* ---------- Hero (portfolio total) ---------- */

.hero { padding: 22px 16px 18px; text-align: center; }

.hero-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.hero-value {
  font-family: var(--mono);
  font-size: 38px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin: 6px 0 4px;
}

.hero-change {
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.hero-ext {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

/* ---------- Chips ---------- */

.chips {
  display: flex;
  gap: 8px;
  padding: 4px 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
}
.chip.active {
  color: var(--bg);
  background: var(--amber);
  border-color: var(--amber);
  font-weight: 600;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--divider);
}

.stat { background: var(--bg); padding: 12px 16px; }

.stat-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.stat-value {
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

/* ---------- Forms ---------- */

.field {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
}

input[type="text"], input[type="number"], input[type="date"], select {
  flex: 1;
  min-width: 0;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--mono);
  outline: none;
}
input:focus, select:focus { border-color: var(--amber); }
input::placeholder { color: var(--ghost); }

.btn {
  flex: none;
  background: var(--amber);
  color: #16120a;
  font-weight: 600;
  border-radius: 10px;
  padding: 12px 18px;
}
.btn:active { background: var(--amber-bright); }
.btn:disabled { opacity: 0.4; }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  font-weight: 500;
}
.btn.danger { background: transparent; border: 1px solid rgba(240,138,138,0.4); color: var(--red); }
.btn.full { width: 100%; }

.seg {
  display: flex;
  gap: 0;
  margin: 0 16px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.seg button {
  flex: 1;
  padding: 11px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.seg button.active { background: var(--card-hover); color: var(--text); }

/* ---------- Bottom nav ---------- */

nav.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  background: rgba(14, 12, 18, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--divider);
  padding-bottom: var(--safe-bottom);
}

nav.tabs button {
  flex: 1;
  height: var(--nav-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.04em;
}
nav.tabs button.active { color: var(--amber); }
nav.tabs svg { width: 21px; height: 21px; stroke-width: 1.7; }

/* ---------- Sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-height: 88vh;
  overflow-y: auto;
  background: #16131c;
  border-top: 1px solid var(--border-strong);
  border-radius: 20px 20px 0 0;
  padding-bottom: calc(var(--safe-bottom) + 20px);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
.sheet.open { transform: translateY(0); }

.grabber {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--ghost);
  margin: 10px auto 4px;
}

.sheet h2 {
  margin: 8px 16px 4px;
  font-size: 20px;
  font-weight: 600;
}

/* ---------- Chart ---------- */

.chart-wrap { padding: 8px 16px 16px; }
canvas.chart { width: 100%; height: 180px; display: block; }

/* ---------- States ---------- */

.empty {
  padding: 48px 32px;
  text-align: center;
  color: var(--faint);
  font-size: 14px;
  line-height: 1.6;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  z-index: 50;
  padding: 13px 16px;
  border-radius: 12px;
  background: #241f2c;
  border: 1px solid var(--border-strong);
  font-size: 14px;
  transform: translateY(140%);
  /* The bottom offset means a self-height translate does not clear the screen,
     so visibility is what actually takes it out of view. */
  opacity: 0;
  visibility: hidden;
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.2s, visibility 0.28s;
}
.toast.show { transform: translateY(0); opacity: 1; visibility: visible; }
.toast.bad { border-color: rgba(240, 138, 138, 0.5); color: var(--red); }

/* ---------- Pairing ---------- */

.pair {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}
.pair h1 { font-size: 26px; margin: 0 0 8px; }
.pair p { color: var(--muted); font-size: 15px; line-height: 1.6; margin: 0 0 28px; max-width: 300px; }

/* Element-qualified so it outranks the `input[type="text"]` rule above, whose
   `flex: 1` would otherwise stretch this box down the whole column. */
input.code-input {
  flex: none;
  width: 100%;
  max-width: 260px;
  text-align: center;
  font-family: var(--mono);
  font-size: 30px !important;
  letter-spacing: 0.28em;
  padding: 16px 12px;
  text-indent: 0.28em;
}

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