:root {
  --bg: #0b1220;
  --bg-elev: #121a2b;
  --bg-card: #162033;
  --line: #243049;
  --text: #e8eefc;
  --muted: #93a0b8;
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --red: #f43f5e;
  --red-dim: rgba(244, 63, 94, 0.12);
  --blue: #60a5fa;
  --amber: #fbbf24;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --font: "Pretendard", "Noto Sans KR", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(96, 165, 250, 0.12), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 197, 94, 0.08), transparent 45%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 12px;
  box-sizing: border-box;
}
.container-full {
  width: 100%;
  max-width: none;
  padding: 0 10px 20px;
}
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0 4px;
}
.top-bar-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.top-bar-text strong {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.top-bar-text span {
  color: var(--muted);
  font-size: 13px;
}
.top-badges { margin-top: 0; }
.disclaimer-banner.slim {
  margin: 8px 0 12px;
  padding: 8px 12px;
  font-size: 12px;
}

/* 좌: 표 / 중: 뉴스 / 우: 채팅 */
.dash-layout {
  display: grid;
  gap: 10px;
  align-items: start;
  margin-top: 8px;
}
.dash-layout.dash-3col {
  /* 표 · 뉴스(더 좁게) · 채팅(더 넓게) */
  grid-template-columns: minmax(340px, 1.3fr) minmax(180px, 0.55fr) minmax(300px, 0.95fr);
}
.dash-col-table,
.dash-col-news,
.dash-col-chat {
  min-width: 0;
  align-self: start;
}
.dash-col-news,
.dash-col-chat {
  position: sticky;
  top: 64px;
}
.dash-col-table .table-wrap {
  max-height: calc(100vh - 200px);
  overflow: auto;
}
.news-scroll {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
.chat-side {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  min-height: 420px;
  max-height: calc(100vh - 120px);
}
.chat-side .chat-bd {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 10px 12px 12px;
}
.chat-side .chat-list {
  flex: 1;
  height: auto;
  min-height: 180px;
  max-height: none;
}
/* 좁은 화면: 표 → 뉴스 → 채팅 세로 */
@media (max-width: 1100px) {
  .dash-layout.dash-3col {
    grid-template-columns: 1fr 1fr;
  }
  .dash-col-chat {
    grid-column: 1 / -1;
    position: relative;
    top: 0;
  }
  .dash-col-news {
    position: relative;
    top: 0;
  }
  .chat-side .chat-list {
    height: 260px;
  }
}
@media (max-width: 720px) {
  .dash-layout.dash-3col {
    grid-template-columns: 1fr;
  }
  .dash-col-table .table-wrap,
  .news-scroll {
    max-height: none;
  }
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(11, 18, 32, 0.85);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}
.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #22c55e);
  font-weight: 800;
  font-size: 14px;
}
.logo strong { display: block; font-size: 16px; letter-spacing: -0.02em; }
.logo small { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }

.nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 14px;
}
.nav a:hover,
.nav a.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}

.menu-btn {
  display: none;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 10px;
  width: 42px;
  height: 42px;
  cursor: pointer;
}

/* Hero / banners (compact on dashboard) */
.hero {
  padding: 16px 0 10px;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.25rem, 2.4vw, 1.75rem);
  letter-spacing: -0.03em;
  line-height: 1.25;
}
.hero p {
  margin: 0;
  color: var(--muted);
  max-width: none;
  font-size: 14px;
}
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.badge {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
}
.badge.warn {
  border-color: rgba(251, 191, 36, 0.35);
  color: var(--amber);
  background: rgba(251, 191, 36, 0.08);
}

.disclaimer-banner {
  margin: 12px 0 24px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
  color: #fde68a;
  font-size: 13px;
}

/* Controls */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.sort-tabs .tab {
  font-weight: 700;
}
.sort-tabs .tab.active {
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.45);
  color: #bbf7d0;
}
.sort-tabs .tab[data-sort="losers"].active {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fecdd3;
}
.live-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.live-badge.is-on {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.12);
}
.live-badge.is-off {
  color: #fecaca;
  border-color: rgba(244, 63, 94, 0.35);
  background: rgba(244, 63, 94, 0.08);
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}
.live-badge.is-on .live-dot {
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  animation: chatPulse 1.6s infinite;
}
.live-badge.is-off .live-dot {
  background: #f43f5e;
}
tr.stock-row.row-flash td {
  animation: rowFlash 1.2s ease;
}
@keyframes rowFlash {
  0% { background: rgba(250, 204, 21, 0.28); }
  100% { background: transparent; }
}
.tab,
.btn {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.tab.active {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.45);
  color: #dbeafe;
}
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: transparent;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.meta-line {
  color: var(--muted);
  font-size: 13px;
}

/* Cards / grid */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .menu-btn { display: inline-grid; place-items: center; }
  .nav {
    display: none;
    position: absolute;
    right: 12px;
    top: 64px;
    flex-direction: column;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 8px;
    min-width: 180px;
    box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.card-hd h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.card-bd { padding: 0; }

/* Table */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(36, 48, 73, 0.9);
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.15);
}
tr:hover td { background: rgba(255, 255, 255, 0.02); }
.sym {
  font-weight: 700;
  color: var(--text);
}
.sym small {
  display: block;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.up { color: var(--green); font-weight: 700; }
.down { color: var(--red); font-weight: 700; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.pill.up { background: var(--green-dim); color: var(--green); }
.pill.down { background: var(--red-dim); color: var(--red); }
.risk-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  background: rgba(251, 191, 36, 0.15);
  color: var(--amber);
  border: 1px solid rgba(251, 191, 36, 0.35);
}
tr.row-extreme td {
  background: rgba(251, 191, 36, 0.04);
}
tr.stock-row {
  cursor: pointer;
}
tr.stock-row:hover td {
  background: rgba(96, 165, 250, 0.1);
}
tr.stock-row.is-focus td {
  background: rgba(96, 165, 250, 0.16);
  box-shadow: inset 3px 0 0 #60a5fa;
}
tr.stock-row .sym {
  display: block;
  font-weight: 700;
  color: var(--text);
}
tr.stock-row .sym small {
  display: block;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* News list */
.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li {
  border-bottom: 1px solid var(--line);
}
.news-list a {
  display: block;
  padding: 14px 16px;
  color: var(--text);
  text-decoration: none;
}
.news-list a:hover { background: rgba(255, 255, 255, 0.03); }
.news-list .src {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.news-list .title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
}
.news-list .title-en {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  font-weight: 400;
}
.news-list .summary {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: #c5d0e6;
  background: rgba(96, 165, 250, 0.08);
  border: 1px solid rgba(96, 165, 250, 0.18);
  border-radius: 10px;
  padding: 8px 10px;
}
.news-list .related {
  margin-top: 6px;
  font-size: 12px;
  color: var(--blue);
}

/* States */
.state {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.state.error { color: #fecaca; }

/* Guide pages */
.prose {
  padding: 28px 0 60px;
}
.prose .card { padding: 22px; }
.prose h1 { margin-top: 0; font-size: 1.7rem; }
.prose h2 { font-size: 1.15rem; margin-top: 1.6em; }
.prose p, .prose li { color: #c9d4ea; }
.prose ul { padding-left: 1.2em; }
.prose code {
  background: rgba(255,255,255,0.06);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.92em;
}

.section-title {
  margin: 28px 0 12px;
  font-size: 1.05rem;
}

.kr {
  margin: 48px 0 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 700px) {
  .footer { grid-template-columns: 1fr; }
}
.footer .card { padding: 16px; }
.footer h3 { margin: 0 0 8px; font-size: 14px; }
.footer p, .footer li {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.footer ul { margin: 0; padding-left: 1.1em; }
.copyright {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding-bottom: 28px;
}

/* Chat — 메신저 스타일 */
.chat-card { margin-bottom: 0; overflow: hidden; }
.chat-card .card-hd {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.25), rgba(34, 197, 94, 0.12));
}
.chat-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: chatPulse 1.6s infinite;
  margin-right: 6px;
  vertical-align: middle;
}
.chat-live-dot.off { background: #f43f5e; animation: none; }
@keyframes chatPulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.chat-bd { padding: 14px 16px 16px; }
.chat-disclaimer {
  margin: 0 0 8px;
  font-size: 11px;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 10px;
  padding: 8px 10px;
  line-height: 1.4;
  flex-shrink: 0;
}
.chat-list {
  height: min(360px, 50vh);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(600px 200px at 50% 0%, rgba(37, 99, 235, 0.08), transparent 60%),
    rgba(0, 0, 0, 0.28);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 36px 12px;
  margin: auto;
  line-height: 1.5;
}
.chat-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 100%;
}
.chat-row.mine {
  flex-direction: row-reverse;
}
.chat-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #0b1220;
  background: linear-gradient(135deg, #60a5fa, #34d399);
}
.chat-row.mine .chat-avatar {
  background: linear-gradient(135deg, #a78bfa, #60a5fa);
}
.chat-bubble-wrap {
  max-width: min(85%, 280px);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-row.mine .chat-bubble-wrap { align-items: flex-end; }
.chat-nick {
  color: #93c5fd;
  font-weight: 700;
  font-size: 11px;
  padding: 0 4px;
}
.chat-row.mine .chat-nick { color: #c4b5fd; }
.chat-bubble {
  border-radius: 16px;
  padding: 9px 12px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  color: var(--text);
  background: #1e2a40;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  border-bottom-left-radius: 6px;
}
.chat-row.mine .chat-bubble {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: transparent;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 6px;
}
.chat-time {
  color: var(--muted);
  font-size: 10px;
  padding: 0 4px;
}
.chat-status {
  margin: 6px 0 8px;
  min-height: 1.1em;
  font-size: 11px;
  flex-shrink: 0;
}
.chat-status.error { color: #fecaca; }
.chat-form {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid rgba(36, 48, 73, 0.9);
  margin-top: 2px;
}
.chat-side .chat-form {
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "nick nick"
    "text send";
}
.chat-side .chat-nick { grid-area: nick; }
.chat-side .chat-text { grid-area: text; }
.chat-side #chatSend { grid-area: send; min-width: 72px; height: 42px; }
@media (max-width: 640px) {
  .chat-form {
    grid-template-columns: 1fr;
  }
}
.chat-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.chat-input:focus {
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12);
}
.chat-input.chat-text {
  border-radius: 20px;
  padding-left: 14px;
}

.kr-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.chip {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.12);
  color: #bfdbfe;
  border: 1px solid rgba(96, 165, 250, 0.25);
  cursor: pointer;
}
.chip:hover { background: rgba(96, 165, 250, 0.2); }

.kr-kr a.btn {
  display: inline-block;
  margin: 4px 6px 4px 0;
  text-decoration: none;
}
