:root {
  color-scheme: light;
  --background: 210 20% 98%;
  --foreground: 220 40% 13%;
  --card: 0 0% 100%;
  --muted: 220 14% 96%;
  --muted-foreground: 220 9% 46%;
  --border: 220 13% 91%;
  --border-strong: 220 13% 78%;
  --primary: 245 58% 64%;
  --primary-foreground: 0 0% 100%;
  --surface-secondary: 220 14% 96%;
  --stock-up: 0 72% 51%;
  --stock-down: 221 83% 53%;
  --stock-flat: 220 9% 50%;
  --stock-up-bg: 0 84% 96%;
  --stock-down-bg: 220 90% 96%;
  --success: 142 71% 45%;
  --warning: 38 92% 50%;
  --danger: 0 84% 60%;
  --info: 210 92% 35%;
  --radius: 8px;
  --shadow: 0 12px 28px hsl(220 40% 13% / 0.07);
}

:root.dark {
  color-scheme: dark;
  --background: 220 20% 10%;
  --foreground: 210 20% 98%;
  --card: 220 20% 12%;
  --muted: 220 16% 16%;
  --muted-foreground: 215 15% 65%;
  --border: 220 16% 22%;
  --border-strong: 220 16% 32%;
  --surface-secondary: 220 16% 15%;
  --stock-up: 0 72% 60%;
  --stock-down: 221 83% 63%;
  --stock-flat: 215 15% 50%;
  --stock-up-bg: 0 60% 14%;
  --stock-down-bg: 220 60% 14%;
  --success: 142 71% 55%;
  --warning: 38 92% 60%;
  --danger: 0 72% 60%;
  --info: 210 92% 65%;
  --shadow: 0 16px 36px hsl(0 0% 0% / 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family:
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Pretendard,
    Noto Sans KR,
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  height: 48px;
  padding: 0 18px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card) / 0.94);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.05;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  font-weight: 800;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.topnav::-webkit-scrollbar {
  display: none;
}

.topnav button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.topnav button:hover,
.topnav button.active {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 34px;
  padding: 0 10px 0 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 700;
}

kbd {
  padding: 2px 6px;
  border: 1px solid hsl(var(--border-strong));
  border-radius: 5px;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-size: 11px;
  font-weight: 900;
}

.icon-btn {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--card));
}

.macro-strip {
  position: sticky;
  top: 48px;
  z-index: 35;
  display: flex;
  gap: 8px;
  min-height: 38px;
  padding: 6px 18px;
  overflow-x: auto;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  scrollbar-width: none;
}

.macro-strip::-webkit-scrollbar {
  display: none;
}

.macro-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  padding: 5px 10px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--card));
  font-size: 12px;
  font-weight: 800;
}

.macro-item span {
  color: hsl(var(--muted-foreground));
}

.app-shell {
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr) 284px;
  gap: 14px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 14px 14px 32px;
}

.side-nav,
.watch-panel {
  position: sticky;
  top: 100px;
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
}

.side-nav {
  display: grid;
  gap: 12px;
  padding: 10px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
}

.side-group {
  display: grid;
  gap: 2px;
}

.side-group p {
  margin: 8px 8px 4px;
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  font-weight: 900;
}

.side-group a {
  display: flex;
  min-height: 32px;
  align-items: center;
  padding: 0 9px;
  border-radius: 7px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 800;
}

.side-group a:hover,
.side-group a.active {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.page {
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  margin-bottom: 10px;
  padding: 0 2px;
}

.eyebrow {
  margin: 0 0 5px;
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
}

h3 {
  margin-bottom: 0;
  font-size: 15px;
}

.page-meta {
  display: grid;
  gap: 3px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.page-meta strong {
  color: hsl(var(--foreground));
}

.sub-tabs {
  display: flex;
  gap: 18px;
  min-height: 43px;
  margin-bottom: 10px;
  overflow-x: auto;
  border-bottom: 1px solid hsl(var(--border));
  scrollbar-width: none;
}

.sub-tabs::-webkit-scrollbar {
  display: none;
}

.sub-tabs a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: max-content;
  color: hsl(var(--muted-foreground));
  font-size: 15px;
  font-weight: 800;
}

.sub-tabs a::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: hsl(var(--foreground));
  content: "";
  transform: scaleX(0);
  transform-origin: left;
}

.sub-tabs a.active {
  color: hsl(var(--foreground));
}

.sub-tabs a.active::after {
  transform: scaleX(1);
}

.content {
  display: grid;
  gap: 12px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.card {
  min-width: 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  box-shadow: var(--shadow);
}

.card.pad {
  padding: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px 12px;
  border-bottom: 1px solid hsl(var(--border));
}

.card-body {
  padding: 14px 16px 16px;
}

.signal-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
}

.signal-lights {
  display: flex;
  gap: 7px;
  padding: 7px;
  border-radius: 999px;
  background: hsl(220 20% 12%);
}

.light {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: hsl(var(--border-strong));
  color: transparent;
  font-size: 10px;
  font-weight: 900;
}

.light.green.on {
  background: hsl(var(--success));
  color: white;
}

.light.yellow.on {
  background: hsl(var(--warning));
  color: hsl(220 40% 13%);
}

.light.red.on {
  background: hsl(var(--danger));
  color: white;
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 104px;
  padding: 15px;
}

.metric span {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 900;
}

.metric strong {
  font-size: 27px;
  line-height: 1;
}

.metric small {
  color: hsl(var(--muted-foreground));
  font-weight: 800;
}

.up {
  color: hsl(var(--stock-up)) !important;
}

.down {
  color: hsl(var(--stock-down)) !important;
}

.flat {
  color: hsl(var(--stock-flat)) !important;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 900;
}

.pill.up {
  background: hsl(var(--stock-up-bg));
}

.pill.down {
  background: hsl(var(--stock-down-bg));
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid hsl(var(--border));
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 900;
}

td {
  font-size: 13px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.name-cell {
  display: grid;
  gap: 2px;
}

.name-cell strong {
  font-size: 13px;
}

.name-cell span {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.heat-tile {
  min-height: 86px;
  padding: 10px;
  border-radius: 8px;
  background: hsl(var(--muted));
}

.heat-tile.hot {
  background: linear-gradient(135deg, hsl(var(--stock-up) / 0.92), hsl(var(--stock-up) / 0.56));
  color: white;
}

.heat-tile.cold {
  background: linear-gradient(135deg, hsl(var(--stock-down) / 0.9), hsl(var(--stock-down) / 0.58));
  color: white;
}

.heat-tile strong {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
}

.heat-tile span {
  display: block;
  font-size: 12px;
  font-weight: 800;
  opacity: 0.86;
}

.spark {
  width: 100%;
  height: 44px;
}

.spark path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.bars {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 48px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  font-weight: 900;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: hsl(var(--muted));
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: hsl(var(--primary));
}

.news-list,
.briefing-list,
.strategy-list {
  display: grid;
  gap: 10px;
}

.news-item,
.briefing-item,
.strategy-row,
.watch-item,
.result-item {
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--card));
}

.news-item,
.briefing-item,
.strategy-row {
  padding: 13px;
}

.news-item h3,
.briefing-item h3 {
  margin-bottom: 7px;
}

.news-item p,
.briefing-item p,
.strategy-row p {
  margin: 0;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.watch-panel {
  display: grid;
  gap: 12px;
}

.watch-head,
.mini-card {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  box-shadow: var(--shadow);
}

.watch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
}

.watch-list {
  display: grid;
  gap: 8px;
}

.watch-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px;
}

.watch-item strong,
.watch-item span {
  display: block;
}

.watch-item span {
  margin-top: 2px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 800;
}

.mini-card {
  padding: 14px;
}

.check-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 8px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.check-list li span {
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: 999px;
  background: hsl(var(--primary));
}

.game-board {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
}

.fake-chart {
  min-height: 360px;
  padding: 14px;
}

.candle-grid {
  display: grid;
  grid-template-columns: repeat(36, 1fr);
  align-items: end;
  gap: 4px;
  height: 300px;
  padding: 16px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background:
    linear-gradient(hsl(var(--border) / 0.38) 1px, transparent 1px) 0 0 / 100% 25%,
    hsl(var(--surface-secondary));
}

.candle {
  position: relative;
  min-width: 4px;
  border-radius: 2px;
}

.candle::before {
  position: absolute;
  top: -14px;
  bottom: -14px;
  left: 50%;
  width: 1px;
  background: currentColor;
  content: "";
  transform: translateX(-50%);
}

.candle.up {
  background: hsl(var(--stock-up));
}

.candle.down {
  background: hsl(var(--stock-down));
}

.form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.input {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  outline: none;
}

.input:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.15);
}

.btn {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border-radius: 8px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 13px;
  font-weight: 900;
}

.btn.secondary {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
}

.command-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: start center;
  padding-top: min(12vh, 90px);
  background: hsl(220 40% 5% / 0.42);
}

.command-backdrop[hidden] {
  display: none;
}

.command-panel {
  width: min(680px, calc(100% - 28px));
  max-height: 74vh;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--card));
  box-shadow: 0 30px 80px hsl(0 0% 0% / 0.28);
}

.command-input {
  display: grid;
  grid-template-columns: 32px 1fr 38px;
  align-items: center;
  min-height: 54px;
  padding: 0 10px;
  border-bottom: 1px solid hsl(var(--border));
}

.command-input span {
  color: hsl(var(--muted-foreground));
  text-align: center;
  font-size: 20px;
}

.command-input input {
  width: 100%;
  border: 0;
  background: transparent;
  color: hsl(var(--foreground));
  outline: none;
}

.command-input button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: hsl(var(--muted-foreground));
  font-size: 22px;
}

.command-input button:hover {
  background: hsl(var(--muted));
}

#command-title {
  padding: 14px 16px 8px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  text-transform: uppercase;
}

.command-results {
  display: grid;
  gap: 7px;
  max-height: calc(74vh - 104px);
  overflow-y: auto;
  padding: 0 12px 12px;
}

.result-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 11px;
  text-align: left;
}

.result-item:hover {
  background: hsl(var(--muted));
}

.result-item strong,
.result-item span {
  display: block;
}

.result-item span {
  margin-top: 2px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 164px minmax(0, 1fr);
  }

  .watch-panel {
    display: none;
  }

  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .topnav {
    grid-column: 1 / -1;
    order: 3;
    margin: 0 -18px;
    padding: 0 18px 8px;
    border-bottom: 1px solid hsl(var(--border));
  }

  .topbar {
    height: auto;
    min-height: 48px;
    padding-top: 7px;
  }

  .macro-strip {
    top: 90px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: static;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    max-height: none;
  }

  .side-group {
    min-width: 150px;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .game-board {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3 {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .search-trigger span,
  .search-trigger kbd {
    display: none;
  }

  .search-trigger {
    width: 34px;
    padding: 0;
    justify-content: center;
  }

  .search-trigger::before {
    content: "⌕";
    font-size: 18px;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-meta {
    text-align: left;
  }

  .heatmap {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
