/* System view v3 + shared fixes. Weather look comes from the original stylesheet. */
:root {
  --bg: #0b1018;
  --card: #111925;
  --card2: #152030;
  --line: #233046;
  --line2: #2f3f57;
  --text: #edf1f7;
  --sub: #9aa9bc;
  --dim: #6b7c92;
  --up: #5fdcae;
  --down: #ff8490;
  --accent: #8fcfbe;
  --warn: #f3c46b;
}

html, body { overflow-x: hidden; overscroll-behavior-x: none; touch-action: manipulation; background: var(--bg); }
* { touch-action: manipulation; }
/* hide scrollbars everywhere (scrolling still works) */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar, html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; width: 0 !important; height: 0 !important; background: transparent; }
html, body { overscroll-behavior-y: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html[data-view=system], html[data-view=system] body { background: var(--bg); color: var(--text); color-scheme: dark; }

/* weather page: keep design, sensible top spacing below the status bar */
.weather-home { padding-top: calc(30px + env(safe-area-inset-top, 0px)) !important; }
.weather-kicker { color: inherit !important; opacity: 1 !important; font-weight: 600; }

/* hidden view switch (bottom-right, triple tap) */
.quiet-corner {
  position: fixed; right: 0; bottom: 0; left: auto;
  width: 70px; height: 70px; opacity: 0; border: 0; background: transparent; padding: 0;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; z-index: 50;
}

html[data-hide-balance] .weather-total { visibility: hidden; }
html[data-hide-balance] .sx-balance { display: none; }

/* ---------- system view ---------- */
.sx {
  max-width: 560px; margin: 0 auto;
  padding: calc(30px + env(safe-area-inset-top, 0px)) 16px calc(86px + env(safe-area-inset-bottom, 0px));
  font-family: "Noto Sans KR", system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
}
.sx button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sx-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sx-brand { display: flex; align-items: center; gap: 10px; }
.sx-brand h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.sx-gear { width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line); background: var(--card); font-size: 16px; color: var(--accent); }
.sx-status { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: #10261f; color: var(--up); font-size: 12px; font-weight: 600; }
.sx-status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sx-status.muted { background: #1a2230; color: var(--sub); }
.sx-status.warn { background: #2a2414; color: var(--warn); }

.sx-warn { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: #2a2414; color: var(--warn); font-size: 12px; line-height: 1.45; }

.sx-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.sx-balance { padding: 18px 18px 16px; margin-bottom: 12px; background: linear-gradient(160deg, #15222f, #101824); }
.sx-balance-label { color: var(--sub); font-size: 12px; }
.sx-balance-value { margin-top: 4px; font-size: 32px; font-weight: 700; letter-spacing: -1px; line-height: 1.15; }
.sx-balance-sub { margin-top: 6px; color: var(--sub); font-size: 12px; }
.sx-balance-sub b { font-weight: 600; }

.sx-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.sx-seg button { border: 0; border-radius: 10px; padding: 10px 0; background: transparent; color: var(--sub); font-size: 14px; font-weight: 600; }
.sx-seg button[aria-pressed=true] { background: #20384b; color: #e4f5ff; }
.sx-seg small { margin-left: 4px; font-size: 11px; color: inherit; opacity: .75; }

.sx-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.sx-stat { padding: 13px 14px; }
.sx-stat span { display: block; color: var(--sub); font-size: 11px; }
.sx-stat strong { display: block; margin-top: 4px; font-size: 20px; font-weight: 700; }
.sx-stat small { display: block; margin-top: 2px; color: var(--dim); font-size: 11px; }

.pos { color: var(--up) !important; }
.neg { color: var(--down) !important; }

.sx-section-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 2px 8px; }
.sx-section-head h2 { margin: 0; font-size: 14px; font-weight: 700; color: #d6e1ee; }
.sx-section-head span { color: var(--dim); font-size: 11px; }

.sx-empty { padding: 22px 12px; text-align: center; color: var(--sub); font-size: 13px; border: 1px dashed var(--line2); border-radius: 16px; }

/* position card */
.sx-pos { margin-bottom: 10px; overflow: hidden; }
.sx-pos.is-long { box-shadow: inset 3px 0 0 #42d19d; }
.sx-pos.is-short { box-shadow: inset 3px 0 0 #e76e9b; }
.sx-pos-head { width: 100%; border: 0; background: transparent; text-align: left; padding: 14px 14px 12px 16px; display: block; }
.sx-pos-row { display: flex; align-items: center; gap: 8px; }
.sx-sym { font-size: 16px; font-weight: 700; }
.sx-side { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.sx-side.is-long { background: #12392c; color: #7fe7bf; }
.sx-side.is-short { background: #3d1a28; color: #ffa3b8; }
.sx-pnl { margin-left: auto; text-align: right; }
.sx-pnl strong { display: block; font-size: 17px; font-weight: 700; }
.sx-pnl small { display: block; font-size: 11px; color: var(--sub); }
.sx-chev { color: var(--dim); font-size: 12px; margin-left: 2px; transition: transform .15s; }
.sx-open .sx-chev { transform: rotate(180deg); }

.sx-gauge { margin-top: 14px; }
.sx-track { position: relative; height: 8px; border-radius: 6px; background: linear-gradient(90deg, #ff849030, #ff84900d 50%, #5fdcae0d 50%, #5fdcae30); }
.sx-range { position: absolute; top: 0; height: 8px; border-radius: 6px; background: #ffffff1c; }
.sx-fill { position: absolute; top: 0; height: 8px; border-radius: 6px; }
.sx-fill.gain { background: #5fdcae88; }
.sx-fill.loss { background: #ff849088; }
.sx-entry { position: absolute; top: -4px; width: 2px; height: 16px; margin-left: -1px; background: #a7b6c9; border-radius: 1px; }
.sx-thumb { position: absolute; top: 50%; width: 3px; height: 20px; margin-left: -1.5px; transform: translateY(-50%); border-radius: 2px; box-shadow: 0 0 0 1.5px var(--card); }
.sx-unreal { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding: 12px 16px; background: var(--card2); font-size: 13px; color: var(--sub); }
.sx-unreal b { font-size: 15px; font-weight: 700; }
.sx-thumb.gain { background: var(--up); }
.sx-thumb.loss { background: var(--down); }
.sx-gauge-labels { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; font-size: 11px; color: var(--sub); }
.sx-gauge-labels b { color: #c8d4e2; font-weight: 600; }
.sx-gauge-labels .mid { color: var(--dim); }

.sx-details { padding: 0 16px 14px; border-top: 1px solid var(--line); }
.sx-details dl { margin: 10px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.sx-details dl div { min-width: 0; }
.sx-details dt { color: var(--dim); font-size: 11px; }
.sx-details dd { margin: 2px 0 0; font-size: 13px; color: #d4e0ed; word-break: break-all; }
.sx-note { margin: 10px 0 0; color: var(--dim); font-size: 10.5px; line-height: 1.45; }

/* history */
.sx-daybar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sx-daybar button.nav { width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line); background: var(--card); font-size: 18px; }
.sx-daybar button.nav:disabled { opacity: .35; }
.sx-date { position: relative; flex: 1; height: 36px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 11px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 600; }
.sx-date small { font-weight: 500; color: var(--sub); }
.sx-date select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; color-scheme: dark; }
.sx-trade { margin-bottom: 8px; overflow: hidden; }
.sx-trade.is-long { box-shadow: inset 3px 0 0 #42d19d; }
.sx-trade.is-short { box-shadow: inset 3px 0 0 #e76e9b; }
.sx-trade-head { width: 100%; border: 0; background: transparent; text-align: left; padding: 12px 14px 12px 16px; display: flex; align-items: center; gap: 8px; }
.sx-trade-head .sx-sym { font-size: 15px; }
.sx-trade-time { display: block; color: var(--dim); font-size: 11px; margin-top: 2px; }
.sx-badge { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 5px; background: #2a3550; color: #b9c6ff; }
.sx-trade-res { margin-left: auto; text-align: right; font-size: 15px; font-weight: 700; }

.sx-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--dim); font-size: 11px; }
.sx-conn { display: inline-flex; align-items: center; gap: 6px; color: #68b59c; }
.sx-conn.off { color: var(--sub); }
.sx-conn i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* settings sheet */
.sx-backdrop { position: fixed; inset: 0; z-index: 60; border: 0; background: #0009; }
.sx-sheet {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 40px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #162130; border: 1px solid var(--line2); border-bottom: 0; border-radius: 20px 20px 0 0;
  padding: 16px 18px calc(22px + env(safe-area-inset-bottom, 0px));
}
.sx-sheet-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sx-sheet-title b { font-size: 15px; }
.sx-sheet-title button { border: 0; background: transparent; font-size: 24px; color: var(--sub); padding: 0 4px; line-height: 1; }
.sx-field { margin-top: 14px; }
.sx-field > span { display: block; color: var(--sub); font-size: 11px; margin-bottom: 6px; }
.sx-choice { display: flex; gap: 6px; }
.sx-choice button { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid #344658; background: #111c28; color: #9fb2c6; font-size: 13px; }
.sx-choice button[aria-pressed=true] { background: #29453f; border-color: #6aa68f; color: #c9f1df; }
.sx-set { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line2); }
.sx-set b { font-size: 12px; color: #c9d6e4; }
.sx-set dl { margin: 6px 0 0; }
.sx-set dl div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid #ffffff08; }
.sx-set dt { color: var(--sub); font-size: 12px; white-space: nowrap; }
.sx-set dd { margin: 0; font-size: 12.5px; color: #e0e9f3; text-align: right; }

@media (max-width: 360px) {
  .sx { padding-left: 12px; padding-right: 12px; }
  .sx-balance-value { font-size: 27px; }
  .sx-stat strong { font-size: 18px; }
}

/* breakeven state */
.sx-be { color: var(--accent) !important; }
.sx-be-badge { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: #17363a; color: #9fe3d2; }

.sx-track.is-be { background: linear-gradient(90deg, #5fdcae12, #5fdcae33); }
.sx-gauge-labels.is-center { justify-content: center; }

/* ---------- weather extras (hourly / rain / outfit) ---------- */
.wx-rain { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; padding: 12px 14px; border-radius: 14px; background: #14243a; border: 1px solid #27405f; color: #cfe2ff; font-size: 13.5px; line-height: 1.4; }
.wx-rain .ic { font-size: 20px; }
.wx-outfit { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 7px 12px; border-radius: 999px; background: #ffffff0f; border: 1px solid #ffffff1a; color: #dbe6f2; font-size: 12.5px; }
.wx-panel { margin-top: 16px; background: #121d2c; border: 1px solid #243347; border-radius: 22px; padding: 16px 0 12px; }
.wx-panel h2 { margin: 0 18px 10px; font-size: 15px; font-weight: 700; color: #e6eef8; }
.wx-hourly { display: flex; gap: 4px; overflow-x: auto; padding: 0 12px 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.wx-hourly::-webkit-scrollbar { display: none; }
.wx-hr { flex: 0 0 52px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0; border-radius: 14px; color: #cdd8e5; font-size: 12px; }
.wx-hr.is-now { background: #1b2a3e; }
.wx-hr .t { color: #8fa1b6; font-size: 11.5px; }
.wx-hr .i { font-size: 22px; line-height: 1; }
.wx-hr .p { height: 13px; color: #7fb3ff; font-size: 10.5px; font-weight: 700; }
.wx-hr b { font-size: 14px; color: #f2f6fb; }

/* ---------- simpler system view (r11, 2026-11-30) ---------- */
.sx-balance { padding: 16px 18px; }
.sx-list-title { margin: 4px 2px 10px; color: var(--sub); font-size: 12px; font-weight: 700; letter-spacing: 1.5px; }
.sx-row { display: flex; gap: 8px; margin-top: 12px; }
.sx-mini { flex: 1; display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: #111c28; border: 1px solid #2a3b4e; }
.sx-mini button { flex: 1; padding: 7px 0; border: 0; border-radius: 7px; background: transparent; color: #8fa3b8; font-size: 13px; }
.sx-mini button[aria-pressed=true] { background: #29453f; color: #c9f1df; }
.sx-mini button.sx-tog { background: transparent; color: var(--text); }
.sx-set p { margin: 6px 0 0; color: #dbe5ef; font-size: 13px; line-height: 1.45; }

/* ---------- weather header bot light (r12, 2026-11-30) ---------- */
.wx-light { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #3a4656; }
.wx-light.is-green { background: #5fdcae; box-shadow: 0 0 0 4px #5fdcae22; }
.wx-light.is-red { background: #ff5b6b; box-shadow: 0 0 0 4px #ff5b6b33; }

/* ---------- r13 (2026-11-30): smaller bot light, wider stat values ---------- */
.wx-light { width: 6px; height: 6px; }
.wx-light.is-green { box-shadow: 0 0 0 2px #5fdcae22; }
.wx-light.is-red { box-shadow: 0 0 0 2px #ff5b6b33; }
.sx-stat strong { font-size: 17px; line-height: 1.3; }

/* ---------- r14 (2026-11-30): two-line results ---------- */
.res2 { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.2; vertical-align: middle; }
.res2 small { font-size: .72em; font-weight: 500; opacity: .85; margin-top: 1px; }
.sx-stat strong .res2 { display: inline-flex; align-items: flex-start; font-size: inherit; color: inherit; }
.sx-stat strong .res2 > span { display: inline; font-size: inherit; color: inherit; }
.sx-stat strong .res2 > small { display: inline; margin-top: 1px; font-size: .72em; color: inherit; }
.sx-date { height: auto; min-height: 42px; padding: 4px 0; }
.sx-date small { display: inline-flex; align-items: center; gap: 8px; }
.sx-date small .res2 { align-items: flex-start; }
.sx-details dd .res2 { align-items: flex-end; }

/* ---------- r15 (2026-11-30): 누적 수익 card opens the trade list ---------- */
.sx-stat-btn { position: relative; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sx-stat-btn:active { background: var(--card2); }
.sx-stat-chev { position: absolute; right: 12px; top: 11px; font-style: normal; color: var(--dim); font-size: 13px; transition: transform .15s; }
.sx-stat-btn[aria-expanded=true] .sx-stat-chev { transform: rotate(180deg); }
.sx-stat-btn[aria-expanded=true] { border-color: var(--line2); }

/* ---------- r17 (2026-11-30): one-line header ◈ | A B | light ---------- */
.sx-top { justify-content: flex-start; gap: 10px; }
.sx-top .sx-gear { flex: none; }
.sx-top-seg { flex: 1; margin-bottom: 0; }
.sx-top-seg button { padding: 8px 0; }
.sx-light { flex: none; width: 8px; height: 8px; margin: 0 6px 0 4px; border-radius: 50%; background: #5fdcae; box-shadow: 0 0 0 3px #5fdcae22; }
.sx-light.warn { background: var(--warn); box-shadow: 0 0 0 3px #f3c46b22; }
.sx-light.muted { background: #5d6b7c; box-shadow: none; }
.sx-foot { justify-content: flex-end; }

/* r24: unlabeled currency switch at the right of the balance */
.sx-balance { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sx-balance-value { margin-top: 0; }
.sx-cur { flex: none; width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 1.5px solid #3a4d63; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; position: relative; }
.sx-cur::after { content: ''; position: absolute; inset: -10px; }

/* r25: small 잔고/숨김 pill in the settings title row */
.sx-title-r { display: flex; align-items: center; gap: 12px; }
.sx-sheet-title button.sx-hide-pill { font-size: 12px; line-height: 1; padding: 6px 12px; border: 1px solid #2a3b4e; border-radius: 999px; background: transparent; color: var(--text); }

/* r26: system light = green ok / red with tap-to-see reason */
button.sx-light { border: 0; padding: 0; position: relative; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button.sx-light::after { content: ''; position: absolute; inset: -14px; }
.sx-light.bad { background: #ff5b6b; box-shadow: 0 0 0 3px #ff5b6b33; }
.sx-why { margin: -4px 0 12px; padding: 10px 14px; border-radius: 12px; background: #2a1519; border: 1px solid #5a2630; color: #ffd5da; font-size: 13px; line-height: 1.55; }
.sx-why p { margin: 0; }

/* ---------- r27 (2026-12-05): simpler system view ---------- */
.sx-seg3 { grid-template-columns: 1.3fr 1fr 1fr; }
.sx-hero { display: block; padding: 16px 18px 14px; margin-bottom: 12px; background: linear-gradient(160deg, #15222f, #101824); }
.sx-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sx-chip { display: inline-block; margin-bottom: 8px; padding: 3px 9px; border-radius: 999px; background: #2a2414; color: var(--warn); font-size: 11px; font-weight: 700; letter-spacing: .3px; }
.sx-figs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid #ffffff10; }
.sx-fig span { display: block; color: var(--dim); font-size: 11px; }
.sx-fig b { display: block; margin-top: 2px; font-size: 14px; font-weight: 700; color: #dfe8f2; }
.sx-sec { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 4px 8px; }
.sx-sec h2 { margin: 0; font-size: 13px; font-weight: 700; color: #c9d6e4; }
.sx-sec span { font-size: 12px; color: var(--sub); font-weight: 600; }
.sx-stats3 { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sx-stats3 .sx-stat { padding: 11px 12px; }
.sx-stats3 .sx-stat strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-day { margin-bottom: 8px; overflow: hidden; }
.sx-day-head { width: 100%; border: 0; background: transparent; text-align: left; padding: 12px 12px 12px 14px; display: flex; align-items: center; gap: 10px; }
.sx-day-d { flex: none; width: 52px; font-size: 14px; font-weight: 700; }
.sx-day-d small { margin-left: 4px; font-size: 11px; font-weight: 500; color: var(--dim); }
.sx-day-wl { flex: none; width: 52px; font-size: 11.5px; color: var(--sub); }
.sx-day-bar { flex: 1; min-width: 20px; height: 6px; border-radius: 4px; background: #ffffff0a; overflow: hidden; }
.sx-day-bar i { display: block; height: 100%; border-radius: 4px; }
.sx-day-bar i.up { background: #5fdcae99; }
.sx-day-bar i.down { background: #ff849099; }
.sx-day-res { flex: none; min-width: 74px; text-align: right; font-size: 14px; font-weight: 700; }
.sx-day-list { padding: 4px 8px 2px; border-top: 1px solid var(--line); background: #0e1520; }
.sx-day-list .sx-trade { margin: 6px 0; border-radius: 12px; background: var(--card); }
.sx-more { display: block; width: 100%; margin-top: 4px; padding: 11px 0; border-radius: 12px; border: 1px dashed var(--line2); background: transparent; color: var(--sub); font-size: 12.5px; }
@media (max-width: 360px) { .sx-day-wl { display: none; } .sx-stats3 .sx-stat strong { font-size: 14px; } }
