:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Palette */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #1e3a5f;
  --text: #0f172a;
  --text-muted: #475569;
  --text-heading: #0f172a;
  --primary: #1e3a5f;
  --primary-light: #2d5584;
  --primary-subtle: #e0e7ff;
  --accent: #b45309;
  --accent-light: #fef3c7;
  --success: #059669;
  --warning: #b45309;
  --danger: #dc2626;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #1e293b;
    --surface-subtle: #0f172a;
    --border: #334155;
    --border-focus: #38bdf8;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-heading: #ffffff;
    --primary: #38bdf8;
    --primary-light: #7dd3fc;
    --primary-subtle: rgba(56, 189, 248, 0.15);
    --accent: #f59e0b;
    --accent-light: rgba(245, 158, 11, 0.15);
    --success: #34d399;
    --warning: #fbbf24;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  }
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent);
}

img, svg {
  vertical-align: middle;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text-heading);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.site-logo svg {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-nav a {
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text-muted);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--primary);
  background: var(--surface-subtle);
}

/* Main Layout */
.site-main {
  min-height: calc(100vh - 220px);
  padding: 2.5rem 1.25rem 3.5rem;
}

.layout-narrow {
  max-width: 760px;
  margin: 0 auto;
}

.layout-wide {
  max-width: 1120px;
  margin: 0 auto;
}

/* Breadcrumb */
.breadcrumb-nav {
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.breadcrumb-nav a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb-nav a:hover {
  text-decoration: underline;
}

.breadcrumb-nav span {
  margin: 0 0.4rem;
  color: var(--border);
}

/* Page Intro */
.page-intro {
  margin-bottom: 2.25rem;
}

.page-title {
  font-size: 2.1rem;
  line-height: 1.25;
  font-weight: 800;
  color: var(--text-heading);
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.page-desc {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 820px;
}

/* Hero Banner on Homepage */
.hero-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  margin-bottom: 3rem;
  box-shadow: var(--shadow-sm);
}

.hero-box h1 {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-heading);
  letter-spacing: -0.02em;
  margin-bottom: 0.85rem;
}

.hero-box p {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 780px;
  line-height: 1.6;
}

.hero-badges {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
}

/* Grid & Cards */
.category-section {
  margin-bottom: 3rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.6rem;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-heading);
}

.section-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-focus);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-heading);
  line-height: 1.35;
  margin-bottom: 0.45rem;
}

.card-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 1rem;
}

.card-meta {
  font-size: 0.82rem;
  color: var(--primary);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* Workbench Grid (Calculator Tool Page) */
.tool-workbench {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
  align-items: start;
}

@media (max-width: 860px) {
  .tool-workbench {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

.form-panel, .result-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-heading);
}

.form-group {
  margin-bottom: 1.15rem;
}

.form-group label {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.35rem;
}

.form-input, .form-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-subtle);
  background: var(--surface);
}

/* Result Presentation */
.result-hero {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
}

.result-hero-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.result-hero-val {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.15;
}

.result-assumption {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-style: italic;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.metric-cell {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
}

.metric-cell-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.metric-cell-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-heading);
}

.recommendations-box {
  background: var(--surface-subtle);
  border-left: 4px solid var(--primary);
  padding: 0.85rem 1.1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.recommendations-box ul {
  padding-left: 1.25rem;
}

.recommendations-box li {
  margin-bottom: 0.35rem;
}

/* Tool Page Sections */
.tool-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.tool-section h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.tool-section ol, .tool-section ul {
  padding-left: 1.4rem;
  margin-bottom: 1rem;
}

.tool-section li {
  margin-bottom: 0.45rem;
  line-height: 1.65;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.faq-item {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.faq-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-q {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.35rem;
}

.faq-a {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* Related Guides and Tools */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.related-card {
  display: block;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
}

.related-card:hover {
  border-color: var(--primary);
  background: var(--surface);
}

.related-card-title {
  font-weight: 600;
  color: var(--text-heading);
  font-size: 0.98rem;
  margin-bottom: 0.25rem;
}

.related-card-arrow {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 500;
}

/* Disclaimer Box */
.disclaimer-alert {
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.6;
}

.disclaimer-alert strong {
  color: var(--accent);
}

/* Guide Article Styling */
.article-header {
  margin-bottom: 2.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.article-body {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text);
}

.article-body h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 2rem 0 0.75rem;
}

.article-body h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-heading);
  margin: 1.5rem 0 0.5rem;
}

.article-body p {
  margin-bottom: 1.25rem;
}

.article-body ul, .article-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.article-body li {
  margin-bottom: 0.4rem;
}

.article-body blockquote {
  border-left: 4px solid var(--border-focus);
  padding-left: 1rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-style: italic;
}

.article-related-tools {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid var(--border);
}

/* Footer */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 3rem 1.25rem 2.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-container {
  max-width: 1120px;
  margin: 0 auto;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
}

.footer-nav a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.footer-disclaimer {
  line-height: 1.6;
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

/* Responsive adjustment for small devices */
@media (max-width: 480px) {
  .page-title {
    font-size: 1.7rem;
  }
  .hero-box {
    padding: 1.5rem 1.25rem;
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
  .form-panel, .result-panel {
    padding: 1.25rem;
  }
  .tool-section {
    padding: 1.25rem;
  }
}
