/* ============ 기본 / 토큰 ============ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --bg: #0E1525;
  --bg-elev: #131C32;
  --bg-elev-2: #1A2542;
  --line: #243154;
  --line-soft: #1B2745;
  --text: #F5F7FA;
  --text-mute: #93A0BD;
  --text-dim: #6A7796;
  --up: #E53935;
  --down: #1E88E5;
  --gold: #F5B400;
  --gold-soft: rgba(245, 180, 0, 0.18);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.22);
  --radius: 14px;
  --radius-sm: 10px;
  --pad: 16px;
  --grid-gap: 14px;
  --maxw: 1240px;
  --font: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
  --mono: 'SF Mono', 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

body[data-theme="light"] {
  --bg: #F7F9FC;
  --bg-elev: #FFFFFF;
  --bg-elev-2: #FFFFFF;
  --line: #E4E8F0;
  --line-soft: #EEF1F7;
  --text: #1A1A1A;
  --text-mute: #5C6577;
  --text-dim: #8A92A6;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 2px 10px rgba(15, 23, 42, 0.06);
}

html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }

/* ============ 상단바 ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg) 60%, rgba(14, 21, 37, 0.85) 100%);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
body[data-theme="light"] .topbar {
  background: linear-gradient(180deg, #FFFFFF 0%, #FFFFFF 60%, rgba(255,255,255,0.9) 100%);
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 20px 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
}

.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px var(--gold-soft);
  display: inline-block; align-self: center;
}
.brand-name { font-weight: 800; letter-spacing: -0.01em; font-size: 17px; }
.brand-sub  { color: var(--text-dim); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }

.search {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  height: 40px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}
.search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.search-icon { color: var(--text-mute); flex: none; }
.search input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: var(--text);
  font-size: 14px;
}
.search input::placeholder { color: var(--text-dim); }
.search-clear {
  background: transparent; border: 0; color: var(--text-mute);
  font-size: 22px; line-height: 1; padding: 0 4px;
  display: none;
}
.search.has-value .search-clear { display: inline-block; }

.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text-mute);
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s ease, border-color .15s ease, transform .15s ease;
}
.icon-btn:hover { color: var(--gold); border-color: var(--gold); transform: translateY(-1px); }
.user-chip {
  display: inline-flex; align-items: center;
  height: 38px; padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  max-width: 180px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.auth-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 38px; padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color .15s ease, border-color .15s ease, background .15s ease, transform .15s ease;
}
.auth-btn:hover { color: var(--gold); border-color: var(--gold); transform: translateY(-1px); }
.auth-btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1606;
}
.auth-btn-primary:hover { background: #ffc926; border-color: #ffc926; color: #1a1606; }

/* ============ 지수 바 ============ */
.indices {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 6px 20px 14px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.idx {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
  position: relative;
  overflow: hidden;
}
.idx::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.35;
}
.idx-name { font-size: 12px; color: var(--text-mute); letter-spacing: 0.02em; }
.idx-price { font-family: var(--mono); font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.idx-change { font-size: 12px; font-family: var(--mono); display: flex; gap: 6px; align-items: center; }
.idx-change .arrow { font-size: 10px; }
.up   { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--text-mute); }

/* ============ 메인 ============ */
.main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px 20px 60px;
  display: flex; flex-direction: column; gap: 36px;
}

.section { display: flex; flex-direction: column; gap: 14px; }
.section-head {
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  flex-wrap: wrap;
}
.section-title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.section-sub { color: var(--text-mute); font-size: 13px; }

.chips, .tabs {
  display: inline-flex; gap: 6px; flex-wrap: wrap;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  position: relative;
}
.chip, .tab {
  background: transparent;
  border: 0;
  color: var(--text-mute);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  transition: color .15s ease, background .15s ease;
  position: relative;
  z-index: 1;
}
.chip:hover, .tab:hover { color: var(--text); }
.chip.active, .tab.active {
  color: var(--text);
  background: var(--bg-elev-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
body[data-theme="light"] .chip.active,
body[data-theme="light"] .tab.active {
  background: #F0F3F9;
}

/* ============ 종목 카드 ============ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--grid-gap);
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  position: relative;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
  overflow: hidden;
}
.card:hover {
  transform: translateY(-3px);
  border-color: rgba(245, 180, 0, 0.5);
  box-shadow: var(--shadow);
}
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-ident { min-width: 0; }
.card-name {
  font-weight: 700; font-size: 15px;
  letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-ticker {
  display: flex; gap: 8px; align-items: center;
  font-size: 11px; color: var(--text-mute);
  font-family: var(--mono);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.card-ticker .mkt {
  padding: 2px 6px; border-radius: 4px;
  background: var(--bg-elev-2);
  color: var(--text-mute);
  font-size: 10px;
}
.fav-btn {
  background: transparent; border: 0;
  color: var(--text-dim);
  font-size: 20px; line-height: 1;
  padding: 2px 4px;
  transition: color .15s ease, transform .15s ease;
}
.fav-btn:hover { color: var(--gold); transform: scale(1.12); }
.fav-btn.is-fav { color: var(--gold); }

.card-price-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.card-price {
  font-family: var(--mono);
  font-size: 20px; font-weight: 700; letter-spacing: -0.01em;
}
.card-change {
  font-family: var(--mono); font-size: 13px;
  display: inline-flex; gap: 4px; align-items: baseline;
}

.sparkline {
  width: 100%;
  height: 56px;
  display: block;
}

.card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rec-pill {
  font-size: 11px; font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.rec-buy  { color: var(--up);   background: rgba(229, 57, 53, 0.12); border-color: rgba(229, 57, 53, 0.35); }
.rec-hold { color: var(--gold); background: var(--gold-soft);        border-color: rgba(245, 180, 0, 0.45); }
.rec-sell { color: var(--down); background: rgba(30, 136, 229, 0.12); border-color: rgba(30, 136, 229, 0.35); }

.card-sector { color: var(--text-dim); font-size: 12px; }

.empty {
  color: var(--text-mute);
  font-size: 13px;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  text-align: center;
}

/* ============ 뉴스 ============ */
.tabs { position: relative; }
.news-viewport {
  position: relative;
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.news-track {
  display: flex;
  width: 200%;
  transition: transform .35s cubic-bezier(.22,.61,.36,1);
}
.news-track[data-pane="global"] { transform: translateX(-50%); }
.news-pane { width: 50%; padding: 8px 0; }
.news-list { display: flex; flex-direction: column; }
.news-item {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background .15s ease;
}
.news-item:first-child { border-top: 0; }
.news-item:hover { background: var(--bg-elev-2); }
body[data-theme="light"] .news-item:hover { background: #F0F3F9; }
.news-thumb {
  width: 84px; height: 60px;
  border-radius: 8px;
  background: var(--bg-elev-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  overflow: hidden;
  position: relative;
}
.news-thumb::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--accent1, #2a3658), var(--accent2, #4a5a8a));
  opacity: 0.9;
}
.news-thumb span { position: relative; color: #fff; font-weight: 700; letter-spacing: 0.04em; font-size: 12px; }
.news-body { min-width: 0; }
.news-title {
  font-size: 14px; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
}
.news-meta {
  margin-top: 6px;
  color: var(--text-mute); font-size: 11.5px;
  display: flex; gap: 8px; align-items: center;
}
.news-meta .dot { color: var(--text-dim); }
.news-tag {
  align-self: start;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

/* ============ 푸터 ============ */
.footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px;
  color: var(--text-dim);
  font-size: 12px;
  border-top: 1px solid var(--line);
  text-align: center;
}

/* ============ 모달 ============ */
.modal {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.is-open { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(5, 9, 20, 0.7);
  backdrop-filter: blur(6px);
  animation: fadeIn .18s ease;
}
.modal-card {
  position: relative;
  width: min(880px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  animation: popIn .25s cubic-bezier(.22,.61,.36,1);
}
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text-mute);
  font-size: 22px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, transform .15s, border-color .15s;
}
.modal-close:hover { color: var(--up); border-color: var(--up); transform: rotate(90deg); }

.detail-head { display: flex; flex-direction: column; gap: 6px; padding-right: 50px; }
.detail-id { display: flex; gap: 10px; align-items: center; color: var(--text-mute); font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; }
.detail-id .market { padding: 2px 8px; background: var(--bg-elev-2); border-radius: 6px; font-size: 10.5px; }
.detail-name { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.detail-price-row { display: flex; align-items: baseline; gap: 12px; margin-top: 6px; }
.detail-price { font-family: var(--mono); font-size: 26px; font-weight: 800; }
.detail-change { font-family: var(--mono); font-size: 14px; }
.detail-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.btn-ghost {
  height: 34px; padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-ghost.is-fav { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }

.detail-chart-wrap {
  margin-top: 20px;
  background: var(--bg-elev-2);
  border-radius: 12px;
  padding: 14px;
}
.chart-tools { display: inline-flex; gap: 4px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-bottom: 8px; }
.range {
  background: transparent; border: 0;
  color: var(--text-mute);
  padding: 5px 12px; border-radius: 999px;
  font-size: 11.5px; font-family: var(--mono); letter-spacing: 0.04em;
}
.range:hover { color: var(--text); }
.range.active { background: var(--bg-elev-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
body[data-theme="light"] .range.active { background: #F0F3F9; }
.detail-chart { width: 100%; height: 220px; display: block; }

.detail-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.metric {
  background: var(--bg-elev-2);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.metric-label { color: var(--text-mute); font-size: 11.5px; letter-spacing: 0.02em; }
.metric-value { font-family: var(--mono); font-size: 15px; font-weight: 700; }

.detail-note { margin-top: 20px; }
.detail-note h4 {
  margin: 0 0 8px; font-size: 13px; color: var(--text-mute);
  letter-spacing: 0.04em; text-transform: uppercase; font-weight: 700;
}
.detail-note p {
  margin: 0; line-height: 1.65; color: var(--text);
  background: var(--bg-elev-2);
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
  padding: 14px 16px;
}

/* ============ 토스트 ============ */
.toast-stack {
  position: fixed;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toastIn .25s ease, toastOut .3s ease forwards;
  animation-delay: 0s, 2.3s;
}
.toast.toast-err { border-color: rgba(229, 57, 53, 0.6); color: var(--up); }
.toast.toast-ok  { border-color: rgba(30, 136, 229, 0.5); }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes popIn  { from { opacity: 0; transform: translateY(8px) scale(.98) } to { opacity: 1; transform: none } }
@keyframes toastIn  { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) } }

/* ============ AI 모닝 브리핑 ============ */
.briefing {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 22px;
  align-items: start;
  position: relative;
  overflow: hidden;
}
.briefing::before {
  content: "";
  position: absolute; top: -40px; right: -40px;
  width: 240px; height: 240px;
  background: radial-gradient(circle at center, var(--gold-soft), transparent 65%);
  pointer-events: none;
}
.briefing-mood {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  position: relative;
}
.briefing-mood .glyph {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800;
  background: var(--bg-elev-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.briefing-mood.bull .glyph    { color: var(--up);   background: rgba(229, 57, 53, 0.14); box-shadow: inset 0 0 0 1px rgba(229,57,53,0.35); }
.briefing-mood.bear .glyph    { color: var(--down); background: rgba(30, 136, 229, 0.14); box-shadow: inset 0 0 0 1px rgba(30,136,229,0.35); }
.briefing-mood.neutral .glyph { color: var(--gold); background: var(--gold-soft); box-shadow: inset 0 0 0 1px rgba(245,180,0,0.45); }
.briefing-mood .label {
  font-size: 11px; color: var(--text-mute);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.briefing-content { min-width: 0; position: relative; }
.briefing-title { font-size: 16px; font-weight: 700; margin: 4px 0 12px; letter-spacing: -0.005em; }
.briefing-bullets { display: flex; flex-direction: column; gap: 8px; }
.briefing-bullets li {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 12px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
}
.briefing-bullets li::before {
  content: "";
  display: block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
  margin-top: 9px;
}

/* ============ 가상 포트폴리오 ============ */
.link-btn {
  background: transparent; border: 0;
  color: var(--text-mute);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 0;
}
.link-btn:hover { color: var(--up); }

.portfolio-summary {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 12px;
}
.summary-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.summary-card.main {
  background:
    linear-gradient(135deg, rgba(245,180,0,0.10), transparent 55%),
    var(--bg-elev);
  border-color: rgba(245, 180, 0, 0.35);
}
.summary-label { font-size: 11.5px; color: var(--text-mute); letter-spacing: 0.04em; }
.summary-value {
  font-family: var(--mono);
  font-size: 22px; font-weight: 800; letter-spacing: -0.01em;
}
.summary-card.main .summary-value { font-size: 26px; }
.summary-sub {
  color: var(--text-dim);
  font-size: 11.5px;
  font-family: var(--mono);
  display: flex; gap: 10px; flex-wrap: wrap;
}
.summary-pl { font-family: var(--mono); font-weight: 700; font-size: 14px; margin-top: 2px; }

.portfolio-holdings {
  display: flex; flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
}
.holding-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-top-width: 0;
  align-items: center;
  cursor: pointer;
  transition: background .15s ease;
}
.holding-row:first-child { border-top-width: 1px; }
.holding-row:hover { background: var(--bg-elev-2); }
.holding-id { min-width: 0; }
.holding-name {
  font-weight: 700; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.holding-meta {
  color: var(--text-mute);
  font-size: 11.5px;
  font-family: var(--mono);
  margin-top: 2px;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.holding-meta .mkt {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-elev-2);
  color: var(--text-mute);
  font-size: 10.5px;
}
.holding-cell { display: flex; flex-direction: column; gap: 2px; text-align: right; min-width: 0; }
.holding-cell-label {
  color: var(--text-mute);
  font-size: 10.5px;
  letter-spacing: 0.04em;
}
.holding-cell-value {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.holding-cell .holding-cell-value.pl { font-size: 14px; }

/* ============ 모의 거래 패널 ============ */
.detail-trade {
  margin-top: 20px;
  background: var(--bg-elev-2);
  border-radius: 12px;
  padding: 18px 20px;
}
.detail-trade h4 {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
}
.trade-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.trade-info, .trade-controls { display: flex; flex-direction: column; gap: 10px; }
.trade-row {
  display: flex; justify-content: space-between;
  gap: 10px; align-items: baseline;
}
.trade-label { color: var(--text-mute); font-size: 12px; }
.trade-value {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  text-align: right;
}
.trade-input-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
}
.trade-input-row input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  text-align: right;
  padding: 6px 0;
  -moz-appearance: textfield;
}
.trade-input-row input::-webkit-outer-spin-button,
.trade-input-row input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.trade-input-row .trade-input-label {
  color: var(--text-mute);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.trade-max {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-mute);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
}
.trade-max:hover { color: var(--gold); border-color: var(--gold); }
.trade-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.btn-buy, .btn-sell {
  height: 40px;
  border-radius: 10px;
  border: 0;
  font-weight: 700;
  font-size: 13.5px;
  color: #fff;
  letter-spacing: 0.02em;
  transition: filter .15s ease, transform .15s ease, opacity .15s ease;
}
.btn-buy  { background: var(--up); }
.btn-sell { background: var(--down); }
.btn-buy:hover:not(:disabled),
.btn-sell:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.btn-buy:disabled, .btn-sell:disabled {
  background: var(--bg-elev);
  color: var(--text-dim);
  cursor: not-allowed;
  opacity: 0.7;
}

/* ============ 로그인 모달 ============ */
.modal-auth .auth-card {
  width: min(420px, 100%);
  padding: 30px 28px 26px;
}
.auth-head { text-align: center; padding-right: 32px; margin-bottom: 22px; }
.auth-title { margin: 0 0 6px; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.auth-sub { margin: 0; color: var(--text-mute); font-size: 13px; line-height: 1.55; }

.auth-stage { display: flex; flex-direction: column; gap: 16px; }

.google-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  width: 100%;
  height: 46px;
  background: #FFFFFF;
  color: #1F2937;
  border: 1px solid #DADCE0;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.005em;
  transition: background .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.google-btn:hover { background: #F8FAFC; box-shadow: 0 1px 3px rgba(60,64,67,.15); border-color: #C9CDD3; }
.google-btn:active { background: #F1F3F4; }
.google-icon { display: inline-flex; align-items: center; }

.auth-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-dim);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1; height: 1px;
  background: var(--line);
}

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > span {
  color: var(--text-mute);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}
.auth-field input {
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.auth-field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.auth-field input::placeholder { color: var(--text-dim); }

.auth-error {
  color: var(--up);
  font-size: 12.5px;
  line-height: 1.5;
  background: rgba(229, 57, 53, 0.10);
  border: 1px solid rgba(229, 57, 53, 0.35);
  border-radius: 8px;
  padding: 8px 12px;
}

.auth-submit {
  height: 46px;
  border-radius: 10px;
  border: 0;
  background: var(--gold);
  color: #1a1606;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-top: 4px;
  transition: background .15s ease, transform .15s ease, opacity .15s ease;
}
.auth-submit:hover:not(:disabled) { background: #FFC926; transform: translateY(-1px); }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-submit-google { background: #4285F4; color: #FFFFFF; }
.auth-submit-google:hover:not(:disabled) { background: #356DDB; }

.auth-toggle {
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-mute);
  margin-top: 4px;
}

.auth-back {
  align-self: flex-start;
  background: transparent; border: 0;
  color: var(--text-mute);
  font-size: 12.5px;
  padding: 4px 0;
  letter-spacing: 0.02em;
}
.auth-back:hover { color: var(--gold); }

.google-stage { display: flex; flex-direction: column; gap: 14px; align-items: stretch; margin-top: 4px; }
.google-stage-logo { display: flex; justify-content: center; }
.google-stage-title {
  margin: 4px 0 0;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.005em;
}
.google-stage-sub {
  margin: 0;
  text-align: center;
  color: var(--text-mute);
  font-size: 13px;
  line-height: 1.55;
}
.google-real-mount {
  display: flex; justify-content: center;
  min-height: 44px;
}
.google-real-mount:not([hidden]) + .google-bridge-form { display: none; }

.auth-note {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.55;
  text-align: center;
}

/* ============ 반응형 ============ */
@media (max-width: 900px) {
  .topbar-inner { grid-template-columns: 1fr auto; row-gap: 10px; }
  .search { grid-column: 1 / -1; order: 3; max-width: none; }
  .indices { grid-template-columns: repeat(3, 1fr); padding: 6px 16px 12px; }
  .indices .idx:nth-child(n+4) { /* keep visible */ }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .portfolio-summary { grid-template-columns: 1fr 1fr; }
  .summary-card.main { grid-column: 1 / -1; }
  .trade-grid { grid-template-columns: 1fr; gap: 14px; }
  .holding-row { grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); }
  .holding-row .holding-cell.avg { display: none; }
}

@media (max-width: 640px) {
  .topbar-inner { padding: 12px 14px 8px; }
  .brand-sub { display: none; }
  .indices { grid-template-columns: repeat(2, 1fr); padding: 6px 14px 12px; }
  .main { padding: 22px 14px 60px; gap: 30px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .modal { padding: 0; }
  .modal-card { border-radius: 18px 18px 0 0; max-height: 92vh; padding: 22px; width: 100%; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .news-item { grid-template-columns: 64px 1fr; padding: 12px 14px; }
  .news-thumb { width: 64px; height: 48px; }
  .news-tag { display: none; }
  .section-title { font-size: 16px; }
  .detail-name { font-size: 19px; }
  .detail-price { font-size: 22px; }
  .user-chip { display: none; }
  .auth-btn { padding: 0 12px; font-size: 12px; height: 36px; }
  .modal-auth .auth-card { border-radius: 18px 18px 0 0; padding: 26px 22px 22px; max-height: 92vh; }

  .briefing { grid-template-columns: 1fr; padding: 18px; gap: 14px; }
  .briefing-mood { flex-direction: row; align-items: center; gap: 12px; }
  .briefing-mood .glyph { width: 46px; height: 46px; font-size: 20px; }
  .briefing-title { font-size: 15px; margin-top: 0; }

  .portfolio-summary { grid-template-columns: 1fr; }
  .summary-card.main { grid-column: auto; }
  .summary-card.main .summary-value { font-size: 22px; }
  .holding-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-auto-rows: auto;
    row-gap: 4px;
    column-gap: 12px;
    padding: 12px 14px;
  }
  .holding-row .holding-id { grid-row: 1 / span 2; align-self: center; }
  .holding-row .holding-cell.avg,
  .holding-row .holding-cell.current { display: none; }
  .holding-row .holding-cell { text-align: right; }
  .detail-trade { padding: 14px 16px; }
}
