:root {
  --bg: #100e09; --card: #1b1811; --card2: #242016; --line: #342e20; --text: #f3ecdc; --muted: #a59b84;
  --gold: #e3b341; --gold2: #f6d77a; --green: #5fd08a; --red: #f0705f; --amber: #f0b35f; --blue: #7fb4ea;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.hidden { display: none !important; }
h1 { font-size: 28px; margin: 6px 0 0; }
h2 { font-size: 16px; margin: 0; letter-spacing: .01em; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.err { color: var(--red); font-size: 14px; min-height: 1em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

header { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(16, 14, 9, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--gold2); }
.brand img { width: 26px; height: 26px; }
.headRight { display: flex; align-items: center; gap: 10px; }
.price { font-variant-numeric: tabular-nums; font-weight: 600; }
.pill { padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--card2); color: var(--muted); white-space: nowrap; }
.pill.good { background: rgba(95, 208, 138, .16); color: var(--green); }
.pill.warn { background: rgba(240, 179, 95, .16); color: var(--amber); }
.pill.bad { background: rgba(240, 112, 95, .16); color: var(--red); }

main { max-width: 720px; margin: 0 auto; padding: 14px 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.cardHead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.tag { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--card2); color: var(--muted); }
.tag.real { background: rgba(240, 112, 95, .18); color: var(--red); }
.tag.demo, .tag.practice { background: rgba(127, 180, 234, .16); color: var(--blue); }
.tag.ok { background: rgba(95, 208, 138, .16); color: var(--green); }
.status .statusMsg { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.status .row { flex-direction: column; align-items: stretch; }
.banner { border-color: var(--gold); background: rgba(227, 179, 65, .08); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; gap: 6px 14px; margin: 8px 0; }
.rowBetween { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grow { flex: 1; }
.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
@media (min-width: 560px) { .grid4 { grid-template-columns: repeat(4, 1fr); } }
.grid4 label, label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.grid4 b { font-size: 18px; font-variant-numeric: tabular-nums; }
.up { color: var(--green); } .down { color: var(--red); }

.btn { appearance: none; border: 1px solid var(--line); background: var(--card2); color: var(--text); border-radius: 12px; padding: 12px 16px;
  font: inherit; font-weight: 650; min-height: 46px; cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1c1503; }
.btn.danger { background: transparent; border-color: rgba(240, 112, 95, .6); color: var(--red); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 38px; padding: 8px 12px; font-size: 14px; margin-top: 10px; }
.btn.on { background: rgba(95, 208, 138, .16); border-color: var(--green); color: var(--green); }
.btn[disabled] { opacity: .5; }

input, select, textarea { width: 100%; background: #0c0a06; color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font: inherit; margin: 4px 0 12px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
textarea { resize: vertical; }

.aiSummary { font-size: 16.5px; }
.did { display: flex; flex-direction: column; gap: 6px; }
.did div { background: var(--card2); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
details { margin: 8px 0; } summary { cursor: pointer; color: var(--gold2); font-size: 14px; }
details p { white-space: pre-wrap; font-size: 14.5px; color: var(--muted); }

.pos { border-left: 4px solid var(--line); }
.pos.buy { border-left-color: var(--green); } .pos.sell { border-left-color: var(--red); }
.posTop { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.posTop b { font-size: 17px; } .posPl { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.kv div { background: var(--card2); border-radius: 10px; padding: 8px; }
.kv b { display: block; font-variant-numeric: tabular-nums; }

.feed { display: flex; flex-direction: column; }
.item { padding: 10px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .when { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.item .k { font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: 10.5px; padding: 1px 6px; border-radius: 6px; background: var(--card2); }
.item .k.trade { color: var(--gold2); } .item .k.warn { color: var(--red); } .item .k.learn { color: var(--blue); } .item .k.owner { color: var(--green); }
.item .why { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

.trade { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.tradeTop { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.prose { white-space: pre-wrap; font: inherit; margin: 0; overflow-wrap: anywhere; }
.lesson { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.lesson:first-child { border-top: 0; } .lesson.off { opacity: .45; text-decoration: line-through; }
.lesson button { flex: none; margin-top: 0; }
.settings .set { display: grid; grid-template-columns: 1fr 110px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.settings .set:first-child { border-top: 0; }
.settings .set input { margin: 0; text-align: right; }
.settings .set span { font-size: 14.5px; } .settings .set small { display: block; color: var(--muted); font-size: 12.5px; }
.q { padding: 12px 0; border-top: 1px solid var(--line); } .q:first-child { border-top: 0; }
.q .ans { color: var(--green); }
canvas { width: 100%; margin-top: 14px; }

nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: rgba(20, 17, 11, .97); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
nav button { flex: 1; position: relative; background: none; border: 0; color: var(--muted); font: inherit; font-size: 12px; padding: 6px 2px; min-height: 52px; cursor: pointer; }
nav button i { display: block; font-style: normal; font-size: 19px; line-height: 1.2; }
nav button.on { color: var(--gold2); }
.dot { position: absolute; top: 6px; right: 28%; width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; text-align: center; }
.logo { width: 64px; height: 64px; }
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .65); display: flex; align-items: flex-end; justify-content: center; }
.sheetBody { width: 100%; max-width: 720px; max-height: 88vh; overflow: auto; border-radius: 18px 18px 0 0; margin: 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; background: #f3ecdc; color: #1c1503;
  padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: 90vw; text-align: center; box-shadow: 0 6px 24px rgba(0, 0, 0, .5); }
.toast.bad { background: var(--red); color: #fff; }
