/* Gold & Silver Bot — iOS-style "liquid glass" interface.
   Layout: large-title pages over a soft metal-tinted backdrop; floating glass tab bar on phones,
   glass sidebar on desktop. */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --bg: #f2f2f7;
  --bg-glow-1: rgba(214, 170, 60, 0.30);
  --bg-glow-2: rgba(150, 160, 178, 0.32);
  --glass: rgba(255, 255, 255, 0.66);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-edge: rgba(0, 0, 0, 0.06);
  --label: #0b0b0f;
  --label-2: rgba(60, 60, 67, 0.72);
  --label-3: rgba(60, 60, 67, 0.45);
  --separator: rgba(60, 60, 67, 0.14);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-2: rgba(118, 118, 128, 0.20);
  --gold: #b8860b;
  --gold-soft: rgba(212, 160, 23, 0.16);
  --silver: #6e7687;
  --silver-soft: rgba(142, 150, 168, 0.18);
  --tint: #b8860b;
  --green: #248a3d;
  --green-soft: rgba(52, 199, 89, 0.15);
  --red: #d70015;
  --red-soft: rgba(255, 59, 48, 0.13);
  --orange: #c93400;
  --blue: #0066cc;
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.03), 0 8px 30px rgba(31, 31, 45, 0.08);
  --radius: 26px;
  --radius-sm: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000;
    --bg-glow-1: rgba(214, 170, 60, 0.20);
    --bg-glow-2: rgba(120, 132, 155, 0.22);
    --glass: rgba(30, 30, 34, 0.62);
    --glass-strong: rgba(38, 38, 44, 0.86);
    --glass-border: rgba(255, 255, 255, 0.10);
    --glass-edge: rgba(255, 255, 255, 0.06);
    --label: #f5f5f7;
    --label-2: rgba(235, 235, 245, 0.68);
    --label-3: rgba(235, 235, 245, 0.38);
    --separator: rgba(84, 84, 88, 0.55);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.34);
    --gold: #f2c14e;
    --gold-soft: rgba(242, 193, 78, 0.16);
    --silver: #b4bccb;
    --silver-soft: rgba(180, 188, 203, 0.16);
    --tint: #f2c14e;
    --green: #30d158;
    --green-soft: rgba(48, 209, 88, 0.16);
    --red: #ff453a;
    --red-soft: rgba(255, 69, 58, 0.16);
    --orange: #ff9f0a;
    --blue: #64d2ff;
    --shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 10px 40px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000;
  --bg-glow-1: rgba(214, 170, 60, 0.20);
  --bg-glow-2: rgba(120, 132, 155, 0.22);
  --glass: rgba(30, 30, 34, 0.62);
  --glass-strong: rgba(38, 38, 44, 0.86);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-edge: rgba(255, 255, 255, 0.06);
  --label: #f5f5f7;
  --label-2: rgba(235, 235, 245, 0.68);
  --label-3: rgba(235, 235, 245, 0.38);
  --separator: rgba(84, 84, 88, 0.55);
  --fill: rgba(118, 118, 128, 0.24);
  --fill-2: rgba(118, 118, 128, 0.34);
  --gold: #f2c14e;
  --gold-soft: rgba(242, 193, 78, 0.16);
  --silver: #b4bccb;
  --silver-soft: rgba(180, 188, 203, 0.16);
  --tint: #f2c14e;
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.16);
  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.16);
  --orange: #ff9f0a;
  --blue: #64d2ff;
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 10px 40px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.35;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60vmax 50vmax at 0% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(55vmax 45vmax at 110% 15%, var(--bg-glow-2), transparent 60%),
    radial-gradient(50vmax 40vmax at 40% 120%, var(--bg-glow-1), transparent 65%),
    var(--bg);
}
a { color: var(--tint); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; border-radius: 10px; }

/* ---------- glass ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border: 0.5px solid var(--glass-border);
  box-shadow: var(--shadow), inset 0 0.5px 0 var(--glass-border);
}

/* ---------- app frame ---------- */
#app {
  min-height: 100vh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
}
.page {
  max-width: 760px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 8px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: page-in 0.32s cubic-bezier(.2, .8, .2, 1);
}
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } * { transition: none !important; } }

.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(48px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: flex-end;
  transition: background 0.2s, border-color 0.2s;
  border-bottom: 0.5px solid transparent;
}
.navbar.scrolled {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border-bottom-color: var(--separator);
}
.navbar-inner {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-left, 0px)) 10px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.nav-title { font-size: 17px; font-weight: 600; opacity: 0; transition: opacity 0.2s; text-align: center; white-space: nowrap; }
.navbar.scrolled .nav-title { opacity: 1; }
.nav-left { justify-self: start; display: flex; gap: 6px; }
.nav-right { justify-self: end; display: flex; gap: 6px; }
.nav-btn {
  border: 0;
  background: var(--fill);
  height: 34px;
  min-width: 34px;
  padding: 0 12px;
  border-radius: 17px;
  color: var(--tint);
  font-weight: 600;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.nav-btn svg { width: 18px; height: 18px; }
.nav-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.large-title { padding: 2px 4px 0; }
.large-title h1 { font-size: 34px; line-height: 41px; letter-spacing: 0.37px; font-weight: 700; margin: 0; text-wrap: balance; }
.large-title p { margin: 4px 0 0; color: var(--label-2); font-size: 15px; }

/* ---------- tab bar (phone) / sidebar (desktop) ---------- */
.tabbar {
  position: fixed;
  z-index: 30;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 2px;
  padding: 6px;
  border-radius: 34px;
  width: min(440px, calc(100% - 24px));
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 26px;
  padding: 7px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--label-2);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, transform 0.15s;
  position: relative;
}
.tab svg { width: 24px; height: 24px; }
.tab:active { transform: scale(0.94); }
.tab.active { color: var(--tint); background: var(--fill); }
.tab .badge {
  position: absolute; top: 3px; left: calc(50% + 6px);
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 11px; line-height: 17px; text-align: center;
}
.brand { display: none; }

@media (min-width: 960px) {
  #app { padding-left: 260px; padding-bottom: 40px; }
  .tabbar {
    left: 16px; top: 16px; bottom: 16px; transform: none;
    width: 228px; flex-direction: column; border-radius: 28px; padding: 18px 12px; gap: 4px;
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 17px; }
  .brand img { width: 34px; height: 34px; border-radius: 9px; }
  .tab { flex: 0 0 auto; flex-direction: row; gap: 12px; font-size: 15px; padding: 10px 14px; border-radius: 14px; justify-content: flex-start; }
  .tab svg { width: 22px; height: 22px; }
  .tab .badge { position: static; margin-left: auto; }
  .page { max-width: 1060px; }
  .navbar-inner { max-width: 1060px; }
}

/* ---------- sections, cards, lists ---------- */
.section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px; gap: 12px; }
.section-head h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 0.35px; }
.section-head .sub { color: var(--label-2); font-size: 14px; }
.footnote { color: var(--label-2); font-size: 13px; padding: 0 4px; margin: 0; line-height: 1.45; }

.card { border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card.tap { cursor: pointer; transition: transform 0.18s cubic-bezier(.2,.8,.2,1); }
.card.tap:active { transform: scale(0.985); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 12px; }

.strat-top { display: flex; align-items: flex-start; gap: 12px; }
.metal-icon {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; font-weight: 800; font-size: 15px; letter-spacing: 0.3px;
  color: #3b2b00; background: linear-gradient(145deg, #ffe08a, #d4a017 55%, #9c7409);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 2px 8px rgba(156,116,9,.35);
}
.metal-icon.silver { color: #22252b; background: linear-gradient(145deg, #ffffff, #c4cad6 55%, #8a93a5); box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 2px 8px rgba(90,100,120,.3); }
.strat-name { font-size: 17px; font-weight: 600; line-height: 1.25; }
.strat-meta { color: var(--label-2); font-size: 14px; margin-top: 2px; }
.strat-top .pill { margin-left: auto; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border-radius: 13px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.long { color: var(--green); background: var(--green-soft); }
.pill.long .dot { box-shadow: 0 0 0 3px var(--green-soft); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }
.pill.flat { color: var(--label-2); background: var(--fill); }
.pill.gold { color: var(--gold); background: var(--gold-soft); }
.pill.silver { color: var(--silver); background: var(--silver-soft); }
.pill.red { color: var(--red); background: var(--red-soft); }
.pill.small { height: 22px; font-size: 12px; padding: 0 9px; }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 12px 14px; }
.kv .k { color: var(--label-2); font-size: 12.5px; font-weight: 500; text-transform: none; }
.kv .v { font-size: 19px; font-weight: 600; margin-top: 1px; letter-spacing: -0.2px; }
.kv .v.big { font-size: 26px; font-weight: 700; }
.kv .s { color: var(--label-2); font-size: 12.5px; margin-top: 1px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--label-2); }

.meter { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; position: relative; }
.meter > span { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--tint); }

.callout { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14.5px; display: flex; gap: 10px; align-items: flex-start; line-height: 1.4; }
.callout.warn { background: rgba(255, 159, 10, 0.15); color: var(--label); }
.callout.err { background: var(--red-soft); }
.callout.ok { background: var(--green-soft); }
.callout svg { flex: 0 0 auto; width: 20px; height: 20px; margin-top: 1px; }

/* inset grouped list (Settings style) */
.list { border-radius: var(--radius); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 10px 16px;
  position: relative;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 0.5px; background: var(--separator); }
.row .label { flex: 1 1 52%; min-width: 0; }
.row .label small { display: block; color: var(--label-2); font-size: 13px; margin-top: 1px; }
.row .value { color: var(--label-2); text-align: right; min-width: 0; flex: 0 1 auto; max-width: 56%; font-size: 15px; }
.row input[type="text"], .row input[type="password"], .row input[type="number"], .row select {
  border: 0; background: transparent; text-align: right; min-width: 0; width: 100%; max-width: 280px;
  padding: 6px 0; color: var(--label-2); font-size: 16px;
}
.row input:focus { outline: none; color: var(--label); }
.row.stack { flex-direction: column; align-items: stretch; gap: 6px; }
.row.stack input, .row.stack textarea {
  text-align: left; max-width: none; border-radius: 12px; background: var(--fill); padding: 11px 12px; color: var(--label); border: 0;
  font-family: var(--mono); font-size: 14px;
}
.row.tap { cursor: pointer; }
.row.tap:active { background: var(--fill); }
.chev { color: var(--label-3); width: 14px; height: 14px; flex: 0 0 auto; }

/* switch */
.switch { position: relative; width: 51px; height: 31px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--fill-2); transition: background 0.25s; }
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform 0.25s cubic-bezier(.3,.7,.4,1.2);
}
.switch input:checked + span { background: #34c759; }
.switch input:checked + span::after { transform: translateX(20px); }

/* buttons */
.btn {
  border: 0; border-radius: 14px; min-height: 50px; padding: 0 18px; font-weight: 600; font-size: 17px; cursor: pointer;
  background: var(--tint); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.15s, opacity 0.2s;
}
:root[data-theme="dark"] .btn:not(.secondary):not(.danger) { color: #1c1400; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn:not(.secondary):not(.danger) { color: #1c1400; } }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; }
.btn.secondary { background: var(--fill); color: var(--tint); }
.btn.danger { background: var(--fill); color: var(--red); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 160px; }

/* segmented control */
.seg { display: inline-flex; background: var(--fill); border-radius: 10px; padding: 2px; gap: 2px; width: 100%; }
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 7px 10px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--label);
}
.seg button.on { background: var(--glass-strong); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 0 0 0.5px rgba(0,0,0,.04); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 4px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 0; white-space: nowrap; background: var(--glass); border: 0.5px solid var(--glass-border); padding: 7px 13px; border-radius: 18px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--label-2); }
.chip.on { background: var(--label); color: var(--bg); }

/* trades list */
.trade { padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; cursor: pointer; position: relative; }
.trade + .trade::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 0.5px; background: var(--separator); }
.trade .t1 { font-weight: 600; font-size: 15.5px; min-width: 0; }
.trade .t2 { color: var(--label-2); font-size: 13.5px; min-width: 0; }
.trade .pnl { font-weight: 700; font-size: 17px; text-align: right; }
.trade .r { color: var(--label-2); font-size: 13px; text-align: right; }
.trade .more { grid-column: 1 / -1; display: none; padding-top: 10px; }
.trade.open .more { display: block; }
.month-label { padding: 14px 4px 6px; color: var(--label-2); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
table.data th, table.data td { padding: 8px 10px; text-align: right; border-bottom: 0.5px solid var(--separator); }
table.data th { color: var(--label-2); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--glass-strong); }
table.data th:first-child, table.data td:first-child { text-align: left; position: sticky; left: 0; background: var(--glass-strong); }
table.data tr.hl td { background: var(--gold-soft); }
table.data td.flip { color: var(--green); font-weight: 700; }

.chart { height: 360px; border-radius: var(--radius-sm); overflow: hidden; }
@media (max-width: 600px) { .chart { height: 300px; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--label-2); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* docs */
.doc { line-height: 1.6; font-size: 16.5px; }
.doc h2 { font-size: 24px; margin: 8px 0 4px; letter-spacing: 0.2px; }
.doc h3 { font-size: 18px; margin: 18px 0 2px; }
.doc p { margin: 8px 0; max-width: 70ch; }
.doc ul, .doc ol { padding-left: 22px; margin: 8px 0; max-width: 70ch; }
.doc li { margin: 4px 0; }
.doc code, .doc .f { font-family: var(--mono); font-size: 0.88em; background: var(--fill); padding: 1px 6px; border-radius: 6px; }
.doc pre { font-family: var(--mono); font-size: 13.5px; background: var(--fill); padding: 12px 14px; border-radius: 14px; overflow-x: auto; line-height: 1.5; }
.doc .formula { font-family: var(--mono); font-size: 14.5px; background: var(--gold-soft); border-radius: 14px; padding: 12px 14px; margin: 10px 0; overflow-x: auto; white-space: pre; line-height: 1.6; }
.doc .note { border-radius: 14px; background: var(--fill); padding: 10px 14px; font-size: 15px; }
.toc { display: flex; flex-wrap: wrap; gap: 8px; }
.toc a { background: var(--glass); border: 0.5px solid var(--glass-border); padding: 7px 12px; border-radius: 16px; font-size: 14px; font-weight: 600; }

/* timeline diagram */
.timeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.timeline .step { border-radius: 18px; padding: 12px 14px; background: var(--fill); font-size: 14px; }
.timeline .step b { display: block; font-size: 13px; color: var(--tint); margin-bottom: 3px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .card { width: min(380px, 100%); align-items: stretch; text-align: center; padding: 28px 22px; }
.login img { width: 76px; height: 76px; border-radius: 18px; margin: 0 auto; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.login input { border: 0; border-radius: 14px; background: var(--fill); padding: 14px; font-size: 17px; text-align: center; }

/* toast */
.toast {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -140%);
  z-index: 50; border-radius: 22px; padding: 11px 18px; font-size: 15px; font-weight: 600; max-width: calc(100% - 32px);
  transition: transform 0.35s cubic-bezier(.2,.9,.3,1.2);
}
.toast.show { transform: translate(-50%, 0); }

.skeleton { border-radius: var(--radius); height: 150px; background: linear-gradient(90deg, var(--fill), var(--fill-2), var(--fill)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { text-align: center; color: var(--label-2); padding: 34px 20px; }
.empty svg { width: 44px; height: 44px; color: var(--label-3); }
.card.doc { display: block; }
.card.doc > :first-child { margin-top: 0; }
.doc .timeline, .doc .table-wrap { margin: 12px 0; }

/* charts */
.mini-chart { height: 170px; margin: 0 -6px; border-radius: 14px; overflow: hidden; pointer-events: none; }
.chart { height: 440px; }
@media (max-width: 600px) { .chart { height: 380px; } }
.chart-readout {
  position: absolute; top: 6px; left: 8px; z-index: 3; pointer-events: none;
  font-size: 12px; line-height: 1.45; padding: 6px 9px; border-radius: 12px;
  background: var(--glass-strong); border: 0.5px solid var(--glass-border); color: var(--label);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); max-width: calc(100% - 90px);
}
.chart-readout b { font-weight: 650; }
#range { max-width: 320px; }
