:root {
  --bg: #f4f6fb;
  --bg2: #ffffff;
  --border: #e2e6ef;
  --text: #1a1d23;
  --muted: #8b95a8;
  --accent: #3b82f6;
  --up: #16a34a;
  --down: #dc2626;
  --shadow: 0 1px 4px rgba(0,0,0,0.07);
}
body.dark {
  --bg: #0f1117;
  --bg2: #1a1f2e;
  --border: #2a3040;
  --text: #e8eaf0;
  --muted: #8b95a8;
  --shadow: 0 1px 4px rgba(0,0,0,0.3);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  padding: 16px;
  max-width: 960px;
  margin: 0 auto;
  transition: background 0.2s, color 0.2s;
}

/* 헤더 */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 10px;
  margin-bottom: 24px;
}
.updated {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--bg2);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* 다크모드 토글 */
.theme-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.theme-label {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 20px;
  min-width: 52px;
  text-align: center;
  transition: color 0.2s;
}
.toggle-track {
  position: relative;
  width: 44px; height: 24px;
  background: #c0c7d0;
  border-radius: 12px;
  transition: background 0.3s;
  flex-shrink: 0;
}
body.dark .toggle-track { background: var(--accent); }
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
body.dark .toggle-thumb { transform: translateX(20px); }

/* 날씨 */
.weather-card {
  background: linear-gradient(135deg, #4a90d9 0%, #6fb3f5 100%);
  border-radius: 14px;
  padding: 14px 20px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}
.weather-main { display: flex; align-items: center; gap: 10px; }
.weather-icon { width: 48px; height: 48px; }
.weather-temp { font-size: 2rem; font-weight: 700; }
.weather-desc { font-size: 0.85rem; opacity: 0.9; margin-top: 1px; }
.weather-location { font-size: 0.75rem; opacity: 0.8; margin-bottom: 2px; }
.weather-details { text-align: right; font-size: 0.8rem; opacity: 0.9; line-height: 1.7; flex-shrink: 0; }


/* 시장 */
.section-title {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 24px 0 10px;
  font-weight: 600;
}
.market-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 8px;
}
.market-left {
  flex: 0 0 calc(50% - 6px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.market-right {
  flex: 0 0 calc(50% - 6px);
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.market-right .group-title { flex-shrink: 0; }
.market-right #stocks {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.market-group {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.group-title {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }
.item-name { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 500; }
.item-flag { font-size: 1rem; }
.item-right { text-align: right; }
.item-value { font-size: 0.95rem; font-weight: 700; }
.item-change { font-size: 0.75rem; font-weight: 600; margin-top: 2px; }
.up { color: var(--up); }
.down { color: var(--down); }

/* 뉴스 */
.news-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 10px; }
.news-section { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.news-section-title { font-size: 0.82rem; font-weight: 700; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.news-list { display: flex; flex-direction: column; gap: 12px; }
.news-item { display: flex; align-items: flex-start; gap: 8px; text-decoration: none; color: var(--text); transition: color 0.2s; }
.news-item:hover { color: var(--accent); }
.news-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; margin-top: 6px; }
.news-content { display: flex; flex-direction: column; gap: 4px; }
.news-source {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.2);
  padding: 1px 8px;
  border-radius: 20px;
}
.news-title { font-size: 0.85rem; line-height: 1.5; }

/* 푸터 */
.footer { text-align: center; font-size: 0.72rem; color: var(--muted); padding: 28px 0 20px; }

/* 모바일 */
@media (max-width: 600px) {
  .market-row { flex-direction: column; }
  .market-right { min-height: 300px; }
  .news-grid { grid-template-columns: 1fr; }
  .weather-forecasts { gap: 4px; }
}
