/* === DESIGN TOKENS === */
:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --text: #0f1117;
  --text-soft: #4a5365;
  --text-mute: #8a93a3;
  --border: #e3e7ee;
  --primary: #5b8def;
  --primary-2: #7c5dee;
  --grad: linear-gradient(135deg, #5b8def 0%, #7c5dee 100%);
  --shadow: 0 4px 24px rgba(15, 17, 23, 0.06);
  --radius: 12px;
  --radius-lg: 16px;
}
[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #181b25;
  --surface-2: #232733;
  --text: #f1f3f7;
  --text-soft: #b8c0cc;
  --text-mute: #6e7689;
  --border: #2a2e3b;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }

/* === HEADER === */
.hd { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 100; backdrop-filter: blur(12px); }
.hd-row { display: flex; align-items: center; gap: 24px; padding: 14px 20px; }
.hd-logo { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--text); font-size: 18px; }
.hd-logo-icon { width: 32px; height: 32px; display: grid; place-items: center; background: var(--grad); color: #fff; border-radius: 8px; font-weight: 900; }
.hd-nav { display: flex; gap: 22px; margin-left: auto; }
.hd-nav a { color: var(--text-soft); font-weight: 500; }
.hd-nav a:hover { color: var(--primary); }
.hd-theme { background: none; border: 1px solid var(--border); cursor: pointer; padding: 8px 12px; border-radius: 8px; font-size: 16px; color: var(--text); }
@media (max-width: 720px) { .hd-nav { display: none; } }

/* === HERO === */
.hero { padding: 60px 0 48px; }
.hero-h1 { font-size: clamp(32px, 5vw, 48px); font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; max-width: 800px; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { font-size: 18px; color: var(--text-soft); margin-top: 16px; max-width: 720px; }
.hero-feats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.hero-feat { padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 100px; font-size: 14px; font-weight: 500; }

/* === CATEGORIES === */
.cat { padding: 32px 0; }
.cat-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; }
.cat-head h2 { font-size: 26px; font-weight: 700; }
.cat-count { color: var(--text-mute); font-size: 14px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); transition: transform .15s, box-shadow .2s, border-color .2s; color: var(--text); position: relative; overflow: hidden; }
.card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--card-color, var(--primary)); opacity: 0; transition: opacity .2s; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--card-color, var(--primary)); }
.card:hover::before { opacity: 1; }
.card-icon { font-size: 32px; margin-bottom: 12px; }
.card-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.card-desc { font-size: 14px; color: var(--text-soft); flex: 1; }
.card-cta { margin-top: 14px; font-size: 14px; font-weight: 600; color: var(--card-color, var(--primary)); }

/* === WHY === */
.why { padding: 60px 0 80px; }
.why h2 { font-size: 28px; font-weight: 700; margin-bottom: 28px; text-align: center; }
.why-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.why-item { padding: 24px; background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); }
.why-item b { display: block; margin-bottom: 8px; font-size: 16px; }
.why-item p { color: var(--text-soft); font-size: 14px; }

/* === FOOTER === */
.ft { background: var(--surface); border-top: 1px solid var(--border); margin-top: 80px; padding: 48px 0 24px; }
.ft-row { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 24px; }
.ft-logo { font-weight: 800; font-size: 18px; margin-bottom: 8px; }
.ft-tagline { color: var(--text-mute); font-size: 14px; }
.ft-col h4 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-mute); margin-bottom: 12px; }
.ft-col a, .ft-col span { display: block; color: var(--text-soft); font-size: 14px; margin-bottom: 6px; }
.ft-col a:hover { color: var(--primary); }
.ft-soon { opacity: 0.5; }
.ft-about { font-size: 13px; color: var(--text-soft); }
.ft-bottom { display: flex; justify-content: space-between; padding-top: 24px; margin-top: 32px; border-top: 1px solid var(--border); color: var(--text-mute); font-size: 13px; }
@media (max-width: 720px) { .ft-row { grid-template-columns: 1fr 1fr; } }

/* === CALC PAGE === */
.calc-page { padding: 32px 0 60px; }
.breadcrumb { font-size: 13px; color: var(--text-mute); margin-bottom: 20px; }
.breadcrumb a { color: var(--text-mute); }
.breadcrumb span { margin: 0 6px; }
.calc-head { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 28px; }
.calc-icon { font-size: 28px; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 14px; flex-shrink: 0; }
.calc-h1 { font-size: clamp(24px, 3vw, 32px); font-weight: 800; line-height: 1.2; letter-spacing: -0.01em; }
.calc-desc { color: var(--text-soft); margin-top: 6px; }

.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 24px; align-items: flex-start; }
@media (max-width: 900px) { .calc-layout { grid-template-columns: 1fr; } }

.calc-form { background: var(--surface); padding: 28px; border-radius: var(--radius-lg); border: 1px solid var(--border); position: sticky; top: 84px; }
.calc-form h3 { font-size: 16px; font-weight: 700; margin: 18px 0 10px; }
.calc-form h3:first-child { margin-top: 0; }
.calc-form label { display: block; margin-bottom: 12px; font-size: 14px; font-weight: 500; color: var(--text-soft); }
.calc-form label small { color: var(--text-mute); font-weight: 400; }
.calc-form input, .calc-form select { width: 100%; padding: 11px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; font-size: 15px; font-family: inherit; color: var(--text); margin-top: 4px; transition: border-color .15s; }
.calc-form input:focus, .calc-form select:focus { outline: none; border-color: var(--primary); }
.calc-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.calc-form .check { display: flex; align-items: center; gap: 8px; }
.calc-form .check input { width: auto; margin: 0; }
.btn-primary { background: var(--grad); color: #fff; border: none; padding: 14px 28px; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; width: 100%; margin-top: 12px; transition: transform .1s, box-shadow .2s; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(91, 141, 239, 0.4); }

.calc-result { padding: 28px; background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); min-height: 320px; }
.result-empty { color: var(--text-mute); text-align: center; padding: 60px 20px; }
.result-empty-icon { display: block; font-size: 32px; margin-bottom: 12px; }

/* result content */
.result-main { display: grid; gap: 14px; }
.result-bigval { font-size: 36px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.result-bigval-label { color: var(--text-mute); font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.result-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 18px 0; }
.result-stat { padding: 14px 16px; background: var(--surface-2); border-radius: 10px; }
.result-stat-label { font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.05em; }
.result-stat-value { font-size: 18px; font-weight: 700; margin-top: 4px; }
.result-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.result-section h4 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }

/* AI box */
.ai-box { margin-top: 20px; padding: 18px 20px; background: linear-gradient(135deg, rgba(91, 141, 239, 0.08), rgba(124, 93, 238, 0.08)); border: 1px solid rgba(91, 141, 239, 0.25); border-radius: 14px; }
.ai-box-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-weight: 700; font-size: 14px; }
.ai-box-head .ai-pulse { width: 8px; height: 8px; background: var(--primary); border-radius: 50%; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(1.5); } }
.ai-box-text { font-size: 14px; color: var(--text); white-space: pre-wrap; line-height: 1.6; }
.ai-box-loading { color: var(--text-mute); font-style: italic; }
.ai-box-error { color: #ef4444; font-size: 13px; }

/* schedule table */
.sched { margin-top: 16px; max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.sched table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sched th, .sched td { padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--border); }
.sched th { background: var(--surface-2); position: sticky; top: 0; font-weight: 600; color: var(--text-soft); }
.sched tr:last-child td { border: 0; }

/* time machine */
.tm { margin-top: 16px; }
.tm-row { display: grid; grid-template-columns: 60px 1fr 80px 80px; gap: 10px; padding: 8px 12px; align-items: center; border-radius: 8px; margin-bottom: 4px; }
.tm-year { font-weight: 700; font-size: 14px; }
.tm-bar { height: 6px; background: var(--surface-2); border-radius: 100px; overflow: hidden; }
.tm-fill { height: 100%; transition: width .4s; border-radius: 100px; }
.tm-burden { font-weight: 600; font-size: 13px; }
.tm-low { color: #22c55e; } .tm-low .tm-fill { background: #22c55e; }
.tm-medium { color: #eab308; } .tm-medium .tm-fill { background: #eab308; }
.tm-high { color: #f97316; } .tm-high .tm-fill { background: #f97316; }
.tm-critical { color: #ef4444; } .tm-critical .tm-fill { background: #ef4444; }

/* related */
.related { margin-top: 48px; }
.related h3 { font-size: 18px; margin-bottom: 16px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.related-card { display: flex; align-items: center; gap: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--text); transition: border-color .2s; }
.related-card:hover { border-color: var(--card-color, var(--primary)); }
.related-icon { font-size: 24px; }
.related-title { font-size: 14px; font-weight: 600; }

/* article */
.article { padding: 40px 0 60px; }
.article h2 { font-size: 22px; margin: 24px 0 12px; }
.article h3 { font-size: 18px; margin: 20px 0 8px; }
.article p { color: var(--text-soft); margin-bottom: 12px; }
.article ul { padding-left: 20px; color: var(--text-soft); }
.article li { margin-bottom: 6px; }
.article code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.taxtable { width: 100%; border-collapse: collapse; margin: 16px 0; background: var(--surface); border-radius: 10px; overflow: hidden; }
.taxtable th, .taxtable td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.taxtable th { background: var(--surface-2); font-weight: 600; }
