
:root {
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --surface-alt: #F2EBE1;
  --fjord: #2C1E16;
  --fjord-mid: #4A3224;
  --fjord-light: #F3EAE3;
  --spruce: #B86B35;
  --spruce-dark: #945224;
  --spruce-soft: #F9EEE6;
  --stone: #6B5B50;
  --ink: #231914;
  --ink-muted: #6B5B50;
  --border: #E2D6C8;
  --radius: 12px;
  --shadow: 0 6px 22px rgba(44, 30, 22, 0.07);
  --maxw: 1180px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  font-size: 16px;
}

a { color: var(--fjord-mid); text-decoration: none; }
a:hover { color: var(--spruce-dark); text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
}
.brand-link,
.brand-link:hover,
.brand-link:focus,
.brand-link:active {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--fjord);
}
.brand-mark { width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; }
.brand-name { font-weight: 800; font-size: 1.18rem; letter-spacing: -0.02em; color: var(--fjord); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a,
.nav-links a:hover,
.nav-links a:focus,
.nav-links a:active {
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 6px 2px;
  text-decoration: none;
  transition: color 0.15s ease;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--spruce-dark);
  text-decoration: none;
}

.header-search {
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-search input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--ink);
  width: 210px;
}
.header-search button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  background: var(--fjord);
  color: #fff;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover, .header-search button:hover { background: var(--fjord-mid); color: #fff; text-decoration: none; }
.btn-accent { background: var(--spruce); color: #fff; }
.btn-accent:hover { background: var(--spruce-dark); color: #fff; }
.btn-fjord { background: var(--fjord-mid); color: #fff; }
.btn-fjord:hover { background: var(--fjord); color: #fff; }
.btn-outline { background: transparent; color: var(--fjord); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--surface-alt); color: var(--fjord); }
.btn-hero-ghost { background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.38); }
.btn-hero-ghost:hover { background: rgba(255,255,255,0.2); color: #fff; }

.nav-toggle {
  display: none;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--fjord);
  cursor: pointer;
}

/* Hero — Nordic Fjord Blue + Spruce Accent */
.hero {
  background: linear-gradient(135deg, #102537 0%, #2C1E16 52%, #244C6B 100%);
  color: #fff;
  padding: 52px 0;
  border-bottom: 4px solid var(--spruce);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 34px;
  align-items: center;
}
.hero-badge {
  display: inline-block;
  background: rgba(184, 125, 75, 0.22);
  color: #F2D7BC;
  border: 1px solid rgba(184, 125, 75, 0.48);
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.hero h1 {
  font-size: clamp(1.9rem, 3.3vw, 2.65rem);
  line-height: 1.18;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}
.hero p { color: #D8E2EB; font-size: 1.06rem; margin: 0 0 22px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-media {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.16);
}
.hero-media img { width: 100%; height: 320px; object-fit: cover; }

/* Sections & Cards */
.section { padding: 44px 0; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.section-head h2 { margin: 0; font-size: 1.55rem; letter-spacing: -0.01em; color: var(--fjord); }
.section-head p { margin: 4px 0 0; color: var(--ink-muted); }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--spruce); }
.card-img {
  margin: -20px -20px 6px;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}
.card-img img { width: 100%; height: 190px; object-fit: cover; }
.card-tag {
  display: inline-block;
  width: fit-content;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fjord);
  background: var(--fjord-light);
  padding: 3px 9px;
  border-radius: 6px;
}
.card h3 { margin: 0; font-size: 1.1rem; line-height: 1.35; }
.card h3 a { color: var(--fjord); }
.card h3 a:hover { color: var(--spruce-dark); }
.card p { margin: 0; color: var(--ink-muted); font-size: 0.94rem; }
.card-foot { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 0.92rem; }

/* Wizard & Calculator */
.wizard-box, .calc-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--spruce);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.calc-layout {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 24px;
  align-items: start;
}
.field-group { margin-bottom: 14px; }
.field-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 5px;
  color: var(--fjord);
}
.field-group input, .field-group select, .field-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.96rem;
  background: #fff;
  color: var(--ink);
}
.field-group input:focus, .field-group select:focus, .field-group textarea:focus {
  outline: 2px solid rgba(184, 125, 75, 0.35);
  border-color: var(--spruce);
}
.field-hint { font-size: 0.78rem; color: var(--ink-muted); margin-top: 3px; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.result-tile {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.result-tile .res-label { font-size: 0.8rem; color: var(--stone); font-weight: 600; }
.result-tile .res-val { font-size: 1.38rem; font-weight: 800; color: var(--fjord); margin-top: 4px; }

.callout {
  border-left: 4px solid var(--fjord);
  background: var(--fjord-light);
  padding: 14px 16px;
  border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
  margin: 16px 0;
}
.callout-spruce { border-left-color: var(--spruce); background: var(--spruce-soft); }

/* Filter Pills */
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.pill {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fjord);
  font-size: 0.86rem;
  font-weight: 600;
}
.pill.active, .pill:hover {
  background: var(--fjord);
  color: #fff;
  border-color: var(--fjord);
  text-decoration: none;
}

/* Article Typography */
.article-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 30px;
  align-items: start;
}
.article-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}
.article-body h1 { color: var(--fjord); }
.article-body h2 { margin-top: 28px; font-size: 1.4rem; color: var(--fjord); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.article-body h3 { margin-top: 20px; font-size: 1.15rem; color: var(--fjord-mid); }
.article-body p { margin: 0 0 1rem; font-weight: 400; line-height: 1.72; }
.article-body p:last-child { margin-bottom: 0; }
.article-body strong { font-weight: 700; }
.article-body ul, .article-body ol { margin: .5rem 0 1.15rem; padding-left: 1.35rem; }
.article-body li { margin-bottom: .42rem; font-weight: 400; line-height: 1.65; }
.article-body table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 0.92rem; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 9px 12px; text-align: left; }
.article-body th { background: var(--fjord-light); color: var(--fjord); }
.article-body a { color: var(--spruce-dark); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.article-body a:hover { opacity: .85; }
.article-hero-img { border-radius: 10px; overflow: hidden; margin: 18px 0; }
.article-hero-img img { width: 100%; max-height: 410px; object-fit: cover; }

/* Footer */
.site-footer {
  background: var(--fjord);
  color: #D8E2EB;
  padding: 42px 0 28px;
  margin-top: 48px;
  border-top: 4px solid var(--spruce);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 28px;
}
.site-footer h4 { color: #fff; margin: 0 0 12px; font-size: 1rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 7px; }
.site-footer a { color: #D8E2EB; font-size: 0.92rem; text-decoration: none; }
.site-footer a:hover { color: #F2D7BC; text-decoration: none; }
.footer-note { font-size: 0.84rem; opacity: 0.85; }
.footer-bottom {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

.cookie-bar {
  position: fixed;
  bottom: 16px;
  right: 16px;
  max-width: 390px;
  background: var(--fjord);
  color: #fff;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  z-index: 80;
  font-size: 0.88rem;
}

@media (max-width: 960px) {
  .hero-grid, .calc-layout, .article-wrap, .footer-grid, .grid-3, .grid-4, .grid-2 {
    grid-template-columns: 1fr;
  }
  .nav-toggle { display: inline-block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 72px;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 16px 20px;
    align-items: flex-start;
  }
  .nav-links.open { display: flex; }
  .header-search { display: none; }
}

@media print {
  .site-header, .site-footer, .cookie-bar, .no-print { display: none !important; }
  body { background: #fff; }
  .card, .article-body, .calc-panel { box-shadow: none; border-color: #ccc; }
}

/* Related Guides on Tool Detail (3 cols desktop, 2 tablet, 1 mobile, 16:10 rounded cover) */
.related-guides-section { margin-top: 40px; width: 100%; }
.related-guides-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
.related-guide-card { padding: 18px; }
.related-guide-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 4px;
  background: var(--surface-alt);
}
.related-guide-thumb a { display: block; width: 100%; height: 100%; }
.related-guide-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
@media (max-width: 960px) {
  .related-guides-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .related-guides-grid { grid-template-columns: 1fr; }
}

html, body { max-width: 100%; overflow-x: hidden; }
*, *::before, *::after { box-sizing: border-box; }
main, section, article, aside, .container,
.hero-grid, .tool-layout, .article-layout, .article-wrap,
.calc-panel, .calc-card, .calc-main, .article-main, .article-body, .article-content,
.related-guides-grid, .cards-grid, .grid-3, .grid-2, .footer-grid {
  min-width: 0 !important;
  max-width: 100% !important;
}
.hero-grid > *, .tool-layout > *, .article-layout > *, .article-wrap > *,
.calc-inputs > *, .result-grid > *, .cards-grid > *, .grid-3 > *, .grid-2 > *,
.related-guides-grid > *, .footer-grid > * {
  min-width: 0 !important;
  max-width: 100% !important;
}
img, svg, video, iframe { max-width: 100%; height: auto; }
input, select, textarea, button { max-width: 100%; min-width: 0; }
.article-body, .article-content, .calc-card, .card, .method-box, .side-card, .side-box {
  overflow-wrap: break-word;
  word-wrap: break-word;
}
@media (max-width: 900px) {
  .container { width: 100% !important; padding-left: 14px !important; padding-right: 14px !important; }
  .hero-grid, .tool-layout, .article-layout, .article-wrap, .footer-grid,
  .calc-inputs, .result-grid, .cards-3, .grid-3, .grid-2 {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .header-inner { flex-wrap: wrap; gap: 0.5rem; }
  .header-search, .header-search input, .filter-bar input, .filter-bar select, .wizard-controls select {
    width: 100% !important; max-width: 100% !important; min-width: 0 !important;
  }
  .calc-card, .article-body, .method-box, .side-card, .side-box, .wizard-card, .wizard-box { padding: 1rem !important; }
  .region-bar, .preset-bar, .calc-header, .calc-preset-row {
    flex-direction: column !important; align-items: stretch !important; gap: 0.5rem !important;
  }
  .region-bar select, .preset-bar select, .calc-preset-row select { width: 100% !important; min-width: 0 !important; }
}
@media (max-width: 600px) {
  .related-guides-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .article-body table, .article-content table, table {
    display: table !important;
    width: 100% !important;
    table-layout: fixed !important;
    font-size: 12px !important;
  }
  .article-body th, .article-body td, .article-content th, .article-content td, th, td {
    padding: 6px 5px !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    white-space: normal !important;
    hyphens: auto;
  }
}

.calc-layout, .calc-layout > * {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box;
}
.calc-panel select, .calc-card select, select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 640px) {
  .calc-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .calc-panel .region-bar,
  .calc-panel .profile-bar,
  .calc-panel .preset-row,
  .calc-card > div:has(> select),
  .calc-panel > div:has(> select) {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
}
