* { box-sizing: border-box; }

html,
body {
  overflow-x: hidden;
}

:root {
  --bg1: #f6f8fb;
  --bg2: #eef2f7;
  --bg3: #e9eef5;
  --ink: #151922;
  --line: #d8e0ea;
  --paper: #fff;
  --soft: #f8fafc;
  --warm: #f4f7fb;
  --good: #ecfdf3;
  --bad: #fff1f3;
  --good-strong: #16a34a;
  --bad-strong: #e11d48;
  --muted: #667085;
  --shadow: 0 18px 48px rgba(15, 23, 42, .10);
  --border-width: 1px;
  --button-shadow: none;
  --panel-shadow: none;
  --selected-shadow: 0 0 0 3px rgba(22, 163, 74, .14);
  --radius: 8px;
  --font: Arial, "Malgun Gothic", sans-serif;
}

body.theme-excel {
  --bg1: #eef6f0;
  --bg2: #f7fbf8;
  --bg3: #edf7ef;
  --ink: #17351f;
  --line: #217346;
  --paper: #fff;
  --soft: #e8f3ec;
  --warm: #f4fbf6;
  --good: #dff3e7;
  --bad: #ffe7e7;
  --good-strong: #217346;
  --bad-strong: #c43b3b;
  --muted: #4d6556;
  --shadow: 4px 4px 0 rgba(33, 115, 70, .22);
  --border-width: 1px;
  --button-shadow: 1px 1px 0 rgba(33, 115, 70, .28);
  --panel-shadow: 2px 2px 0 rgba(33, 115, 70, .22);
  --selected-shadow: 0 0 0 3px rgba(33, 115, 70, .16);
  --radius: 2px;
  --font: Aptos, Calibri, Arial, "Malgun Gothic", sans-serif;
}

body.theme-crt {
  --bg1: #07130f;
  --bg2: #0b1f1a;
  --bg3: #111827;
  --ink: #d7ffe9;
  --line: #5df2a4;
  --paper: #071511;
  --soft: #0d241c;
  --warm: #142c22;
  --good: #102f20;
  --bad: #2b1421;
  --good-strong: #4bf28b;
  --bad-strong: #ff5d8d;
  --muted: #90c9ad;
  --shadow: 0 0 0 2px rgba(93,242,164,.24), 0 0 28px rgba(93,242,164,.18);
  --border-width: 2px;
  --button-shadow: 3px 3px 0 var(--line);
  --panel-shadow: 4px 4px 0 var(--line);
  --selected-shadow: 0 0 0 3px rgba(93,242,164,.24);
  --radius: 4px;
  --font: "Lucida Console", Consolas, "Courier New", monospace;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 100%);
}

body.theme-crt {
  background:
    radial-gradient(circle at 18% 14%, rgba(93,242,164,.12), transparent 30%),
    radial-gradient(circle at 82% 4%, rgba(255,93,141,.10), transparent 30%),
    linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 48%, var(--bg3) 100%);
}

button { font: inherit; }

.wrap {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 18px 44px;
}

.app {
  position: relative;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

body.theme-crt .app::before,
body.theme-crt .app::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

body.theme-crt .app::before {
  background: repeating-linear-gradient(
    to bottom,
    rgba(215,255,233,.08) 0,
    rgba(215,255,233,.08) 1px,
    transparent 1px,
    transparent 7px
  );
  mix-blend-mode: screen;
}

body.theme-crt .app::after {
  background:
    radial-gradient(circle at 50% 18%, rgba(93,242,164,.18), transparent 42%),
    linear-gradient(90deg, rgba(255,0,80,.06), transparent 18%, transparent 82%, rgba(0,160,255,.06));
}

body.theme-crt .brand,
body.theme-crt .line-title,
body.theme-crt .vote-title,
body.theme-crt .side-title {
  text-shadow: 0 0 8px rgba(93,242,164,.7);
}

body.theme-crt .line-body,
body.theme-crt .time-cell,
body.theme-crt .vote-panel,
body.theme-crt .note,
body.theme-crt .day {
  box-shadow: inset 0 0 18px rgba(93,242,164,.08);
}

.nav {
  min-height: 58px;
  padding: 36px 18px 14px;
  border-bottom: var(--border-width) solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--soft);
}

.market-index-strip {
  position: relative;
  min-height: 38px;
  border-bottom: var(--border-width) solid var(--line);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
}

.index-left,
.index-right {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.index-left {
  flex-wrap: wrap;
}

.index-label {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
}

.index-left strong {
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.index-inline-change {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.index-inline-change.is-up { color: var(--good-strong); }
.index-inline-change.is-down { color: var(--bad-strong); }

.index-divider {
  width: 1px;
  height: 14px;
  background: var(--line);
  flex: 0 0 auto;
}

.index-right {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-logo {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: calc(var(--radius) - 1px);
}

.theme-switch,
.simple-switch,
.nav-right,
.keyword-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.theme-switch-top {
  position: absolute;
  top: 50px;
  right: 18px;
  z-index: 6;
  justify-content: flex-end;
}

.simple-switch-top {
  position: absolute;
  top: 50px;
  left: 18px;
  z-index: 6;
  justify-content: flex-start;
}

.nav-right { justify-content: flex-end; }

.chip,
.nav-btn,
.keyword-chip {
  border: var(--border-width) solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.nav-btn,
.keyword-chip {
  box-shadow: var(--button-shadow);
}

.keyword-chip {
  appearance: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .14s ease, color .14s ease, transform .14s ease;
}

.keyword-chip:active {
  transform: translate(1px, 1px);
}

.nav-btn,
.theme-link,
.simple-link {
  cursor: pointer;
}

.nav-btn {
  background: var(--warm);
}

.theme-link,
.simple-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.theme-link.is-active,
.simple-link.is-active {
  color: var(--ink);
  font-weight: 900;
}

.simple-link.is-active::after {
  content: " ON";
  color: var(--good-strong);
  font-size: 10px;
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
}

.content {
  min-width: 0;
  padding: 22px 28px;
  border-right: var(--border-width) solid var(--line);
}

body.theme-excel .content {
  background-image:
    linear-gradient(to right, rgba(33,115,70,.12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(33,115,70,.12) 1px, transparent 1px);
  background-size: 76px 34px;
}

.side {
  min-width: 0;
  padding: 18px;
  background: var(--warm);
}

.date {
  display: inline-flex;
  border: var(--border-width) solid var(--line);
  border-radius: 999px;
  background: var(--good);
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 14px;
}

.source-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--warm);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
  margin-top: 12px;
}

.keyword-strip { margin: 0 0 18px; }

.summary {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.line {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  align-items: stretch;
}

.time-cell,
.line-body,
.vote-panel,
.note,
.day {
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.time-cell {
  background: var(--soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  padding: 8px 6px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
}

.time-cell span:first-child { font-size: 15px; }
.time-cell span:nth-child(2) { margin-top: 4px; color: var(--muted); font-size: 10px; }

.line-body {
  min-width: 0;
  padding: 10px 11px;
}

.line-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 900;
}

.mark {
  width: 24px;
  height: 24px;
  border: var(--border-width) solid var(--line);
  border-radius: calc(var(--radius) - 1px);
  background: var(--good);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  flex: 0 0 auto;
}

.line-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.52;
  overflow-wrap: anywhere;
}

.vote-panel {
  position: relative;
  min-width: 0;
  padding: 14px;
  box-shadow: var(--panel-shadow);
  margin-bottom: 18px;
  overflow: visible;
}

.vote-title {
  font-size: 15px;
  font-weight: 900;
  margin-bottom: 11px;
}

.votes {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 13px;
  transition: padding .16s ease;
}

.vote-panel:not(.is-closed):not(.is-verified) .votes {
  min-height: 84px;
  padding-right: min(318px, 52%);
}

.vote {
  position: relative;
  min-width: 0;
  min-height: 58px;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 900;
  box-shadow: var(--button-shadow);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, outline-color .12s ease;
  user-select: none;
}

.vote:disabled {
  cursor: wait;
  opacity: .68;
}

.nav-btn:disabled {
  cursor: default;
  opacity: .42;
  transform: none;
}

.vote.good { background: var(--good); color: var(--ink); }
.vote.bad { background: var(--bad); color: var(--ink); }

.vote.is-selected {
  transform: translate(2px, 2px);
  box-shadow: inset 0 4px 12px rgba(15, 23, 42, .18);
  outline: var(--selected-shadow);
}

.vote.is-selected::after {
  content: "내 선택";
  position: absolute;
  top: 7px;
  right: 8px;
  border: var(--border-width) solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  padding: 2px 5px;
  font-size: 10px;
  line-height: 1;
}

.vote.is-pending {
  transform: translate(2px, 2px);
  box-shadow: inset 0 3px 8px rgba(15, 23, 42, .14);
}

.vote-status,
.closed-result {
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--warm);
  color: var(--ink);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.45;
  margin-bottom: 12px;
}

.vote-status {
  margin-top: -3px;
}

.vote-status[hidden] {
  display: none;
}

.turnstile-float {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  width: min(304px, calc(100% - 24px));
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--panel-shadow);
  padding: 8px;
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
}

.turnstile-float-title {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border: var(--border-width) solid var(--line);
  border-radius: 999px;
  background: var(--warm);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 7px;
}

.vote-panel.needs-turnstile .turnstile-float {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--bad-strong);
}

.vote-panel.is-verified .turnstile-float {
  display: none;
}

.turnstile-slot {
  min-height: 34px;
  margin: 0;
}

.vote-panel.is-submitting .vote {
  transform: translate(1px, 1px);
  box-shadow: var(--button-shadow);
}

.closed-result {
  display: block;
}

.meter-label {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 7px;
}

.meter {
  height: 18px;
  border: var(--border-width) solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: var(--paper);
  margin-bottom: 9px;
}

.meter .good { background: var(--good-strong); }
.meter .bad { flex: 1; background: var(--bad-strong); }

.small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.market-panel {
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--panel-shadow);
  padding: 11px;
  margin-bottom: 14px;
}

.market-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.market-head h2 {
  margin: 0;
}

.market-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.market-theme-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.market-theme {
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius);
  background: var(--warm);
  padding: 8px;
}

.market-theme-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.market-theme-title strong {
  font-size: 12px;
}

.market-theme-title span {
  border: var(--border-width) solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  padding: 2px 5px;
  font-size: 9px;
  font-weight: 900;
  white-space: nowrap;
}

.stock-list {
  display: grid;
  gap: 4px;
}

.stock-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  border: var(--border-width) solid var(--line);
  border-radius: calc(var(--radius) - 1px);
  background: var(--paper);
  padding: 6px 7px;
  min-width: 0;
}

.stock-name,
.stock-price,
.stock-change {
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
}

.stock-name {
  overflow-wrap: anywhere;
}

.stock-price {
  color: var(--ink);
}

.stock-change {
  color: var(--muted);
  min-width: 58px;
  text-align: right;
}

.stock-change.is-up { color: var(--good-strong); }
.stock-change.is-down { color: var(--bad-strong); }

.notes {
  border-top: var(--border-width) dashed var(--line);
  padding-top: 16px;
}

h2 {
  margin: 0 0 10px;
  font-size: 17px;
  letter-spacing: 0;
}

.note-list,
.day-list {
  display: grid;
  gap: 10px;
}

.note,
.day {
  min-width: 0;
  padding: 11px;
}

.note strong,
.day strong {
  display: block;
  font-size: 13px;
  margin-bottom: 5px;
}

.note p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.note a {
  color: var(--line);
  font-size: 12px;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.side-title {
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 9px;
}

.day {
  text-align: left;
  color: var(--ink);
  box-shadow: var(--button-shadow);
  cursor: pointer;
}

.day.active {
  background: var(--good);
}

.day span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.footer {
  border-top: var(--border-width) solid var(--line);
  padding: 12px 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  background: var(--paper);
}

body.theme-excel .chip,
body.theme-excel .nav-btn,
body.theme-excel .turnstile-float,
body.theme-excel .keyword-chip {
  border-radius: 2px;
}

body.theme-crt .chip,
body.theme-crt .nav-btn,
body.theme-crt .keyword-chip,
body.theme-crt .turnstile-float {
  border-radius: var(--radius);
}

@media (max-width: 820px) {
  .wrap { padding: 14px 12px 34px; }
  .app { box-shadow: var(--shadow); }
  .theme-switch-top {
    position: static;
    padding: 12px 18px 0;
    background: var(--soft);
  }
  .simple-switch-top {
    position: static;
    padding: 12px 18px 0;
    background: var(--soft);
  }
  .theme-switch-top { justify-content: flex-start; }
  .market-index-strip { align-items: flex-start; flex-direction: column; }
  .index-right { flex-wrap: wrap; white-space: normal; }
  .nav { padding-top: 12px; }
  .nav { align-items: flex-start; flex-direction: column; }
  .nav-right { justify-content: flex-start; }
  .main { grid-template-columns: 1fr; }
  .content { border-right: 0; border-bottom: var(--border-width) solid var(--line); padding: 18px; }
  .side { padding: 16px; }
  .source-summary { align-items: flex-start; flex-direction: column; }
  .line { grid-template-columns: 1fr; }
  .time-cell { min-height: auto; flex-direction: row; justify-content: flex-start; gap: 7px; }
  .time-cell span:nth-child(2) { margin-top: 0; }
  .vote-panel:not(.is-closed):not(.is-verified) .votes { min-height: auto; padding-right: 0; }
  .turnstile-float {
    position: relative;
    top: auto;
    right: auto;
    width: 100%;
    margin: -2px 0 12px;
  }
  .market-head { align-items: flex-start; flex-direction: column; }
  .stock-row { grid-template-columns: minmax(0, 1fr) auto; }
  .stock-change { grid-column: 2; min-width: 0; }
}
