/* Apple-style skin for TV Lab. Loaded after the inline styles in index.html and overrides them:
   Pretendard (SF Pro-like Korean) + JetBrains Mono (SF Mono-like), Apple system colors, segmented controls,
   rounded translucent panels, monochrome line icons, and the layout grid (tool rail | charts | sidebar | AI). */
@font-face { font-family: "Pretendard Variable"; src: url("vendor/fonts/PretendardVariable.woff2") format("woff2-variations"); font-weight: 45 920; font-display: swap; }
@font-face { font-family: "JetBrains Mono Variable"; src: url("vendor/fonts/JetBrainsMono-Variable.woff2") format("woff2-variations"); font-weight: 100 800; font-display: swap; }

:root {
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI Variable", "Segoe UI", "Malgun Gothic", sans-serif;
  --mono: "JetBrains Mono Variable", "SF Mono", ui-monospace, Consolas, "D2Coding", monospace;
  --bg: #161618; --panel: #1c1c1e; --raised: #2c2c2e; --seg: #48484a; --hover: rgba(255, 255, 255, .065); --line: rgba(255, 255, 255, .09);
  --text: #f5f5f7; --muted: #8e8e93; --up: #30d158; --down: #ff453a; --accent: #0a84ff; --yellow: #ffd60a; --orange: #ff9f0a;
  --menu: rgba(40, 40, 43, .86); --tint: rgba(10, 132, 255, .18);
  --r-sm: 7px; --r: 9px; --r-lg: 14px;
  --shadow: 0 12px 34px rgba(0, 0, 0, .45), 0 0 0 .5px rgba(255, 255, 255, .1);
  --seg-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 0 0 .5px rgba(0, 0, 0, .2);
}
body.light {
  --bg: #ffffff; --panel: #f5f5f7; --raised: #ffffff; --seg: #ffffff; --hover: rgba(0, 0, 0, .05); --line: rgba(0, 0, 0, .085);
  --text: #1d1d1f; --muted: #6e6e73; --up: #1f9d48; --down: #e0302b; --accent: #0071e3;
  --menu: rgba(250, 250, 252, .88); --tint: rgba(0, 113, 227, .12);
  --shadow: 0 12px 34px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .1);
  --seg-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .06);
}

/* ---------- type ---------- */
html, body { font: 13px/1.42 var(--font); letter-spacing: -0.012em; -webkit-font-smoothing: antialiased; }
b, strong { font-weight: 650; }
#info, #list, .book, #dockBody table, .tk, .srow, #alerts, .legend, .pane .tag, table.eng,
#scan, #cal, #aiLog, .ord-card, .ask .box, .ai-pop, .osum, .pm-sum { font-variant-numeric: tabular-nums; }
pre, code, .code, textarea.code, #aiLog .code pre { font-family: var(--mono); letter-spacing: 0; }
.small { font-size: 11.5px; }

/* ---------- layout: header / info on top, tool rail | charts (+ trading dock) | sidebar | AI ---------- */
/* column / row sizes live in the "layout grid" block at the end of this file */
header { grid-column: 1 / -1; grid-row: 1; }
#info { grid-column: 1 / -1; grid-row: 2; }
#rail { grid-column: 1; grid-row: 3 / 5; }
#charts { grid-column: 2; grid-row: 3; }
#dock { grid-column: 2; grid-row: 4; }
aside { grid-column: 3; grid-row: 3 / 5; }
#ai { position: relative; top: auto; right: auto; bottom: auto; width: auto; z-index: auto; box-shadow: none; }

/* ---------- controls ---------- */
button, select { border-radius: var(--r-sm); padding: 5px 9px; font-weight: 500; transition: background-color .12s, color .12s, box-shadow .12s; }
button:hover, select:hover { background-color: var(--hover); }
button.on { background: var(--accent); color: #fff; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--tint); outline-offset: 1px; }
select {
  -webkit-appearance: none; appearance: none; background-color: var(--hover); padding-right: 24px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M7 10l5 5 5-5'/></svg>");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 11px;
}
select option { background: var(--raised); color: var(--text); }
input, textarea { background: var(--hover); border: 1px solid transparent; border-radius: var(--r-sm); padding: 6px 9px; }
input:focus, textarea:focus { border-color: var(--accent); background: var(--raised); }
input[type=checkbox], input[type=range] { accent-color: var(--accent); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: transparent; border: 2.5px solid transparent; border-radius: 9px; background-clip: padding-box; }
:hover::-webkit-scrollbar-thumb { background-color: var(--seg); }

/* ---------- icons (monochrome line icons as masks, colored by currentColor) ---------- */
.ic { width: 16px; height: 16px; display: inline-block; flex: none; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.i-chart { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'><path d='M3 17l5.5-6 4 4L21 6'/><path d='M15 6h6v6'/></svg>"); }
.i-code { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'><path d='M8 7l-5 5 5 5M16 7l5 5-5 5M14 4l-4 16'/></svg>"); }
.i-bars { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'><path d='M5 20v-8M12 20V5M19 20v-5'/></svg>"); }
.i-case { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linejoin='round'><rect x='3' y='7' width='18' height='13' rx='2.5'/><path d='M8.5 7V5.5A1.5 1.5 0 0 1 10 4h4a1.5 1.5 0 0 1 1.5 1.5V7M3 12.5h18'/></svg>"); }
.i-gauge { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'><path d='M3.5 17a8.5 8.5 0 1 1 17 0'/><path d='M12 17l4.2-5.5'/><circle cx='12' cy='17' r='1.3' fill='black'/></svg>"); }
.i-spark { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'><path d='M11 3.5l1.9 5.1 5.1 1.9-5.1 1.9L11 17.5l-1.9-5.1L4 10.5l5.1-1.9z'/><path d='M18.5 14.5l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8z'/></svg>"); }
.i-grid { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9'><rect x='4' y='4' width='7' height='7' rx='1.8'/><rect x='13' y='4' width='7' height='7' rx='1.8'/><rect x='4' y='13' width='7' height='7' rx='1.8'/><rect x='13' y='13' width='7' height='7' rx='1.8'/></svg>"); }
.i-link { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'><path d='M10 14a4.2 4.2 0 0 0 6 0l3-3a4.2 4.2 0 0 0-6-6l-1 1'/><path d='M14 10a4.2 4.2 0 0 0-6 0l-3 3a4.2 4.2 0 0 0 6 6l1-1'/></svg>"); }
.i-camera { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linejoin='round'><path d='M4 8.5h3.2L9 6h6l1.8 2.5H20v10.5H4z'/><circle cx='12' cy='13.3' r='3.3'/></svg>"); }
.i-more { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><circle cx='6' cy='12' r='1.8'/><circle cx='12' cy='12' r='1.8'/><circle cx='18' cy='12' r='1.8'/></svg>"); }
.i-theme { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9'><circle cx='12' cy='12' r='8'/><path d='M12 4a8 8 0 0 1 0 16z' fill='black'/></svg>"); }
.i-cursor { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'><path d='M6 3.5l12 7.2-5.1 1.4-2.2 5.4z'/></svg>"); }
.i-hline { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'><path d='M3 12h18'/><circle cx='12' cy='12' r='2.2' fill='black'/></svg>"); }
.i-trend { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'><path d='M5.5 18.5l13-13'/><circle cx='5' cy='19' r='2'/><circle cx='19' cy='5' r='2'/></svg>"); }
.i-fib { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'><path d='M3 5h18M3 10h18M3 14.5h18M3 19h18'/><path d='M6 19L18 5' stroke-dasharray='1.5 2.5'/></svg>"); }
.i-ruler { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='2.5' y='8.5' width='19' height='7' rx='1.5' transform='rotate(-45 12 12)'/><path d='M9.2 9.2l1.6 1.6M11.6 6.8l1.1 1.1M6.8 11.6l1.1 1.1M14 4.4l1.6 1.6M4.4 14l1.6 1.6'/></svg>"); }
.i-bell { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linejoin='round'><path d='M6 16.5V11a6 6 0 0 1 12 0v5.5l1.8 1.8H4.2z'/><path d='M10 20.5a2.2 2.2 0 0 0 4 0'/></svg>"); }
.i-replay { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'><path d='M3.5 12a8.5 8.5 0 1 0 2.6-6.1'/><path d='M3.5 4.5v4.6h4.6'/><path d='M12 8v4.3l2.8 1.7'/></svg>"); }
.i-star { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><path d='M12 3.2l2.7 5.6 6.1.8-4.5 4.2 1.2 6.1L12 17l-5.5 2.9 1.2-6.1-4.5-4.2 6.1-.8z'/></svg>"); }
.i-list { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><path d='M9 6h11M9 12h11M9 18h11'/><circle cx='4.5' cy='6' r='1.2' fill='black'/><circle cx='4.5' cy='12' r='1.2' fill='black'/><circle cx='4.5' cy='18' r='1.2' fill='black'/></svg>"); }
.i-cal { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'><rect x='3.5' y='5' width='17' height='15.5' rx='2.5'/><path d='M3.5 10h17M8 3v4M16 3v4'/></svg>"); }
.i-news { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'><rect x='4' y='4' width='16' height='16' rx='2.5'/><path d='M8 9h8M8 12.5h8M8 16h5'/></svg>"); }

/* ---------- header ---------- */
header { height: var(--hdr-h); padding: 0 10px; gap: 4px; background: var(--panel); border-bottom: 1px solid var(--line); overflow: visible; }
header .grp { display: flex; align-items: center; gap: 2px; flex: none; }
header .sp { flex: 1; min-width: 6px; }
header .hsep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; flex: none; }
header button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; }
header button .ic { color: var(--muted); }
header button:hover .ic { color: var(--text); }
#symBtn { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; padding: 6px 10px; }
#symBtn small { font-weight: 500; }
#ivFav { display: flex; gap: 0; padding: 2px; border-radius: var(--r); background: var(--hover); }
#ivFav button { padding: 4px 9px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: var(--fs-ctl); }
#ivFav button:hover { color: var(--text); background: transparent; }
#ivFav button.on { background: var(--seg); color: var(--text); box-shadow: var(--seg-shadow); }
#ivAll { margin-left: 4px; }
#ivAll, #ctype { font-size: var(--fs-ctl); font-weight: 600; }
/* panel toggles: tinted when their panel is open */
header .pt.on { background: var(--tint); color: var(--accent); }
header .pt.on .ic { color: var(--accent); }
#status { margin-left: 6px; padding: 3px 10px; border-radius: 99px; background: var(--hover); font-size: 11.5px; font-weight: 600; }

/* ---------- info strip ---------- */
#info { height: var(--info-h); gap: 0; padding: 0; overflow: hidden; background: var(--bg); border-bottom: 1px solid var(--line); font-size: 12px; }
#info > b { font-size: 14px; font-weight: 700; letter-spacing: -0.02em; }
#info .k { color: var(--muted); font-weight: 500; margin-right: 6px; }
#info .calnext { padding: 3px 10px; border-radius: 99px; background: rgba(255, 159, 10, .14); }

/* ---------- tool rail ---------- */
#rail { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
#rail button { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border-radius: var(--r); color: var(--muted); }
#rail button:hover { color: var(--text); background: var(--hover); }
#rail button.on { background: var(--tint); color: var(--accent); }
body:not(.picking) #railCursor { background: var(--hover); color: var(--text); }
#rail .ic { width: 18px; height: 18px; }
#rail .sep { width: 20px; height: 1px; background: var(--line); margin: 6px 0; }

/* ---------- charts ---------- */
#charts { background: var(--line); }
.slot.active::after { border: 0; box-shadow: inset 0 0 0 1.5px rgba(10, 132, 255, .55); }
.legend b { font-weight: 700; }

/* ---------- sidebar ---------- */
aside { background: var(--panel); border-left: 1px solid var(--line); }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); margin: 10px 10px 6px; padding: 2px; border: 0; border-radius: var(--r); background: var(--hover); }
.tabs button { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 5px 0; border: 0; border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--muted); }
.tabs button:hover { background: transparent; color: var(--text); }
.tabs button.on { background: var(--seg); color: var(--text); box-shadow: var(--seg-shadow); border: 0; }
.tabs .ic { width: 13px; height: 13px; }
.tabs button[data-tab="watch"].on .ic { color: var(--yellow); }
.tabs small { font-size: 10px; font-weight: 600; color: var(--muted); margin-left: 1px; }
.lists { padding: 4px 10px 0; }
.filter { padding: 6px 10px 8px; }
.filter input {
  border-radius: var(--r-sm); padding-left: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.2' stroke-linecap='round'><circle cx='11' cy='11' r='6.5'/><path d='M16 16l4 4'/></svg>");
  background-repeat: no-repeat; background-position: 9px center; background-size: 14px;
}
.colhead { padding: 0 18px 0 16px; border-bottom: 1px solid var(--line); }
.colhead button { font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px 0; }
.colhead button.on { color: var(--accent); }
#list { padding: 4px 0; }
#list li { margin: 0 6px; padding: 7px 12px 7px 10px; border-radius: 8px; }
#list li:hover { background: var(--hover); }
#list li.cur { background: var(--tint); box-shadow: none; }
#list .name { font-weight: 600; }
#list .name small { font-weight: 500; }
#list .star { font-size: 13px; }
#list .star.on { color: var(--yellow); }
aside h3 { margin: 0; padding: 12px 14px 6px; font-size: 12px; font-weight: 700; color: var(--text); border-top: 1px solid var(--line); }
#alerts li { margin: 0 6px; border-radius: 8px; padding: 6px 10px; }
#alerts li:hover { background: var(--hover); }

/* 일정 / 뉴스 */
#cal .cal-f { padding: 6px 10px 8px; gap: 5px; border-bottom: 1px solid var(--line); }
#cal .cal-f button, #news .cal-f button { font-size: 11px; font-weight: 600; padding: 3px 9px; border: 0; border-radius: 99px; background: var(--hover); opacity: .6; }
#cal .cal-f button.on, #news .cal-f button.on { opacity: 1; background: var(--tint); color: var(--accent); }
#cal .cal-day { padding: 10px 14px 4px; font-size: 11.5px; font-weight: 700; color: var(--muted); background: var(--panel); }
#cal .cal-ev { margin: 0 6px; padding: 5px 8px; border-radius: 8px; grid-template-columns: 42px 10px 1fr auto; }
#cal .cal-ev:hover { background: var(--hover); }
#cal .cal-ev.next { background: var(--tint); }
.imp.High { background: #ff453a; } .imp.Medium { background: #ff9f0a; } .imp.Low { background: #ffd60a; } .imp.Holiday { background: #8e8e93; }
#news .cal-f { display: flex; gap: 5px; padding: 6px 10px 8px; border-bottom: 1px solid var(--line); }
#news .news-it { margin: 2px 6px; padding: 8px 10px; border: 0; border-radius: 10px; line-height: 1.45; }
#news .news-it:hover { background: var(--hover); }
#news .news-it .meta { font-size: 11px; font-weight: 600; margin-bottom: 3px; }

/* ---------- menus, dialogs, toast ---------- */
#menu { padding: 5px; border: 0; border-radius: 11px; background: var(--menu); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%); box-shadow: var(--shadow); }
#menu .item { padding: 5px 10px 5px 8px; border-radius: 6px; }
#menu .item:hover { background: var(--accent); color: #fff; }
#menu .item:hover .key { color: rgba(255, 255, 255, .8); }
#menu .item.disabled:hover { background: none; color: var(--muted); }
#menu .sep { margin: 4px 8px; }
#modal, .ask { background: rgba(0, 0, 0, .32); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
#modal .box, .ask .box { border: 0; border-radius: var(--r-lg); background: var(--menu); -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%); box-shadow: var(--shadow); }
#modal .head { padding: 14px 18px; font-size: 15px; font-weight: 700; border-bottom: 1px solid var(--line); }
#modal .body { padding: 14px 18px; }
.ask .t { font-size: 15px; font-weight: 700; }
.ask .b button { min-width: 72px; padding: 7px 14px; border-radius: var(--r); font-weight: 600; background: var(--hover); }
.ask .b button.on { background: var(--accent); color: #fff; }
#toast { border: 0; border-radius: 99px; padding: 9px 18px; font-weight: 600; background: var(--menu); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%); box-shadow: var(--shadow); }
.srow { border-radius: 8px; }

/* ---------- trading dock ---------- */
#dock { background: var(--panel); border-top: 1px solid var(--line); }
#dock .dock-head { padding: 6px 10px; gap: 12px; border-bottom: 1px solid var(--line); }
#dock .dock-tabs { display: inline-flex; padding: 2px; border-radius: var(--r); background: var(--hover); }
#dock .dock-tabs button { padding: 4px 12px; border: 0; border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--muted); }
#dock .dock-tabs button:hover { background: transparent; color: var(--text); }
#dock .dock-tabs button.on { background: var(--seg); color: var(--text); box-shadow: var(--seg-shadow); }
#dockBody th { font-size: 11px; font-weight: 600; background: var(--panel); }
#dockBody td, #dockBody th { border-bottom: 1px solid var(--line); padding: 6px 10px; }
#dockBody tr:hover td { background: var(--hover); }
#ticket { background: var(--panel); }
.tk-l input[type=number], .tk-l input:not([type]), .tk-l input[type=password], .tk-l select { background-color: var(--hover); border: 1px solid transparent; border-radius: var(--r-sm); }
.tk-l input:focus { border-color: var(--accent); background-color: var(--raised); }
.tk-side { padding: 2px; border-radius: var(--r); background: var(--hover); gap: 0; }
.tk-side button { border: 0; border-radius: 7px; padding: 5px 0; font-weight: 700; color: var(--muted); }
.tk-side button.buy.on { background: var(--up); color: #fff; box-shadow: var(--seg-shadow); }
.tk-side button.sell.on { background: var(--down); color: #fff; box-shadow: var(--seg-shadow); }
.tk-go button { border-radius: 10px; padding: 8px 0; font-weight: 700; }
.book .hd { font-weight: 600; }
.book .lad .mid b { font-weight: 700; letter-spacing: -0.02em; }
.ord-card { border: 0; border-radius: 12px; background: var(--hover); padding: 10px 12px; }

/* ---------- AI panel (chat) ---------- */
#ai { background: var(--panel); border-left: 1px solid var(--line); }
#ai .ai-head b { font-size: 14px; letter-spacing: -0.02em; }
#aiLog { gap: 8px; padding: 12px; }
#aiLog .msg { border-radius: 18px; padding: 9px 13px; line-height: 1.55; }
#aiLog .msg.u { background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
#aiLog .msg.a { background: var(--raised); border: 0; border-bottom-left-radius: 6px; }
#aiLog .msg.err { box-shadow: inset 0 0 0 1px var(--down); }
#aiLog .code { border: 0; border-radius: 10px; background: var(--bg); }
#aiLog .code .bar { background: transparent; border-bottom: 1px solid var(--line); }
#aiLog .drawchip { border: 0; border-radius: 10px; background: var(--tint); }
#aiQuick { gap: 6px; padding: 0 12px 8px; }
#aiQuick button { border: 0; border-radius: 99px; padding: 4px 11px; font-weight: 600; background: var(--hover); }
#aiQuick button:hover { background: var(--tint); color: var(--accent); }
#ai .ai-in { padding: 10px 12px; border-top: 1px solid var(--line); }
#ai textarea { border-radius: 14px; padding: 9px 12px; background: var(--hover); border: 1px solid transparent; }
#ai textarea:focus { border-color: var(--accent); background: var(--raised); }
#aiSend { border-radius: 99px; padding: 6px 16px; font-weight: 700; }

/* ---------- engine modal ---------- */
table.eng th { font-size: 11px; font-weight: 600; color: var(--muted); }
table.eng td, table.eng th { border-bottom: 1px solid var(--line); }

/* --- placement fixes --- */
#ai .ai-head b { display: none; }
#ai #aiHist { max-width: 130px; }
/* Watchlist: every symbol is a USDT perp, so show the base asset only and give it the room. */
#list .name small { display: none; }
#list .star, #list .star.on { background: none; box-shadow: none; padding: 0; }
/* Neutral segmented choice (e.g. testnet) — raised segment, readable text. */
.tk-side button.on:not(.buy):not(.sell) { background: var(--seg); color: var(--text); box-shadow: var(--seg-shadow); }
#ai #aiStat { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#dock #dockSum { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1100px) { #ivFav { display: none; } } /* the interval select still lists every interval */

/* --- resizable panels (CSS variables set by the app.js gutters) and the UI zoom button --- */
#ticket { width: var(--tk-w, 300px); }
@media (max-width: 760px) { #ticket { width: var(--tk-w, 220px); } }
.pane { height: var(--pane-h, 110px); }
#charts:not(.l1) .pane { height: calc(var(--pane-h, 110px) * .65); }
#charts.l6 .pane, #charts.l8 .pane { height: calc(var(--pane-h, 110px) * .5); }
aside, #dock, #ticket { position: relative; }
.gutter { position: absolute; z-index: 30; touch-action: none; }
.gutter.l { left: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; }
.gutter.r { right: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; }
.gutter.t { top: 0; left: 0; right: 0; height: 6px; cursor: row-resize; }
.gutter::after { content: ""; position: absolute; background: var(--accent); border-radius: 2px; opacity: 0; transition: opacity .12s; }
.gutter.l::after { left: 0; top: 0; bottom: 0; width: 3px; }
.gutter.r::after { right: 0; top: 0; bottom: 0; width: 3px; }
.gutter.t::after { left: 0; right: 0; top: 0; height: 3px; }
.gutter:hover::after { opacity: .7; transition-delay: .15s; }
.gutter.drag::after { opacity: 1; }
body.resizing * { cursor: inherit !important; user-select: none; }
header [hidden] { display: none !important; }
header #zoomBtn { min-width: 46px; justify-content: center; font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
header #zoomBtn:hover { color: var(--text); }
#dock .dock-main { position: relative; }
.gutter.r.tk { right: auto; left: calc(var(--tk-w, 300px) - 4px); }
@media (max-width: 760px) { .gutter.r.tk { left: calc(var(--tk-w, 220px) - 4px); } }
/* Saved sizes must never crush the price chart (small window, zoom): the indicator panes shrink instead
   (price-chart floor and dock height: see "chart slot" and "trading dock" at the end). */
.slot { overflow: hidden; }
.pane { flex: 0 1 auto; min-height: 36px; }
.ai-link { color: var(--accent); cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 2px; word-break: break-all; }
.ai-link:hover { text-decoration-color: var(--accent); }

/* --- trading desk: risk preview, position tools, journal, scanner --- */
.warn { color: var(--orange); }
.tk-risk { min-height: 16px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.tk-risk b { font-weight: 700; }
button.danger { color: var(--down); }
button.danger:hover { background: color-mix(in srgb, var(--down) 14%, transparent); }
#dockBody td.guards { white-space: nowrap; font-size: 11px; }
#dockBody td.acts { white-space: nowrap; }
.pm { display: flex; flex-direction: column; gap: 6px; min-width: 520px; }
.pm-sum { padding: 8px 10px; border-radius: var(--r); background: var(--hover); }
.pm-h { margin-top: 8px; font-weight: 700; font-size: 12px; }
.pm-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pm-row input[type=number] { width: 110px; }
.pm-row input.pct { width: 56px; }
.pm-row .sp { flex: 1; }
.jr { display: flex; flex-direction: column; gap: 6px; padding: 6px 8px; }
.jr-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.jr-stats { display: flex; flex-wrap: wrap; gap: 4px; }
.jr-stats .chip { display: inline-flex; gap: 5px; align-items: baseline; padding: 3px 8px; border-radius: 99px; background: var(--hover); font-size: 11.5px; }
.jr-stats .chip .k { color: var(--muted); }
.jr tr[data-trip] { cursor: pointer; }
.jr-eq { height: 200px; }
.jr-trips td.note { max-width: 260px; white-space: normal; text-align: left; cursor: text; }
.tabs { grid-template-columns: repeat(5, 1fr); }
.tabs button { padding-left: 2px; padding-right: 2px; font-size: 11.5px; }
#scan { flex: 1; overflow-y: auto; min-height: 0; font-size: 12px; }
.scan-cfg { padding: 4px 12px 2px; line-height: 2; color: var(--muted); font-size: 11.5px; }
.scan-cfg input, .scan-cfg select { padding: 2px 5px; font-size: 11.5px; }
.scan-list { list-style: none; margin: 0; padding: 2px 0; }
.scan-list li { margin: 0 6px; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.scan-list li:hover { background: var(--hover); }
.scan-list li.empty { cursor: default; color: var(--muted); }
.scan-list .l1 { display: flex; gap: 8px; align-items: baseline; }
.scan-list .l1 b { flex: 1; }
.scan-list .chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.tg { padding: 1px 7px; border-radius: 99px; font-size: 10.5px; font-weight: 600; background: var(--hover); }
.tg.vol { color: var(--accent); background: var(--tint); }
.tg.up { color: var(--up); background: color-mix(in srgb, var(--up) 14%, transparent); }
.tg.down { color: var(--down); background: color-mix(in srgb, var(--down) 14%, transparent); }
.tg.fund, .tg.fundn { color: var(--orange); background: color-mix(in srgb, var(--orange) 14%, transparent); }
.tg.oi { color: var(--yellow); background: color-mix(in srgb, var(--yellow) 14%, transparent); }
.i-scan { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'><circle cx='12' cy='12' r='2'/><path d='M7.8 7.8a6 6 0 0 0 0 8.4M16.2 16.2a6 6 0 0 0 0-8.4M4.9 4.9a10 10 0 0 0 0 14.2M19.1 19.1a10 10 0 0 0 0-14.2'/></svg>"); }
.tk-risk { white-space: normal; overflow: visible; line-height: 15px; } /* the risk line may take two lines in a narrow ticket */
/* --- trader test fixes --- */
/* Indicator panes keep the height you dragged them to; only when space runs out do they shrink, and the price chart
   never drops below 62% of its slot (dock open, zoomed, several panes). */
.mainc { flex: 1 0 62%; min-height: 0; }
.pane { flex: 0 1 var(--pane-h, 110px); height: auto; min-height: 36px; }
#charts:not(.l1) .pane { flex-basis: calc(var(--pane-h, 110px) * .65); height: auto; }
#charts.l6 .pane, #charts.l8 .pane { flex-basis: calc(var(--pane-h, 110px) * .5); height: auto; }
/* Five sidebar tabs in 320px: one line each (the all-symbols count isn't worth the room). */
.tabs button { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; gap: 4px; }
#allCount { display: none; }
/* AI draw chip: label on its own line, buttons wrap under it. */
#aiLog .drawchip { flex-wrap: wrap; }
#aiLog .drawchip .sp { flex: 1 1 100%; height: 0; }
/* --- AI panel: model / effort / usage controls, tool steps, robust answers --- */
.i-chev { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M7 10l5 5 5-5'/></svg>"); width: 12px; height: 12px; }
#ai .ai-btns { gap: 6px; align-items: center; }
.ai-ctl { display: inline-flex; align-items: center; gap: 4px; }
.ai-ctl .pill { display: inline-flex; align-items: center; gap: 2px; padding: 4px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; color: var(--muted); background: transparent; }
.ai-ctl .pill:hover { background: var(--hover); color: var(--text); }
.ai-ctl .ring { width: 26px; height: 26px; padding: 4px; border-radius: 99px; background: transparent; }
.ai-ctl .ring:hover { background: var(--hover); }
.ai-ctl .ring svg { width: 18px; height: 18px; transform: rotate(-90deg); display: block; }
.ai-ctl .ring circle { fill: none; stroke-width: 2.6; }
.ai-ctl .ring .val { stroke: var(--accent); stroke-linecap: round; transition: stroke-dasharray .3s; }
.ai-ctl .ring.hot .val { stroke: var(--orange); }
.ai-pop { position: absolute; z-index: 60; width: 340px; max-width: calc(100% - 16px); padding: 14px; border-radius: 14px; background: var(--menu); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg, 0 18px 50px rgba(0,0,0,.35)); backdrop-filter: blur(24px) saturate(160%); font-size: 12.5px; display: flex; flex-direction: column; gap: 8px; }
.ai-pop .pop-h { font-size: 13px; }
.ai-pop .pop-h b { color: var(--accent); margin-left: 6px; }
.ai-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.ai-pop button { padding: 4px 10px; border-radius: 8px; background: var(--hover); font-size: 12px; }
.pop-eff { width: 300px; }
.eff-l { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.eff { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 6px; border-radius: 10px; background: var(--hover); }
.eff button { height: 18px; border-radius: 6px; background: var(--line); padding: 0; }
.eff button.on { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.eff button.cur { background: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.eff-rec { position: relative; height: 14px; font-size: 11px; color: var(--muted); }
.eff-rec span { position: absolute; transform: translateX(-50%); }
.urow { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; }
.urow > :nth-child(2) { text-align: right; }
.ubar { height: 6px; border-radius: 99px; background: var(--hover); overflow: hidden; }
.ubar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.ubar i.hot { background: var(--orange); }
#aiLog .steps { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
#aiLog .step { padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--tint); color: var(--accent); }
#aiLog .step.err { background: color-mix(in srgb, var(--down) 14%, transparent); color: var(--down); }
#aiLog .thinking { display: inline-flex; gap: 4px; padding: 6px 2px; }
#aiLog .thinking i { width: 6px; height: 6px; border-radius: 99px; background: var(--muted); animation: aiDot 1.2s infinite ease-in-out; }
#aiLog .thinking i:nth-child(2) { animation-delay: .15s; } #aiLog .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes aiDot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
#aiLog .drawchip .lbl { flex: 1 1 100%; font-weight: 600; }

/* ===== design tokens (round 1) ===== */
:root {
  color-scheme: dark;                 /* native checkboxes, number spinners, select popups follow the theme */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px;
  --fs-meta: 11px; --fs-ctl: 12.5px; --fs-body: 13px; --fs-title: 15px;
  --ctl-sm: 24px; --ctl: 28px; --ctl-lg: 34px; --row: 32px;
  --hdr-h: 48px; --info-h: 34px; --rail-w: 46px; --rail-btn: 34px;
  --r-pill: 99px;                     /* existing --r-sm 7 / --r 9 / --r-lg 14 stay */
}
body.light { color-scheme: light; --yellow: #a67c00; --orange: #c25400; }   /* 3.5:1 / 4.2:1 on #f5f5f7 */
/* density: short or narrow CSS viewports (1280×720 laptops, 150–200% zoom) */
@media (max-height: 760px), (max-width: 1100px) {
  :root { --hdr-h: 40px; --info-h: 28px; --rail-w: 40px; --rail-btn: 30px; --ctl: 26px; --row: 28px; }
}
html, body { word-break: keep-all; overflow-wrap: break-word; }   /* Korean breaks at spaces only */

/* --- layout grid: the single source of column / row sizes (--side-w / --ai-w come from the app.js gutters) --- */
body { grid-template-columns: var(--rail-w) minmax(0, 1fr) min(var(--side-w, 320px), 40vw); grid-template-rows: var(--hdr-h) var(--info-h) minmax(0, 1fr) auto; }
body.ai-open { grid-template-columns: var(--rail-w) minmax(0, 1fr) min(var(--side-w, 320px), 30vw) min(var(--ai-w, 430px), 45vw); }
body.ai-open #info { grid-column: 1 / 4; }
body.ai-open #ai { grid-column: 4; grid-row: 2 / -1; }   /* under the header, so the AI toggle is never covered */
/* < 1600: the AI replaces the sidebar (sidebar → drawer). At 1280 the chart goes from 534px to ~804px. */
@media (max-width: 1599px) {
  body.ai-open { grid-template-columns: var(--rail-w) minmax(0, 1fr) min(var(--ai-w, 430px), 42vw); }
  body.ai-open aside { display: none; }
  body.ai-open #info { grid-column: 1 / 3; }
  body.ai-open #ai { grid-column: 3; }
}
@media (max-width: 980px) { body { grid-template-columns: var(--rail-w) minmax(0, 1fr); } aside { display: none; } }
@media (max-width: 900px) {
  body.ai-open { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  body.ai-open #info { grid-column: 1 / -1; }
  body.ai-open #ai { position: fixed; top: var(--hdr-h); right: 0; bottom: 0; width: min(420px, calc(100vw - var(--rail-w))); z-index: 40; box-shadow: var(--shadow); }
}

/* --- sidebar drawer (#sideBtn): the sidebar slides over the charts when it has no column --- */
#sideBtn { display: none; }
@media (max-width: 980px) {
  #sideBtn { display: inline-flex; }
  body.side-open aside { display: flex; position: fixed; top: var(--hdr-h); right: 0; bottom: 0; width: min(var(--side-w, 320px), calc(100vw - var(--rail-w))); z-index: 45; box-shadow: var(--shadow); }
  body.side-open aside > .gutter { display: none; }
}
@media (max-width: 1599px) {
  body.ai-open #sideBtn { display: inline-flex; }
  body.ai-open.side-open aside { display: flex; position: fixed; top: var(--hdr-h); right: 0; bottom: 0; width: min(var(--side-w, 320px), calc(100vw - var(--rail-w))); z-index: 45; box-shadow: var(--shadow); }
  body.ai-open.side-open aside > .gutter { display: none; }
}

/* --- header --- */
header button, header select { height: var(--ctl); padding-block: 0; font-size: var(--fs-ctl); }
header .ico { width: var(--ctl); padding: 0; justify-content: center; }
header #zoomBtn { width: auto; padding: 0 8px; }
#ivFav { height: var(--ctl); }
#ivFav button { height: 100%; padding: 0 9px; }
#ivAll, #ctype { field-sizing: content; }          /* '캔들' no longer takes the width of 'P&F (포인트앤피겨)'; saves ~110px */
#status { height: var(--ctl); display: inline-flex; align-items: center; padding: 0 10px; }
/* Narrow windows: header buttons drop their labels, icons and tooltips stay. */
@media (max-width: 1360px) { header .lbl { display: none; } header .grp button { padding: 0; width: var(--ctl); justify-content: center; } }
@media (max-width: 960px) { #shotBtn, #themeBtn, header .hsep { display: none; } }   /* both move into the ⋯ menu */

/* --- info strip: ticks scroll silently and fade at the edge; the next macro event sits outside the scroller --- */
#info .ticks { display: flex; align-items: center; gap: 18px; flex: 1; min-width: 0; height: 100%; padding: 0 14px; overflow-x: auto; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent); }
#info .calnext { flex: none; margin: 0 10px 0 4px; display: inline-flex; align-items: center; gap: 6px; background: color-mix(in srgb, var(--orange) 16%, var(--bg)); }
#info .calnext[hidden] { display: none; }
#info .calnext .ic { width: 13px; height: 13px; color: var(--orange); }
.ccy { font: 600 10px var(--mono); color: var(--muted); padding: 1px 4px; border-radius: 4px; background: var(--hover); margin-right: 4px; }
@media (max-width: 1100px) { #info .calnext .ttl { display: none; } }   /* countdown always visible */

/* --- tool rail --- */
#rail { overflow-y: auto; scrollbar-width: none; }
#rail button { width: var(--rail-btn); height: var(--rail-btn); }

/* --- chart slot and legend --- */
.mainc { container: chart / inline-size; }
.legend { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 0 2px var(--bg), 0 0 4px var(--bg), 0 0 6px var(--bg); }
.legend span span { margin: 0 0 0 3px; }          /* value inside an item gets no extra right gap */
.legend .ohl { margin-right: 0; }
.legend .ohl > span { margin: 0 8px 0 0; }
@container chart (max-width: 720px) { .legend .src { display: none; } }
@container chart (max-width: 520px) { .legend .ohl { display: none; } }   /* C and % survive */

/* --- trading dock --- */
#dock { height: auto; max-height: none; }
#dock .dock-main { flex: none; height: clamp(150px, var(--dock-h, 340px), calc(45vh - 40px)); min-height: 0; }   /* the gutter now really sets the height */
#dockBody { container: dock / size; }
#ticket { overflow-y: auto; container-type: inline-size; }   /* no scrollbar-width: in Chromium 121+ it disables the skin's ::-webkit-scrollbar and brings back the light native bar */
#ticket .tk-go { position: sticky; bottom: -6px; z-index: 2; margin: 6px -8px -6px; padding: 6px 8px; background: var(--panel); box-shadow: 0 -1px 0 var(--line); }
#dock .dock-tabs button, .tabs button { height: calc(var(--ctl) - 4px); padding-block: 0; }
/* tables */
#dockBody table { width: auto; min-width: min(100%, 960px); }
#dockBody td, #dockBody th { height: var(--row); padding-block: 0; }
#dockBody :is(table.pos, table.ord) tr > :last-child { position: sticky; right: 0; z-index: 1; background: var(--panel); box-shadow: -12px 0 12px -12px rgba(0,0,0,.35); }
#dockBody :is(table.pos, table.ord) tr > th:last-child { z-index: 2; }
#dockBody :is(table.pos, table.ord) tr:hover > td:last-child { background: color-mix(in srgb, var(--text) 6.5%, var(--panel)); }   /* opaque: --hover is translucent */
@container dock (max-width: 760px) { #dockBody .c-mark { display: none; } }
#dockBody table.ord :is(th, td):nth-child(-n+3), #dockBody .jr table :is(th, td):nth-child(-n+3) { text-align: left; }
#dockBody table.kv { width: auto; min-width: 360px; }
#dockBody td.acts button, #dockBody th button { height: var(--ctl-sm); padding: 0 10px; margin-left: 4px; border-radius: var(--r-sm); background: var(--hover); font-size: var(--fs-meta); font-weight: 600; }
#dockBody td.acts button[data-close], #dockBody th button.danger { color: var(--down); background: color-mix(in srgb, var(--down) 14%, transparent); }
/* ticket controls and labelled fields */
.tk-l input[type=number], .tk-l input:not([type]), .tk-l input[type=password], .tk-l select, .tk-l button { height: var(--ctl); }
.tk-l button { border: 0; background: var(--hover); padding: 0 10px; font-weight: 600; }
.tk-l select { padding: 0 22px 0 8px; background-position: right 7px center; }
.tk-side button { height: calc(var(--ctl) - 4px); padding-block: 0; }
.tk-go button { height: var(--ctl-lg); padding-block: 0; }
.tk-l .fld { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: var(--ctl); padding: 0 8px; border-radius: var(--r-sm); background: var(--hover); border: 1px solid transparent; container-type: inline-size; }
.tk-l .fld:focus-within { border-color: var(--accent); background: var(--raised); }
.tk-l .fld > span { flex: none; font-size: var(--fs-meta); font-weight: 600; color: var(--muted); }
.tk-l .fld input[type=number], .tk-l .fld input[type=number]:focus { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: none; text-align: right; }
@container (max-width: 90px) { .fld > span { display: none; } }        /* the number wins over the label */
@container (max-width: 260px) { .tk-l:has(.typ) { flex-wrap: wrap; } .tk-l .typ { flex: 1 1 100%; } }
/* empty states, settings, journal toolbar, order book */
.cal-note { padding: 8px 14px; color: var(--muted); font-size: var(--fs-meta); line-height: 1.5; }
#dockBody > .cal-note:only-child { padding: 28px 16px; font-size: 12px; text-align: center; line-height: 1.6; }
#dockBody .cal-note kbd { padding: 1px 5px; border-radius: 4px; background: var(--hover); font: 600 11px var(--mono); }
#scan > .cal-note { padding: 0 14px 6px; }
.set { display: grid; gap: 8px; padding: 10px 14px; max-width: 900px; }
.set > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.set input:not([type=checkbox]) { height: var(--ctl); padding-block: 0; }
.set button:not(.on), .jr-top button:not(.on) { height: var(--ctl); padding: 0 12px; background: var(--hover); font-weight: 600; }
.jr-top select { height: var(--ctl); }
.book { grid-template-columns: minmax(300px, 1.2fr) minmax(220px, 1fr) minmax(260px, 1fr); }
.book .lad .a i { background: color-mix(in srgb, var(--down) 16%, transparent); }
.book .lad .b i { background: color-mix(in srgb, var(--up) 16%, transparent); }
.book .tape .r.big { background: color-mix(in srgb, var(--orange) 16%, transparent); }
.book .hd select { height: 20px; padding: 0 18px 0 6px; border: 0; background-color: var(--hover); background-position: right 4px center; border-radius: 5px; font-weight: 600; }

/* --- sidebar --- */
.colhead, #list li { grid-template-columns: 14px minmax(0, 1fr) 72px 60px 44px; column-gap: 6px; }
#list li { margin: 0 4px; padding: 7px 8px; }
.colhead { padding: 0 12px; overflow: hidden; scrollbar-gutter: stable; }
#list { scrollbar-gutter: stable; }              /* header and row numbers line up whether or not the list scrolls */
.lists select { border: 0; }
.lists select, .lists button, .filter input, aside > form input, aside > form button { height: var(--ctl); padding-block: 0; border-radius: var(--r-sm); }
.lists button[data-a] { min-width: var(--ctl); padding: 0 8px; display: inline-grid; place-items: center; }
.lists button[data-a="new"] { display: inline-flex; align-items: center; gap: 4px; }
aside > form button { padding: 0 14px; background: var(--tint); color: var(--accent); font-weight: 650; }
.i-plus { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><path d='M12 5v14M5 12h14'/></svg>"); }
.i-pencil { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linejoin='round'><path d='M4 20l1-4L16 5l3 3L8 19z'/><path d='M14 7l3 3'/></svg>"); }
.i-trash { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'><path d='M4 7h16M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3'/></svg>"); }
.lists .ic { width: 14px; height: 14px; }
aside h3 { padding: 12px 12px 6px; }
aside form { padding: 0 12px 10px; }
#alerts li { margin: 0 4px; padding: 6px 8px; }
#alerts li.empty { margin: 0; padding: 6px 12px !important; }
#alerts .empty .ic { width: 12px; height: 12px; vertical-align: -2px; }
/* calendar */
#cal .cal-f .imp { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 2px; }
#cal .cal-f button, #news .cal-f button { opacity: 1; color: var(--muted); }
.cal-sep { width: 1px; height: 14px; background: var(--line); margin: 0 2px; }
#cal .cal-ev { grid-template-columns: 40px 10px minmax(0, 1fr) auto; row-gap: 1px; }
#cal .cal-ev .ttl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cal .cal-ev .cd { font-size: var(--fs-meta); font-weight: 650; color: var(--orange); white-space: nowrap; }
#cal .cal-ev .fc { grid-column: 3 / -1; grid-row: 2; text-align: left; }
/* scanner: CSS-only repair */
.scan-cfg input, .scan-cfg select { height: var(--ctl-sm); }
.scan-cfg input { text-align: right; }
.scan-cfg select { padding: 0 20px 0 6px; background-position: right 5px center; }
.scan-cfg input::-webkit-inner-spin-button, .scan-cfg input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.scan-list .l1 { display: grid; grid-template-columns: minmax(0, 1fr) auto 64px; column-gap: 10px; }
.scan-list .l1 span { text-align: right; }

/* --- AI panel --- */
#aiLog { position: relative; scrollbar-gutter: stable; }   /* offsetTop is measured inside the log; no reflow when the scrollbar appears */
#aiLog .msg { word-break: keep-all; overflow-wrap: break-word; }
#ai .ai-head { box-sizing: border-box; height: var(--info-h); padding: 0 8px; gap: 4px; }   /* divider lines up with #info */
#ai .ai-head select, #ai .ai-head button { height: var(--ctl-sm); padding-block: 0; font-size: 12px; }
#ai #aiHist[hidden] { display: none; }
#ai textarea { resize: none; field-sizing: content; min-height: 38px; max-height: 32vh; }
#ai textarea:focus-visible { outline: none; }
#ai textarea:focus { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
#aiQuick { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
#aiQuick button { flex: none; }
.ai-ctl .ctx { position: relative; cursor: pointer; }
.ai-ctl .ctx input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.ai-ctl .ctx:has(input:checked) { background: var(--tint); color: var(--accent); }
.ai-ctl .ctx:has(input:focus-visible) { outline: 3px solid var(--tint); }
.ai-ctl .ring .trk { stroke: var(--seg); }
.ai-ctl .ring .val { stroke-linecap: butt; }
#aiLog .step { background: var(--hover); color: var(--muted); font-weight: 500; }   /* was blue-on-blue (3.1:1) and looked clickable */
#aiLog .stepsd { margin-bottom: 8px; font-size: var(--fs-meta); color: var(--muted); }
#aiLog .stepsd > summary { cursor: pointer; list-style: none; }
#aiLog .stepsd > summary::-webkit-details-marker { display: none; }
#aiLog .stepsd > summary::before { content: "▸ "; }
#aiLog .stepsd[open] > summary::before { content: "▾ "; }
#aiLog .stepsd .steps { margin: 6px 0 0; }
#aiLog .h { font-size: var(--fs-title); letter-spacing: -0.02em; margin: 14px 0 4px; }
#aiLog .msg > .h:first-child, #aiLog .steps + .h, #aiLog .stepsd + .h { margin-top: 0; }
#aiLog .q { color: var(--text); border-left: 0; padding: 7px 10px; margin: 6px 0; border-radius: 8px; background: var(--hover); box-shadow: inset 3px 0 0 var(--accent); }
#aiLog .li { padding-left: 1.1em; text-indent: -0.75em; }
#aiLog .tw { overflow-x: auto; margin: 10px 0; }
#aiLog table { width: auto; min-width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
#aiLog th, #aiLog td { border: 0; border-bottom: 1px solid var(--line); padding: 6px 10px; }
#aiLog tr:last-child td { border-bottom: 0; }
#aiLog th { font-size: var(--fs-meta); font-weight: 600; color: var(--muted); background: var(--hover); }
#aiLog tr:nth-child(odd) td { background: none; }
#aiLog .code, #aiLog img.svg { background: color-mix(in srgb, var(--text) 4%, var(--panel)); box-shadow: inset 0 0 0 1px var(--line); }   /* visible in light theme */
/* order summary: shared by the AI order card and the confirm dialog */
.osum-h { font-weight: 700; margin-bottom: 4px; }
.osum { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 16px; margin: 6px 0; }
.osum > div { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
.osum .k { color: var(--muted); }
.osum-r { font-size: var(--fs-meta); }
.ord-card { --side: var(--accent); box-shadow: inset 3px 0 0 var(--side); }
.ord-card.buy { --side: var(--up); } .ord-card.sell { --side: var(--down); }
.ord-card .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.ord-card .btns button { height: var(--ctl); border-radius: var(--r); font-weight: 600; background: var(--hover); }
.ord-card .btns button.on { background: var(--side); color: #fff; }

/* --- menus, confirm dialog, modals --- */
#menu { max-height: calc(100vh - 8px); overflow-y: auto; overscroll-behavior: contain; }
#menu .item { padding: 3px 10px 3px 6px; line-height: 20px; }
#menu .item.danger { color: var(--down); }
#menu .item.danger:hover { background: var(--down); color: #fff; }
.ask .box { width: min(460px, 92vw); padding: 20px 22px; gap: 14px; }
.ask .box > .small { font-size: var(--fs-body); line-height: 1.5; margin: 0; }
.ask .b button { height: 32px; min-width: 88px; padding-block: 0; }
.ask.buy .b .yes { background: var(--up); }
.ask.sell .b .yes, .ask.danger .b .yes { background: var(--down); }
.ask.live .box { box-shadow: var(--shadow), inset 0 3px 0 var(--orange); }
.ask.live .t { color: var(--orange); }
#modal { padding: 6vh 16px; }
#modal .box, #modal .box.wide { max-height: 100%; }
@media (max-height: 600px) { #modal { padding: 12px 16px; } }
#modal .body { overscroll-behavior: contain; }
#modal .body::-webkit-scrollbar-thumb { background-color: var(--seg); }   /* show that the body scrolls */
#modal .body input:not([type=checkbox]):not([type=color]):not(.q), #modal .body select, #modal .body button:not(.star) { height: var(--ctl); box-sizing: border-box; }
#modal .body input:not([type=checkbox]):not([type=color]):not(.q) { padding-block: 0; }
#modal .body button:not(.on):not(.star) { padding: 0 12px; background: var(--hover); font-weight: 600; }   /* secondary buttons no longer read as plain text */
#modal .body button:not(.on):not(.star):hover { background: color-mix(in srgb, var(--text) 12%, transparent); }
#modal table.eng button, #modal .pm-row button[data-r] { height: var(--ctl-sm); padding: 0 10px; font-size: 12px; border-radius: var(--r-pill); }
#modal label:has(> input[type=checkbox]) { display: inline-flex; align-items: center; gap: 8px; }
#modal input[type=checkbox] { margin: 0; width: 15px; height: 15px; flex: none; }
input[type=color] { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: none; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 6px; }
.srow .star, .srow .star.on { background: none; box-shadow: none; }   /* starred row was a filled blue pill */
.srow .star.on { color: var(--yellow); }
.srow.hl { background: var(--tint); }                                  /* keyboard highlight ≠ mouse hover */
.pm-sum { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px 12px; padding: 10px 12px; }
.pm-sum > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pm-sum .k { font-size: var(--fs-meta); color: var(--muted); }
.pm-sum b { font-size: var(--fs-title); font-weight: 700; }
#modal .jr { padding: 0; }
#modal .jr-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
#modal .jr-stats .chip { flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; border-radius: var(--r); font-size: var(--fs-title); font-weight: 700; }
#modal .jr-stats .chip .k { font-size: var(--fs-meta); font-weight: 500; }
@media (max-width: 760px) { #modal .jr-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
#modal .jr-trips :is(th, td):nth-child(-n+3), #modal .jr-trips th:last-child { text-align: left; }
#modal .jr > table.eng:not(.jr-trips) { width: auto; min-width: 50%; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 16px; text-align: center; }
.empty-state b { font-size: var(--fs-title); }

/* ---------- PC sync (chart/sync.js) ---------- */
#syncChip { height: var(--ctl); padding: 0 12px; border: 0; border-radius: var(--r-pill); background: var(--tint); color: var(--accent); font: 600 var(--fs-ctl) var(--font); cursor: pointer; white-space: nowrap; }
#syncChip:hover { filter: brightness(1.15); }
.sync-pane { display: flex; flex-direction: column; gap: 10px; min-width: min(520px, 80vw); font-size: var(--fs-body); }
.sync-pane .kv { display: grid; grid-template-columns: 84px 1fr; gap: 12px; align-items: baseline; }
.sync-pane .kv > span { color: var(--muted); }
.sync-pane .kv b { font-weight: 600; line-height: 1.6; }
.sync-pane .kv b button { margin-left: 8px; }
.sync-pane .row, .sync-pane .paste { display: flex; gap: 8px; flex-wrap: wrap; }
.sync-pane button { height: var(--ctl); padding: 0 14px; border-radius: var(--r); }
.sync-pane .paste input { flex: 1; min-width: 220px; height: var(--ctl); padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r); background-color: var(--bg); color: var(--text); font: var(--fs-ctl) var(--mono); }
.sync-pane p { margin: 4px 0 0; line-height: 1.6; }

/* ---------- cloud saves (chart/sync.js openSnapPanel) ---------- */
.snap-pane { display: flex; flex-direction: column; gap: 10px; min-width: min(640px, 86vw); font-size: var(--fs-body); }
.snap-pane .save-row { display: flex; gap: 8px; }
.snap-pane .save-row input { flex: 1; min-width: 0; height: var(--ctl-lg); padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r); background-color: var(--bg); color: var(--text); font: inherit; }
.snap-pane .save-row button { height: var(--ctl-lg); padding: 0 16px; border-radius: var(--r); font-weight: 700; white-space: nowrap; }
.snap-pane .auto { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: var(--fs-ctl); }
.snap-pane h4 { margin: 8px 0 0; font-size: var(--fs-ctl); font-weight: 700; }
.snap-pane .slot { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: var(--r-lg); background: var(--raised); box-shadow: 0 0 0 .5px var(--line); }
.snap-pane .slot.manual { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.snap-pane .slot .ic-s { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--hover); font-size: 20px; }
.snap-pane .slot .meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.snap-pane .slot .meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snap-pane .slot .meta span { font-size: var(--fs-meta); color: var(--muted); }
.snap-pane .slot .acts { display: flex; gap: 6px; }
.snap-pane .slot .acts button { height: var(--ctl); padding: 0 12px; border-radius: var(--r); }
.snap-pane p { margin: 2px 0; line-height: 1.6; }

/* long failed/stopped AI answers must not collapse and spill over the next message (found by the phone UI test) */
#aiLog .msg { flex-shrink: 0; }
