:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e4e6ea;
  --line-strong: #cfd3d9;
  --text: #15171a;
  --muted: #7a808a;
  --faint: #a3a8b0;
  --accent: #3d6b45;
  --accent-soft: #e8f0e9;
  --green: #3ecf70;
  --red: #e5484d;
  --gray: #9aa0a8;
  --radius: 16px;
  --tabs-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body { min-height: 100vh; font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
#app { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(var(--tabs-h) + 28px); }
h1 { font-size: 22px; line-height: 1.2; margin: 6px 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.lead { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
.card.flush { padding: 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.grow { flex: 1; min-width: 0; }

/* the bar with the back button stays at the top while the page scrolls */
.topbar { display: flex; align-items: center; gap: 10px; margin: -16px -16px 8px; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 10px; position: sticky; top: 0; z-index: 8; background: var(--bg); box-shadow: 0 1px 0 var(--line); }
.back { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; flex: none; }
.back svg { width: 18px; height: 18px; }
.topbar .title { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* switch */
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 14px; background: #d9dce1; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* chips and segmented */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font-size: 14px; cursor: pointer; user-select: none; }
.chip.on { border-color: #222; box-shadow: inset 0 0 0 1px #222; font-weight: 600; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gray); }
.chip .dot.green { background: var(--green); }
.chip .dot.red { background: var(--red); }
.chip[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #eceef1; border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 8px 4px; border-radius: 10px; font: inherit; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.btn { border: 1px solid var(--line-strong); background: #fff; border-radius: 12px; padding: 9px 14px; font: inherit; cursor: pointer; }
.btn.primary { background: #15171a; color: #fff; border-color: #15171a; }
.btn:disabled { opacity: .6; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
input[type="search"], input[type="number"], select { width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 12px; font: inherit; background: #fff; color: var(--text); }
/* numbers are typed in by hand: no up/down arrows */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* lists */
.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.list li:first-child { border-top: 0; }
.list .name { font-weight: 500; }
.general-mark { width: 46px; flex: none; display: flex; justify-content: center; color: #a3a8b0; }
.list .sub { color: var(--muted); font-size: 12.5px; }
.group-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 4px 6px; }
.chev { color: var(--faint); flex: none; }

/* tab bar */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabs-h); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
#tabs .inner { width: 100%; max-width: 640px; display: grid; grid-template-columns: repeat(5, 1fr); }
#tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--faint); text-decoration: none; font-size: 11px; }
#tabs a svg { width: 22px; height: 22px; }
#tabs a.on { color: var(--text); }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 14px); transform: translate(-50%, 20px); background: #15171a; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 10; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: #b3261e; }
#toast.top { top: calc(env(safe-area-inset-top, 0px) + 12px); bottom: auto; transform: translate(-50%, -20px); }
#toast.top.show { transform: translate(-50%, 0); }

/* dropdown list */
.dd { position: relative; }
.dd-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: #fff; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.dd.open .dd-btn { border-color: #15171a; }
.dd-caret { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translate(-2px, -2px); flex: none; transition: transform .15s; }
.dd.open .dd-caret { transform: rotate(-135deg) translate(-2px, -2px); }
.dd-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); max-height: 228px; overflow-y: auto; padding: 4px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 28px rgba(15, 17, 20, .16); z-index: 15; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.dd.up .dd-list { top: auto; bottom: calc(100% + 6px); }
.dd-item { display: flex; align-items: center; justify-content: space-between; height: 44px; padding: 0 12px; border-radius: 10px; cursor: pointer; }
.dd-item.on { background: var(--accent-soft); font-weight: 600; }
.dd-item:active { background: #eef0f2; }
.dd-check { color: var(--accent); }

/* full-screen zoom of a picture */
.zoomable { cursor: zoom-in; }
.zoom-overlay { position: fixed; inset: 0; background: rgba(8, 10, 13, .98); z-index: 30; }
.zoom-view { position: absolute; inset: 0; overflow: auto; display: flex; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.zoom-view { cursor: grab; user-select: none; -webkit-user-select: none; }
.zoom-view.dragging { cursor: grabbing; }
.zoom-stage { margin: auto; flex: none; }
.zoom-stage img { -webkit-user-drag: none; }
.zoom-stage > * { width: 100% !important; height: auto; display: block; margin: 0; }
.zoom-bar { position: absolute; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 12px; pointer-events: none; }
.zoom-btn { pointer-events: auto; width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .25); background: rgba(30, 33, 38, .92); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }

/* confirmation sheet */
.sheet-overlay { position: fixed; inset: 0; background: rgba(15, 17, 20, .45); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .2s; z-index: 20; }
.sheet-overlay.show { opacity: 1; }
.sheet { width: 100%; max-width: 640px; background: var(--card); border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); transform: translateY(24px); transition: transform .2s; }
.sheet-overlay.show .sheet { transform: none; }
.sheet h2 { margin: 0 0 16px; font-size: 18px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions .btn { padding: 12px 14px; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }

/* sliders */
.field { margin: 16px 0 0; }
.field .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field .head .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.field .ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.slider { position: relative; height: 28px; --lo: 0%; --hi: 100%; }
.slider::before { content: ""; position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 2px; background: linear-gradient(to right, #d6d9de var(--lo), var(--accent) var(--lo), var(--accent) var(--hi), #d6d9de var(--hi)); }
.slider.single::before { background: linear-gradient(to right, var(--accent) var(--hi), #d6d9de var(--hi)); }
.slider input[type="range"] { position: absolute; left: 0; width: 100%; top: 0; height: 28px; margin: 0; background: none; -webkit-appearance: none; appearance: none; pointer-events: none; }
.slider input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: transparent; }
.slider input[type="range"]::-moz-range-track { height: 4px; background: transparent; }
.slider input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 1px solid #c4c8ce; box-shadow: 0 1px 4px rgba(0,0,0,.25); margin-top: -10px; cursor: pointer; }
.slider input[type="range"]::-moz-range-thumb { pointer-events: auto; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 1px solid #c4c8ce; box-shadow: 0 1px 4px rgba(0,0,0,.25); cursor: pointer; }
.slider.centered::after { content: ""; position: absolute; left: 50%; top: 8px; width: 2px; height: 12px; margin-left: -1px; background: #c4c8ce; border-radius: 1px; }
.disabled { opacity: .45; pointer-events: none; }

/* candle chart */
.chart { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 6px 10px; margin: 0 0 12px; }
.chart svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.chart .grid { stroke: #e2e5e9; stroke-width: 1; stroke-dasharray: 3 4; }
.chart .sel { fill: #e9ecec; stroke: #5a6068; stroke-width: 1.4; }
.chart text { fill: var(--text); font-size: 12px; font-weight: 600; text-anchor: middle; }
.chart text.sub { fill: var(--muted); font-weight: 400; font-size: 11px; }
.chart .hit { fill: transparent; cursor: pointer; }
.save-state { font-size: 12px; color: var(--muted); min-height: 16px; }
.divider { border: 0; border-top: 1px dashed var(--line-strong); margin: 16px 0 12px; }

details.fold > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; color: #3d424a; font-size: 24px; line-height: 1; width: 20px; text-align: center; flex: none; transition: transform .15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > summary.big { font-size: 19px; font-weight: 700; color: #000; }
pre.json { background: #f0f2f4; border-radius: 12px; padding: 12px; font-size: 12px; overflow: auto; max-height: 320px; margin: 10px 0 8px; }
.scheme { width: 100%; border-radius: 12px; display: block; background: #fff; border: 1px solid var(--line); }
.bullets { margin: 10px 0 0; padding-left: 18px; }
.bullets li { margin: 4px 0; }
.note { background: var(--accent-soft); color: #274a2e; border-radius: 12px; padding: 9px 12px; font-size: 13px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eceef1; color: var(--muted); }
.badge.on { background: var(--accent-soft); color: var(--accent); }
.kv { display: grid; grid-template-columns: 1fr 110px; gap: 8px 12px; align-items: center; }
.kv label { color: var(--muted); font-size: 13.5px; }

/* level check */
.lvchart { border-radius: 12px; overflow: hidden; background: #0b0f14; }
.lvchart svg { width: 100%; height: auto; display: block; }
.lvchart text { font-size: 9px; fill: #8b98a5; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 4px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.found { margin: 8px 0 0; padding: 0; list-style: none; font-size: 14px; }
.found li { padding: 7px 0; border-top: 1px solid var(--line); }
/* REAL edition R9: the screens of the real trading carry a red strip so they are never taken for the test ones */
.real-banner { margin: -16px -16px 16px; padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px; background: #c62828; color: #fff; font-weight: 700; font-size: 13.5px; text-align: center; letter-spacing: .02em; }
body.real::before { content: ""; position: fixed; left: 0; right: 0; top: 0; height: 4px; background: #c62828; z-index: 20; }
