/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-900: #111827;
  --white: #ffffff;

  /* 테마 변수 (라이트 기본) */
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --border: #e5e7eb;
  --border-2: #d1d5db;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --result-bg: #f9fafb;
  --highlight-bg: #eff6ff;
  --highlight-border: #bfdbfe;
  --ad-bg: #f3f4f6;
  --history-hover: #eff6ff;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --font: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  --content-width: 660px;
  --side-ad-width: 160px;
}

/* ===== 다크모드 ===== */
[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #222534;
  --border: #2e3347;
  --border-2: #3d4460;
  --text-primary: #e8eaf0;
  --text-secondary: #9aa0b8;
  --text-muted: #5a6080;
  --card-bg: #1a1d27;
  --input-bg: #222534;
  --result-bg: #1e2130;
  --highlight-bg: #1e2d4a;
  --highlight-border: #2d4a7a;
  --ad-bg: #1e2130;
  --history-hover: #1e2d4a;
  --primary-light: #1e2d4a;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}
a { color: inherit; text-decoration: none; }

/* ===== 헤더 ===== */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  transition: background 0.2s;
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 20px;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
}
.logo { font-size: 15px; font-weight: 700; color: var(--primary); letter-spacing: -0.5px; }
.logo span { color: var(--text-primary); }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-nav { display: flex; gap: 4px; }
.header-nav a {
  font-size: 13px; color: var(--text-muted);
  padding: 6px 10px; border-radius: var(--radius-sm); transition: all 0.15s;
}
.header-nav a:hover { background: var(--surface-2); color: var(--text-primary); }
.header-nav a.active { color: var(--primary); font-weight: 500; }

/* 다크모드 토글 버튼 */
.dark-toggle {
  width: 36px; height: 36px;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-secondary);
  font-size: 16px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all 0.15s;
}
.dark-toggle:hover { border-color: var(--primary); color: var(--primary); }

/* ===== 3단 레이아웃 ===== */
.page-layout {
  flex: 1; display: flex; justify-content: center; align-items: flex-start;
  gap: 20px; max-width: 1200px; margin: 0 auto;
  padding: 28px 16px; width: 100%;
}
.side-ad { width: var(--side-ad-width); flex-shrink: 0; position: sticky; top: 76px; }
.side-ad-inner {
  background: var(--ad-bg); border: 1px dashed var(--border-2);
  border-radius: var(--radius); min-height: 600px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 11px; text-align: center; padding: 12px 6px;
}
.main-content { flex: 1; min-width: 0; max-width: var(--content-width); }
.main-content.wide { max-width: 860px; }

/* ===== 광고 배너 ===== */
.ad-banner {
  background: var(--ad-bg); border: 1px dashed var(--border-2);
  border-radius: var(--radius); padding: 12px; text-align: center;
  color: var(--text-muted); font-size: 12px; margin: 16px 0;
  min-height: 90px; display: flex; align-items: center; justify-content: center;
}
.ad-banner-tall { min-height: 250px; }

/* ===== 히어로 ===== */
.hero { text-align: center; padding: 32px 0 24px; }
.hero-title { font-size: 26px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; margin-bottom: 8px; }
.hero-title em { color: var(--primary); font-style: normal; }
.hero-desc { font-size: 14px; color: var(--text-muted); }

/* ===== 섹션 / 카드 ===== */
.section-title {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px; margin-bottom: 28px;
}
.tool-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 14px;
  cursor: pointer; transition: all 0.15s; display: block;
}
.tool-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tool-card.coming-soon { opacity: 0.45; cursor: default; pointer-events: none; }
.card-icon { font-size: 24px; margin-bottom: 8px; line-height: 1; }
.card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 3px; }
.card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.card-badge { display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 20px; margin-top: 7px; }
.badge-new { background: #dcfce7; color: #16a34a; }
.badge-soon { background: var(--surface-2); color: var(--text-muted); }
.badge-hot { background: #fef2f2; color: #dc2626; }

/* ===== 푸터 ===== */
.site-footer {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 24px 20px; text-align: center; transition: background 0.2s;
}
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-links { display: flex; justify-content: center; gap: 20px; margin-bottom: 12px; flex-wrap: wrap; }
.footer-links a { font-size: 13px; color: var(--text-secondary); transition: color 0.15s; }
.footer-links a:hover { color: var(--primary); }
.footer-notice {
  font-size: 12px; color: var(--text-muted); line-height: 1.7;
  max-width: 600px; margin: 0 auto 12px;
}
.footer-copy { font-size: 12px; color: var(--text-muted); }

/* ===== 계산기 페이지 ===== */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-muted); margin-bottom: 16px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span { color: var(--border-2); }
.page-title { font-size: 20px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.3px; margin-bottom: 4px; }
.page-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

.calc-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 14px;
  box-shadow: var(--shadow); transition: background 0.2s;
}
.input-group { margin-bottom: 12px; }
.input-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 5px; }
.input-label .sub { font-weight: 400; color: var(--text-muted); font-size: 12px; margin-left: 4px; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.input-field {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text-primary); background: var(--input-bg);
  font-family: var(--font); transition: border-color 0.15s; outline: none;
}
.input-field:focus { border-color: var(--primary); }
.input-field::placeholder { color: var(--text-muted); }

.buy-entry {
  display: grid; grid-template-columns: 1fr 1fr 36px;
  gap: 8px; align-items: center; margin-bottom: 7px;
}
.buy-entry .entry-num {
  grid-column: span 3; font-size: 11px;
  color: var(--text-muted); font-weight: 500; margin-bottom: -3px;
}
.btn-del {
  width: 36px; height: 36px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--input-bg);
  color: var(--text-muted); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.btn-del:hover { border-color: #fca5a5; color: #ef4444; background: #fef2f2; }
.btn-add {
  width: 100%; padding: 8px; border: 1px dashed var(--border-2);
  border-radius: var(--radius-sm); background: none; color: var(--text-muted);
  font-size: 13px; cursor: pointer; font-family: var(--font);
  transition: all 0.15s; margin-top: 3px;
}
.btn-add:hover { border-color: var(--primary); color: var(--primary); background: var(--highlight-bg); }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

/* ===== 결과 ===== */
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.result-card {
  background: var(--result-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.result-card.highlight { background: var(--highlight-bg); border-color: var(--highlight-border); }
.result-label { font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
.result-value { font-size: 18px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.5px; }
.result-value.profit { color: #dc2626; }
.result-value.loss { color: #2563eb; }
.result-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.result-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.result-table th {
  text-align: left; padding: 7px 10px;
  background: var(--surface-2); color: var(--text-muted);
  font-weight: 500; border-bottom: 1px solid var(--border); font-size: 12px;
}
.result-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
.result-table tr:last-child td { border-bottom: none; }
.result-table tr.add-row { background: var(--highlight-bg); }
.pct-pos { color: #dc2626; font-weight: 500; }
.pct-neg { color: #2563eb; font-weight: 500; }
.pct-zero { color: var(--text-muted); }

/* ===== BEP 바 ===== */
.bep-bar-wrap { margin: 4px 0 14px; }
.bep-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.bep-bar-label { font-size: 12px; color: var(--text-muted); width: 60px; flex-shrink: 0; text-align: right; }
.bep-bar-track { flex: 1; height: 20px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bep-bar-fill {
  height: 100%; border-radius: 4px; display: flex; align-items: center;
  padding: 0 10px; font-size: 11px; font-weight: 600;
  color: #fff; transition: width 0.4s; white-space: nowrap; min-width: 40px;
}

/* ===== 최근 기록 ===== */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.history-item:hover { border-color: var(--primary); background: var(--history-hover); }
.history-main { flex: 1; min-width: 0; }
.history-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.history-sub { font-size: 12px; color: var(--text-muted); }
.history-pnl { font-size: 13px; font-weight: 600; flex-shrink: 0; }
.history-pnl.pos { color: #dc2626; }
.history-pnl.neg { color: #2563eb; }
.history-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.history-del {
  width: 24px; height: 24px; border: none; background: none;
  color: var(--text-muted); font-size: 14px; cursor: pointer;
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.history-del:hover { color: #ef4444; background: #fef2f2; }

/* ===== 관련 계산기 ===== */
.related-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px; margin-top: 10px;
}
.related-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  text-align: center; transition: all 0.15s; display: block;
}
.related-card:hover { border-color: var(--primary); color: var(--primary); }
.related-card .r-icon { font-size: 18px; margin-bottom: 5px; }

/* ===== 개인정보 ===== */
.prose h2 { font-size: 15px; font-weight: 700; margin: 22px 0 9px; color: var(--text-primary); }
.prose p, .prose li { font-size: 14px; color: var(--text-secondary); line-height: 1.8; margin-bottom: 7px; }
.prose ul { padding-left: 18px; }

/* ===== 모바일 ===== */
@media (max-width: 900px) { .side-ad { display: none; } }
@media (max-width: 600px) {
  .header-nav { display: none; }
  .hero-title { font-size: 20px; }
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .tool-card { padding: 12px 10px; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .input-row { grid-template-columns: 1fr; }
  .calc-card { padding: 16px; }
  .result-value { font-size: 16px; }
  .page-layout { padding: 16px 12px; }
  .footer-links { gap: 12px; }
}
