:root {
  --bg: #070707;
  --bg2: #0e0e0e;
  --card: #121212;
  --card2: #181818;
  --border: rgba(255, 107, 0, 0.14);
  --border2: rgba(255, 255, 255, 0.06);
  --orange: #ff6b00;
  --orange2: #ff8533;
  --orange-dim: rgba(255, 107, 0, 0.12);
  --text: #f2f2f2;
  --muted: #7a7a7a;
  --green: #2ecc71;
  --red: #ff4757;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --nav-h: 64px;
  --top-h: 72px;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(255, 107, 0, 0.18), transparent),
    radial-gradient(circle at 100% 100%, rgba(255, 107, 0, 0.06), transparent 40%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
}

.topbar {
  height: var(--top-h);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border2);
  backdrop-filter: blur(12px);
  background: rgba(7, 7, 7, 0.85);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 36px; height: 36px; color: var(--orange); }
.brand-title { font-weight: 700; letter-spacing: 0.04em; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: var(--mono); }

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border2);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s, box-shadow 0.3s;
}

.status-pill.live .dot {
  background: var(--green);
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.6);
}

.views {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(var(--nav-h) + 16px);
  scroll-behavior: smooth;
}

.view { display: none; animation: fadeUp 0.28s ease; }
.view.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-card {
  background: linear-gradient(135deg, var(--card) 0%, var(--card2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.hero-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--orange2);
  margin-bottom: 14px;
  font-weight: 600;
}

.hero-actions { display: flex; gap: 10px; }

.btn-session {
  width: 100%;
  padding: 14px 18px;
}

.btn-session .icon-stop {
  display: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.btn-session.is-stop {
  background: linear-gradient(180deg, #3a3a3a, #222);
  color: var(--text);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.btn-session.is-stop .icon-play { display: none; }
.btn-session.is-stop .icon-stop { display: block; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  user-select: none;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-ui {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}

.toggle-row input:checked + .toggle-ui {
  background: var(--orange-dim);
  border-color: var(--orange);
}

.toggle-row input:checked + .toggle-ui::after {
  transform: translateX(18px);
  background: var(--orange2);
}

.toggle-text {
  font-size: 14px;
  color: var(--text);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.filter-chip {
  border: 1px solid var(--border2);
  background: var(--bg2);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-chip.on {
  border-color: var(--orange);
  background: var(--orange-dim);
  color: var(--orange2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }
.btn svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.btn-ghost svg { fill: none; stroke: currentColor; stroke-width: 2; }

.btn-primary {
  flex: 1;
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--orange2), var(--orange));
  color: #111;
  box-shadow: 0 4px 20px rgba(255, 107, 0, 0.35);
}

.btn-ghost {
  padding: 14px 16px;
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border2);
}

.btn-sm { padding: 10px 14px; font-size: 13px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--orange2);
}

.panel {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.panel-head {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 14px;
}

.muted { color: var(--orange); font-weight: 500; }

.ctrl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.ctrl-row:last-child { border-bottom: none; }

.ctrl-label { font-size: 14px; color: var(--text); }

.ctrl-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg2);
  border-radius: 10px;
  padding: 4px;
  border: 1px solid var(--border2);
}

.ctrl-stepper button {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--orange2);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
}

.ctrl-stepper button:active { background: var(--orange-dim); }

.ctrl-stepper span {
  min-width: 64px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}

.add-row { display: flex; gap: 8px; }

.add-row input {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.add-row input:focus { border-color: var(--orange); }

.hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
}

.hint.ok { color: var(--green); }
.hint.err { color: var(--red); }

.coin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}

.coin-chip {
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  background: var(--bg2);
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.coin-chip.on {
  border-color: var(--orange);
  background: var(--orange-dim);
  color: var(--orange2);
  box-shadow: 0 0 0 1px rgba(255,107,0,0.2);
}

.log-list { display: flex; flex-direction: column; gap: 8px; }

.log-item {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--border2);
  border-radius: 10px;
  padding: 12px;
  animation: fadeUp 0.22s ease;
}

.log-item.win { border-left-color: var(--green); }
.log-item.loss { border-left-color: var(--red); }
.log-item.skip { border-left-color: var(--orange); }

.log-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.log-sym {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
}

.log-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--orange2);
}

.log-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.log-meta strong { color: var(--text); font-weight: 500; }

.pnl-pos { color: var(--green); }
.pnl-neg { color: var(--red); }

.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 13px;
}

.blocked {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--orange2);
  letter-spacing: 0.04em;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  height: var(--nav-h);
  display: flex;
  background: rgba(10, 10, 10, 0.92);
  border-top: 1px solid var(--border2);
  backdrop-filter: blur(16px);
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-btn.active { color: var(--orange2); }

.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
