:root {
  --bg: #070b14;
  --card: #101a2b;
  --card-2: #0d1524;
  --line: #22324f;
  --text: #e9eef8;
  --muted: #9cb0cc;
  --accent: #F59E0B;
  --surface: #0c1423;
  --surface-2: #0b1322;
}

body[data-theme="light"] {
  --bg: #f2f6ff;
  --card: #ffffff;
  --card-2: #f8fbff;
  --line: #d9e4f5;
  --text: #1f2a3d;
  --muted: #5f718f;
  --accent: #F59E0B;
  --surface: #eef4ff;
  --surface-2: #f5f9ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, #12243f 0%, var(--bg) 40%);
  color: var(--text);
  font-family: "Pretendard", "Noto Sans KR", system-ui, sans-serif;
}

body[data-theme="light"] {
  background: radial-gradient(circle at top right, #dcecff 0%, var(--bg) 45%);
}

.mobile-topbar {
  display: none;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 10px;
  padding: 10px;
}

.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  height: fit-content;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card);
  padding-bottom: 4px;
}

.brand-title-wrap {
  display: grid;
  gap: 2px;
  flex: 1;
}

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  border-radius: 10px;
  width: 100%;
  height: 100%;
  cursor: pointer;
  font-size: 14px;
}

.sidebar-quick-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 8px;
  align-items: start;
}

.sidebar-quick-stack {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  height: 124px;
}

.quick-action {
  margin-top: 0;
  min-height: 0;
  height: calc((124px - 8px) / 2);
}

.sidebar h1 { margin: 0; font-size: 20px; line-height: 1.15; letter-spacing: -0.2px; text-align: center; }

.brand-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffffff66;
  box-shadow: 0 6px 16px #00000055;
  background: radial-gradient(circle at 30% 20%, #ffffffaa, #ffffff22 45%, transparent 70%);
}

.muted { color: var(--muted); }

.sidebar {
  text-align: center;
}

.sidebar .small-card {
  text-align: center;
}

.calendar-card {
  margin-top: 10px;
  display: grid;
  gap: 4px;
}

.calendar-head {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  gap: 6px;
}

.calendar-month-label {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  text-align: center;
}

.calendar-nav {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

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

.calendar-dow,
.calendar-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 26px;
  display: grid;
  place-items: center;
  font-size: 11px;
}

.calendar-dow {
  background: var(--surface);
  color: var(--muted);
  min-height: 22px;
}

.calendar-day {
  position: relative;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.calendar-day.empty {
  border-color: transparent;
  background: transparent;
  cursor: default;
}

.calendar-day.today {
  border-color: var(--accent);
}

.calendar-day.has-event::after {
  content: "";
  position: absolute;
  top: 3px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

.calendar-day.has-event:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  min-width: 120px;
  max-width: 180px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  white-space: pre-line;
  font-size: 11px;
  line-height: 1.3;
  z-index: 20;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.calendar-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
}

.calendar-add-btn:hover {
  border-color: var(--accent);
}

.tabs { display: grid; gap: 8px; margin: 14px 0; }
.tab {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
}
.tab.active { border-color: var(--accent); color: var(--accent); }

.small-card {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--surface-2);
}

.update-card {
  cursor: pointer;
}

.update-card:hover {
  border-color: var(--accent);
}

.update-card #updatedAt {
  display: none;
}

.update-card {
  display: grid;
  place-items: center;
}

.update-card .small-title {
  margin: 0;
}
.small-title {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
}

#todoDateLabel {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
}
.todo-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
}
.todo-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 6px;
}
.todo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.todo-item label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.todo-item span {
  color: var(--text);
  word-break: break-word;
}
.todo-item span.done {
  color: var(--muted);
  text-decoration: line-through;
}
.todo-del {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
}
.todo-empty {
  font-size: 12px;
  color: var(--muted);
}

#updatedAt,
#currentTime,
#usUpdatedAt,
#krUpdatedAt,
#btcUpdatedAt,
#moversUpdatedAt,
#usUpdatedAtStocks,
#krUpdatedAtStocks {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--muted);
  white-space: pre-line;
}

.content {
  display: grid;
  gap: 12px;
  align-content: start;
  align-items: start;
}

.view {
  display: grid;
  gap: 12px;
  align-content: start;
  align-items: start;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.kpi-title { margin: 0; color: var(--muted); font-size: 13px; }
.kpi-value { margin: 8px 0 0; font-size: 20px; font-weight: 700; }

h2 { margin: 0 0 10px; color: var(--accent); font-size: 18px; }
.market-summary-line {
  margin: 0 0 6px;
  padding: 6px 8px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

#krSummary,
#usSummary,
#newsMustKnow {
  color: var(--text);
  white-space: pre-line;
}

#newsOneLine {
  white-space: pre-line;
  color: var(--text);
  border: none;
  padding: 0;
  background: transparent;
  font-size: 14px;
  line-height: 1.6;
}
.list { margin: 0; padding-left: 18px; line-height: 1.65; }
ol.list { list-style: decimal; }
.list.compact { line-height: 1.55; font-size: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hidden { display: none; }

.weather-time-card {
  display: grid;
  gap: 4px;
  padding: 8px;
  align-content: start;
  min-height: 124px;
}

.weather-title {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 2px;
}

.weather-stack {
  display: grid;
  gap: 4px;
  justify-items: center;
}

.weather-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.weather-row.compact {
  gap: 8px;
}

.weather-status-row {
  align-items: center;
}

.weather-icon {
  font-size: 20px;
  line-height: 1;
}

.weather-icon.title-icon {
  font-size: 16px;
}

.weather-temp {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
}

.weather-status-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.2;
}

.weather-time {
  margin: 0;
  padding-top: 0;
  border-top: none;
  color: var(--text) !important;
  font-size: 12px !important;
  line-height: 1.25 !important;
}

.btc-widget {
  cursor: pointer;
}

.coin-table {
  display: grid;
  gap: 4px;
}

.coin-row {
  display: grid;
  gap: 8px;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
}

.coin-table.cols-4 .coin-row {
  grid-template-columns: 1.1fr 1.2fr 1fr 1fr;
}

.coin-table.cols-5 .coin-row {
  grid-template-columns: 1.1fr 1.2fr 1fr 1fr 1fr;
}

.coin-row.head {
  font-size: 12px;
  color: var(--muted);
  background: transparent;
}

.btc-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upbit-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
}

.upbit-link:hover {
  text-decoration: underline;
}

.btc-price {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.btc-change {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.up {
  color: #ff5e6c;
}

.down {
  color: #4da3ff;
}

.neutral {
  color: #23d18b;
}

.movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.movers-title {
  margin: 0 0 8px;
  font-size: 13px;
}

.movers-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-size: 12px;
}

.movers-table th,
.movers-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  line-height: 1.25;
}

.movers-table th {
  color: var(--muted);
  background: var(--surface-2);
}

.movers-table tr:last-child td {
  border-bottom: none;
}

.news-split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.news-top-link {
  color: var(--text);
  text-decoration: none;
}

.news-top-link:hover {
  text-decoration: underline;
}

.news-sector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.news-sector-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: var(--surface-2);
}

.news-sector-title {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
}

.news-sector-summary {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.news-sector-list {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  line-height: 1.4;
}

@media (max-width: 920px) {
  .news-sector-grid {
    grid-template-columns: 1fr;
  }
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.briefing-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 10px;
}

.briefing-box p {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
  font-size: 13px;
  white-space: pre-line;
}

.chat-card {
  display: grid;
  gap: 12px;
}

.chat-messages {
  min-height: 280px;
  max-height: 48vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--surface-2);
  display: grid;
  gap: 8px;
  align-content: start;
  justify-items: start;
}

.chat-bubble {
  max-width: 85%;
  border-radius: 10px;
  padding: 8px 10px;
  line-height: 1.45;
  white-space: pre-line;
  word-break: break-word;
}

.chat-bubble.user {
  justify-self: end;
  background: #7b5cff;
  color: #fff;
}

.chat-bubble.assistant {
  justify-self: start;
  background: var(--card-2);
  border: 1px solid var(--line);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.chat-form input {
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: var(--surface-2);
  color: var(--text);
}

.chat-form button {
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

@media (max-width: 920px) {
  .mobile-topbar {
    display: flex;
    position: fixed;
    top: 8px;
    left: 10px;
    right: 10px;
    z-index: 1200;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  }

  .mobile-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 18px;
    color: var(--text);
    margin: 0 auto;
  }

  .mobile-topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--line);
  }

  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    border-radius: 999px;
    font-size: 18px;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
  }

  .sidebar {
    display: none;
  }

  body.sidebar-open .sidebar {
    display: block;
    position: fixed;
    inset: 72px 10px 10px 10px;
    z-index: 1100;
    overflow-y: auto;
  }

  body.sidebar-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
  }

  .app {
    grid-template-columns: 1fr;
    padding: 76px 10px 10px;
    gap: 10px;
  }

  .card {
    padding: 12px;
  }

  .sidebar h1 {
    font-size: 22px;
  }

  .brand-avatar {
    width: 64px;
    height: 64px;
  }

  .sidebar-quick-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-quick-stack {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: none;
  }

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

  .coin-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .coin-table.cols-4 .coin-row,
  .coin-table.cols-5 .coin-row {
    min-width: 0;
  }

  .coin-table.cols-4 .coin-row {
    grid-template-columns: 1fr 1fr 0.9fr 0.9fr;
  }

  .coin-table.cols-5 .coin-row {
    grid-template-columns: 0.95fr 1fr 0.8fr 0.85fr 0.85fr;
  }

  .coin-row {
    gap: 6px;
    padding: 4px 6px;
    font-size: 11px;
  }

  .coin-row.head {
    display: grid;
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: 10px;
  }

  .movers-grid {
    grid-template-columns: 1fr;
  }

  .news-split-grid {
    grid-template-columns: 1fr;
  }

  .movers-table {
    font-size: 11px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat-form button {
    width: 100%;
  }
}

.mini-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}

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

.stock-validate-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.stock-validate-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
}

.stocktest-table th,
.stocktest-table td {
  white-space: nowrap;
}

