/* NexyWin — dark glass theme (Nexysys blue/violet lineage) */
:root {
  --bg: #0b0e17;
  --bg2: #101527;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e6eaf2;
  --muted: #9aa4b8;
  --accent: #7c8cff;
  --accent2: #b06cff;
  --up: #26a69a;
  --down: #ef5350;
  --gold: #f5c518;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

/* UA [hidden] loses to our display:flex rules without this */
[hidden] { display: none !important; }

/* custom scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(124, 140, 255, 0.35) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(124, 140, 255, 0.35), rgba(176, 108, 255, 0.3));
  border-radius: 8px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, rgba(124, 140, 255, 0.6), rgba(176, 108, 255, 0.55)); }
::-webkit-scrollbar-corner { background: transparent; }

/* custom svg icons */
.ic { display: inline-flex; width: 15px; height: 15px; flex: 0 0 auto; vertical-align: -2px; }
.ic svg { width: 100%; height: 100%; }
.ic-accent { color: var(--accent); }
button .ic { margin-right: 5px; }
.icon-btn .ic:only-child, #alertsBtn .ic { margin-right: 0; }
.dash-card h4 { display: flex; align-items: center; gap: 7px; }
.modal-box h3 .ic { width: 18px; height: 18px; vertical-align: -3px; }
.card-head .ic, .next-earn .ic, .alert-main .ic { width: 13px; height: 13px; margin-right: 4px; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, rgba(124, 140, 255, 0.12), transparent),
    radial-gradient(900px 500px at -10% 110%, rgba(176, 108, 255, 0.1), transparent), var(--bg);
  color: var(--text);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(11, 14, 23, 0.7);
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.logo { font-size: 20px; font-weight: 800; letter-spacing: 0.5px; }
.logo b { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { font-size: 10px; color: var(--muted); }

.search-wrap { position: relative; min-width: 220px; flex: 0 1 280px; }
.search-wrap input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  outline: none;
  font-size: 13px;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-results {
  display: none;
  position: absolute;
  top: 110%;
  left: 0;
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  overflow: hidden;
  z-index: 50;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.search-results.open { display: block; }
.search-item { display: flex; gap: 8px; align-items: baseline; padding: 8px 12px; cursor: pointer; font-size: 13px; }
.search-item:hover { background: rgba(124, 140, 255, 0.12); }
.search-item b { color: var(--accent); min-width: 84px; }
.search-item span { flex: 1; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item em { color: var(--muted); font-style: normal; font-size: 11px; }

.bars { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 260px; }
.pillbar { display: flex; gap: 4px; flex-wrap: wrap; }
.view-dash .bars { visibility: hidden; } /* chart-only controls, irrelevant on the dashboard */
.pillbar-sep { width: 1px; height: 18px; background: var(--panel-border); }
.pill {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.pill:hover { color: var(--text); background: var(--panel); }
.pill.active { color: var(--text); background: rgba(124, 140, 255, 0.18); border-color: rgba(124, 140, 255, 0.4); }
.pill.locked { color: var(--gold); opacity: 0.8; }

.top-actions { display: flex; align-items: center; gap: 8px; }
.lang-sel {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
}
.premium-btn {
  padding: 7px 14px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.premium-btn:hover { filter: brightness(1.1); }

/* ---------- layout ---------- */
.layout { flex: 1; display: flex; min-height: 0; }
.chart-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 12px; gap: 8px; }
.sym-head { display: flex; align-items: baseline; gap: 12px; padding: 0 4px; }
.sym-title { font-size: 15px; font-weight: 700; }
.sym-price { font-size: 15px; font-weight: 600; color: var(--text); }
.sym-change { font-size: 13px; font-weight: 600; }
.evt-toggle { border: 1px solid var(--panel-border); }
#evtBtn { margin-left: auto; }
.evt-toggle.active { color: var(--text); background: rgba(176, 108, 255, 0.18); border-color: rgba(176, 108, 255, 0.5); }

/* news & earnings card */
.news-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.news-item { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.4; }
.news-item a { color: var(--text); text-decoration: none; }
.news-item a:hover { color: var(--accent); }
.news-item .meta { color: var(--muted); font-size: 10px; }
.senti { flex: 0 0 auto; min-width: 38px; text-align: center; padding: 2px 5px; border-radius: 6px; font-size: 10px; font-weight: 700; background: rgba(255,255,255,0.07); color: var(--muted); }
.senti.pos { background: rgba(38,166,154,0.2); color: var(--up); }
.senti.neg { background: rgba(239,83,80,0.2); color: var(--down); }
.eps-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 6px; }
.eps-table th, .eps-table td { padding: 3px 6px; text-align: right; border-bottom: 1px solid var(--panel-border); white-space: nowrap; }
.eps-table th:first-child, .eps-table td:first-child { text-align: left; }
.eps-table th { color: var(--muted); font-weight: 600; }
.next-earn { font-size: 11px; color: var(--gold); margin-top: 4px; }
.up { color: var(--up); }
.down { color: var(--down); }
/* multi-pane chart grid */
.chart-grid { flex: 1; display: grid; gap: 8px; min-height: 0; }
.chart-grid.layout-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.chart-grid.layout-2h { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.chart-grid.layout-2v { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
.chart-grid.layout-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.pane { position: relative; border: 1px solid var(--panel-border); border-radius: 14px; background: var(--panel); overflow: hidden; min-height: 0; display: flex; flex-direction: column; }
.pane.active { border-color: rgba(124, 140, 255, 0.55); box-shadow: 0 0 0 1px rgba(124, 140, 255, 0.25); }
.chart-grid.layout-1 .pane { border-color: var(--panel-border); box-shadow: none; }
.pane-tag { position: absolute; top: 6px; left: 8px; z-index: 5; font-size: 10px; color: var(--muted); background: rgba(11, 14, 23, 0.65); padding: 2px 7px; border-radius: 6px; pointer-events: none; }
.chart-grid.layout-1 .pane-tag { display: none; }
.pane-chart { flex: 1; min-height: 0; }
.layout-tabs { display: flex; gap: 2px; margin-left: 8px; }
.layout-tabs .lt { padding: 5px 7px; border: 1px solid transparent; }
.layout-tabs .lt.active { color: var(--text); background: rgba(124, 140, 255, 0.18); border-color: rgba(124, 140, 255, 0.4); }
.layout-tabs .lt .ic { margin-right: 0; }
.layout-tabs .ic-lock { width: 9px; height: 9px; margin-left: 2px; color: var(--gold); }

/* ---------- chat pane ---------- */
.chat-pane {
  width: 400px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--panel-border);
  background: rgba(16, 21, 39, 0.6);
  backdrop-filter: blur(10px);
  min-height: 0;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--panel-border);
  font-weight: 700;
  font-size: 14px;
}
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); box-shadow: 0 0 8px var(--up); }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 10px 13px; border-radius: 14px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, rgba(124, 140, 255, 0.35), rgba(176, 108, 255, 0.3)); border: 1px solid rgba(124, 140, 255, 0.4); }
.msg.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--panel-border); }
.msg.ephemeral { opacity: 0.6; font-style: italic; }
.msg.flash { animation: msg-flash 0.5s ease; }
@keyframes msg-flash { 0% { border-color: var(--accent); box-shadow: 0 0 10px rgba(124, 140, 255, 0.4); } 100% { box-shadow: none; } }

/* result card */
.msg.card { width: 92%; }
.card-head { font-weight: 700; font-size: 12px; color: var(--accent); margin-bottom: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; margin-bottom: 10px; }
.stat-grid label { display: block; font-size: 10px; color: var(--muted); margin-bottom: 2px; }
.stat-grid b { font-size: 14px; }
.eq-label { font-size: 10px; color: var(--muted); }
.equity { width: 100%; height: 60px; display: block; margin: 4px 0 6px; }
.markers-note { font-size: 11px; color: var(--gold); margin-bottom: 6px; }
.msg.card details { margin-top: 6px; font-size: 12px; }
.msg.card summary { cursor: pointer; color: var(--muted); }
.msg.card pre { margin-top: 6px; padding: 8px; background: rgba(0, 0, 0, 0.35); border-radius: 8px; font-size: 10px; overflow-x: auto; }
.trades { max-height: 180px; overflow-y: auto; margin-top: 6px; }
.trades table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.trades th, .trades td { padding: 3px 5px; text-align: left; border-bottom: 1px solid var(--panel-border); white-space: nowrap; }
.trades th { color: var(--muted); font-weight: 600; }
.disclaimer-inline { margin-top: 8px; font-size: 9.5px; color: var(--muted); opacity: 0.8; }

.suggestions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 8px; }
.chip {
  padding: 6px 10px;
  border-radius: 20px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--accent); }

.chat-form { display: flex; gap: 8px; padding: 10px 14px 14px; border-top: 1px solid var(--panel-border); }
.chat-form input {
  flex: 1;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  outline: none;
  font-size: 13px;
}
.chat-form input:focus { border-color: var(--accent); }
.chat-form button {
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- dashboard ---------- */
.view-tabs { display: flex; gap: 4px; }
.view-tabs .pill { border: 1px solid var(--panel-border); }
.view-tabs .pill.active { color: var(--text); background: rgba(124, 140, 255, 0.18); border-color: rgba(124, 140, 255, 0.4); }
.dash-pane { flex: 1; min-width: 0; overflow-y: auto; padding: 14px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 1100px; margin: 0 auto; }
.dash-card { border: 1px solid var(--panel-border); border-radius: 14px; background: var(--panel); padding: 14px 16px; min-width: 0; }
.dash-card.wide { grid-column: 1 / -1; }
.dash-card h4 { font-size: 13px; margin-bottom: 10px; color: var(--text); }
.dash-news-sym { color: var(--accent); font-size: 12px; }
.dash-hero { background: linear-gradient(135deg, rgba(124,140,255,0.12), rgba(176,108,255,0.08)); border-color: rgba(124,140,255,0.3); }
.dash-hero h3 { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.dash-chat { padding: 0; border-top: none; }
.dash-chat input { font-size: 14px; padding: 12px 15px; }
.mkt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.mkt-card { border: 1px solid var(--panel-border); border-radius: 10px; padding: 8px 10px; cursor: pointer; background: rgba(0,0,0,0.15); }
.mkt-card:hover { border-color: var(--accent); }
.mkt-card .nm { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mkt-card .px { font-size: 14px; font-weight: 700; margin: 2px 0; }
.mkt-card .chg { font-size: 11px; font-weight: 600; }
.mkt-card canvas { width: 100%; height: 28px; display: block; margin-top: 4px; }
.up-events { display: flex; flex-direction: column; gap: 6px; }
.up-event { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 6px 8px; border-radius: 8px; background: rgba(0,0,0,0.15); }
.up-event .dday { min-width: 42px; text-align: center; font-weight: 700; color: var(--gold); font-size: 11px; }
.up-event .kind { padding: 1px 7px; border-radius: 6px; font-size: 10px; font-weight: 700; }
.kind-CPI { background: rgba(255,143,208,0.2); color: #ff8fd0; }
.kind-FOMC { background: rgba(176,108,255,0.2); color: #b06cff; }
.kind-NFP { background: rgba(95,212,255,0.2); color: #5fd4ff; }
.up-event .dt { color: var(--muted); margin-left: auto; font-size: 11px; }
.up-event.past { opacity: 0.55; }
.up-event.past .dday { color: var(--muted); }
.up-sub { font-size: 10px; color: var(--muted); margin: 8px 0 2px; text-transform: uppercase; letter-spacing: 0.5px; }
/* scenario card */
.scen-sym { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.scen-row { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 5px 8px; border-radius: 8px; background: rgba(0,0,0,0.15); margin-bottom: 4px; }
.scen-row .sc { width: 16px; text-align: center; }
.scen-row b { margin-left: auto; }
.scen-row .scv { min-width: 84px; text-align: right; color: var(--muted); font-size: 11.5px; }
.scen-probs { font-size: 12px; color: var(--text); margin: 8px 2px 2px; }
.sim-list { display: flex; flex-direction: column; gap: 6px; }
.sim-item { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 7px 9px; border-radius: 8px; background: rgba(0,0,0,0.15); cursor: pointer; border: 1px solid transparent; }
.sim-item:hover { border-color: var(--accent); }
.sim-item .sym { font-weight: 700; }
.sim-item .ret { margin-left: auto; font-weight: 700; }
.sim-item .meta { color: var(--muted); font-size: 10.5px; }
.dash-empty { font-size: 12px; color: var(--muted); padding: 4px 0; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } .view-tabs { order: 3; } }

/* delayed-quote badge */
.delay-badge { font-size: 9px; color: var(--muted); border: 1px solid var(--panel-border); border-radius: 5px; padding: 2px 6px; opacity: 0.75; white-space: nowrap; }

/* onboarding callout */
.onboard { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 12px; border: 1px dashed rgba(124, 140, 255, 0.45); border-radius: 10px; font-size: 12.5px; color: var(--text); background: rgba(124, 140, 255, 0.07); }
.onboard .chip { border-color: var(--accent); color: var(--text); }
.onboard-x { margin-left: auto; }

/* result card actions + sweep card */
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.sweep-rows { display: flex; flex-direction: column; gap: 3px; margin: 8px 0; }
.sweep-row { display: flex; align-items: center; gap: 7px; font-size: 11px; padding: 3px 6px; border-radius: 6px; }
.sweep-row.best { background: rgba(245, 197, 24, 0.1); border: 1px solid rgba(245, 197, 24, 0.35); }
.sweep-row .sv { min-width: 34px; font-weight: 700; }
.sweep-row .sbar { flex: 1; height: 7px; background: rgba(255, 255, 255, 0.06); border-radius: 4px; overflow: hidden; }
.sweep-row .sbar i { display: block; height: 100%; border-radius: 4px; }
.sweep-row .sbar i.pos { background: linear-gradient(90deg, rgba(38, 166, 154, 0.5), #26a69a); }
.sweep-row .sbar i.neg { background: linear-gradient(90deg, rgba(239, 83, 80, 0.5), #ef5350); }
.sweep-row .sret { min-width: 62px; text-align: right; font-weight: 700; }
.sweep-row .smeta { color: var(--muted); font-size: 10px; min-width: 78px; }
.sweep-row .sbest { color: var(--gold); font-size: 10px; font-weight: 700; }
.apply-best { margin-top: 4px; }
.payoff { width: 100%; height: 120px; display: block; margin: 6px 0; }
.greeks { font-size: 10.5px; color: var(--muted); margin-top: 4px; letter-spacing: 0.3px; }

/* icon buttons + alerts modal */
.icon-btn { border: 1px solid var(--panel-border); }
.alerts-box { text-align: left; max-height: 80vh; overflow-y: auto; }
.alerts-box h4 { margin: 14px 0 6px; font-size: 12px; color: var(--muted); }
.alerts-list, .fired-list { display: flex; flex-direction: column; gap: 6px; }
.alert-item { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--panel-border); border-radius: 10px; background: var(--panel); }
.alert-item.off { opacity: 0.5; }
.alert-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.alert-main b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-main .meta { font-size: 10.5px; color: var(--muted); }
.alert-empty { font-size: 12px; color: var(--muted); padding: 6px 0; }
.fired-item { font-size: 11px; color: var(--muted); padding: 3px 0; border-bottom: 1px solid var(--panel-border); }
.mk-alert { margin-top: 8px; }
.alerts-box .premium-btn { margin-top: 14px; width: 100%; }

/* ---------- footer / modal ---------- */
.footer { padding: 6px 16px; font-size: 10px; color: var(--muted); border-top: 1px solid var(--panel-border); text-align: center; }
.footer-sep { margin: 0 6px; opacity: 0.5; }
.footer .tv-attr { color: var(--muted); text-decoration: none; border-bottom: 1px dotted rgba(154, 164, 184, 0.5); }
.footer .tv-attr:hover { color: var(--text); }
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal.open { display: flex; }
.modal-box {
  width: min(420px, 90vw);
  background: var(--bg2);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 26px;
  text-align: center;
}
.modal-box h3 { margin-bottom: 12px; font-size: 17px; }
.modal-box p { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 10px; }
.modal-box .soon { color: var(--gold); }
.modal-box button { margin-top: 8px; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  .layout { flex-direction: column; }
  .chart-pane { min-height: 46vh; }
  .chart { min-height: 40vh; }
  .chat-pane { width: 100%; border-left: none; border-top: 1px solid var(--panel-border); min-height: 50vh; }
  .chat-log { max-height: 40vh; }
  .tagline { display: none; }
  /* iOS zooms inputs under 16px — keep chat/search inputs at 16px */
  .chat-form input, .search-wrap input { font-size: 16px; }
  /* interval/range pills: single scrollable row instead of wrapping */
  .bars { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .bars::-webkit-scrollbar { display: none; }
  .pillbar { flex-wrap: nowrap; }
  .pill { white-space: nowrap; padding: 7px 11px; } /* bigger touch targets */
  .search-wrap { flex: 1 1 100%; order: 5; }
  .sym-head { flex-wrap: wrap; row-gap: 4px; }
  .delay-badge { display: none; }
  .chat-form { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .dash-pane { padding: 10px; }
  .mkt-grid { grid-template-columns: repeat(2, 1fr); }
}
