/* ---------- Design tokens ----------
   Dark is the default. Light is a warm "map paper" palette.
   Two shades per theme: --chrome (header + footer) and --bg (page body). */
:root {
  color-scheme: dark;
  --bg: #0b1420;
  --chrome: #15263c;
  --chrome-border: #22374f;
  --surface: #122033;
  --surface-2: #1a2b41;
  --text: #edf1f6;
  --muted: #9fb0c6;
  --border: #23354c;
  --accent: #f4efe4;
  --accent-ink: #0e1b2c;
  --accent-soft: #1c2c42;
  --north: #ff6a5e;
  --danger: #ff6a5e;
  --mark-bg: #1d3150;
  --glow: rgb(122 162 255 / .10);
  --gold: #d9ae45;
  --ok: #46c37b;
  --shadow: 0 1px 2px rgb(0 0 0 / .35), 0 10px 30px rgb(0 0 0 / .28);
  --radius-sm: 8px;
  --radius: 16px;
  --max: 1040px;
  --tap: 44px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fbf5ea;
  --chrome: #f0e1c7;
  --chrome-border: #e2cda8;
  --surface: #fffaf1;
  --surface-2: #f6ead5;
  --text: #2a2018;
  --muted: #6f604c;
  --border: #ead9bb;
  --accent: #0e1b2c;
  --accent-ink: #fdf8ef;
  --accent-soft: #f3e4c9;
  --north: #c8352b;
  --danger: #c8352b;
  --mark-bg: #0e1b2c;
  --glow: rgb(214 150 60 / .16);
  --gold: #b07f1f;
  --ok: #1f8a4c;
  --shadow: 0 1px 2px rgb(90 60 20 / .06), 0 8px 24px rgb(90 60 20 / .09);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.icon { width: 1em; height: 1em; flex: none; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 10;
  background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 12px; }

/* ---------- Header / footer ---------- */
header.site {
  position: sticky; top: 0; z-index: 5;
  background: var(--chrome);
  border-bottom: 1px solid var(--chrome-border);
  box-shadow: 0 1px 0 rgb(0 0 0 / .04);
}
header.site .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.logo {
  display: inline-flex; align-items: center;
  gap: 9px; font-size: 1.2rem; letter-spacing: -.025em; text-decoration: none; color: var(--text);
}
.logo .mark { width: 30px; height: 30px; flex: none; display: block; }
.logo .wm-a { font-weight: 500; color: var(--muted); }
.logo .wm-b { font-weight: 800; }
nav.main a { white-space: nowrap; }
nav.main { display: flex; gap: 4px; }
nav.main a {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 12px;
  border-radius: var(--radius-sm); text-decoration: none; color: var(--muted); font-size: .95rem; font-weight: 500;
}
nav.main a:hover { color: var(--text); background: var(--surface-2); }
nav.main a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

footer.site { background: var(--chrome); border-top: 1px solid var(--chrome-border); padding: 36px 0 28px; color: var(--muted); font-size: .92rem; margin-top: 24px; }
.foot-grid { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px 40px; }
.foot-brand { max-width: 340px; }
.foot-brand .logo { margin-bottom: 8px; }
.foot-brand p { margin: 0; }
.foot-links { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: flex-start; padding: 0; margin: 4px 0 0; list-style: none; }
footer.site a { color: var(--muted); text-decoration: none; }
footer.site a:hover { color: var(--text); text-decoration: underline; }
.foot-copy { border-top: 1px solid var(--chrome-border); margin-top: 24px; padding-top: 16px; font-size: .85rem; }

/* ---------- Layout & type ---------- */
main { padding: 28px 0 56px; }
h1 { font-size: clamp(1.75rem, 4.5vw, 2.6rem); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 10px; }
h2 { font-size: 1.35rem; line-height: 1.3; letter-spacing: -.01em; margin: 44px 0 12px; }
h3 { font-size: 1.05rem; margin: 24px 0 6px; }
.lead { color: var(--muted); font-size: 1.125rem; margin: 0 0 24px; max-width: 60ch; }
.eyebrow { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; }

.breadcrumb { font-size: .875rem; color: var(--muted); margin-bottom: 14px; }
.breadcrumb ol { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0; }
.breadcrumb li + li::before { content: "›"; margin-right: 6px; }
.breadcrumb a { color: var(--muted); }

/* ---------- Hero (home) ---------- */
.hero { padding: 24px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0; margin: 0 0 36px; list-style: none; color: var(--muted); font-size: .95rem; }
.chips li { display: inline-flex; align-items: center; gap: 6px; }
.chips .icon { color: var(--accent); }

/* ---------- Tool cards ---------- */
.tools-featured { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.tool-card {
  position: relative; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: start;
  padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); text-decoration: none; color: var(--text);
  transition: border-color .15s ease, transform .15s ease;
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tool-card .tile {
  grid-row: span 3; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); font-size: 26px;
}
.tool-card h3 { margin: 2px 0 0; font-size: 1.15rem; }
.tool-card p { margin: 0; color: var(--muted); font-size: .95rem; }
.tool-card .cta { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-weight: 600; color: var(--accent); font-size: .95rem; }
.tool-card:hover .cta .icon { transform: translateX(3px); }
.cta .icon { transition: transform .15s ease; }

.tools-soon { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); padding: 0; list-style: none; margin: 0; }
.tools-soon li {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px dashed var(--border); color: var(--muted); font-size: .95rem;
}
.tools-soon .icon { font-size: 20px; }
.badge {
  margin-left: auto; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted);
}

/* ---------- Tool panels & controls ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.btn, button, select {
  font: inherit; font-size: .95rem; font-weight: 500; min-height: var(--tap); padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); background: var(--surface-2); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 10px; }
.seg button { border: 0; min-height: 38px; background: transparent; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }

.readout { font-size: clamp(1.8rem, 6vw, 2.4rem); font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin: 0; line-height: 1.2; }
.readout small { display: block; font-size: .95rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.hint { color: var(--muted); font-size: .9rem; margin: 6px 0 0; }
.hint.ok { color: var(--accent); }

/* Ad slots stay collapsed until real ad code is added (add class "is-live"). */
.ad-slot { display: none; }
.ad-slot.is-live { display: block; margin: 32px 0; min-height: 250px; }

/* ---------- Article content ---------- */
article.content { max-width: 70ch; }
article.content li { margin-bottom: 6px; }
.related { margin-top: 48px; }
.related .tools-featured { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  nav.main a { padding: 0 10px; font-size: .9rem; }
  nav.main a.hide-sm { display: none; }
  .logo { font-size: 1.1rem; }
  .tool-card { padding: 16px; }
  .tool-card .tile { width: 44px; height: 44px; font-size: 22px; }
  .panel { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Brand mark ---------- */
.mark .bg { fill: var(--mark-bg); }

/* ---------- Theme toggle & link buttons ---------- */
.theme-toggle { width: var(--tap); padding: 0; border-color: transparent; background: transparent; color: var(--muted); }
.theme-toggle:hover { color: var(--text); background: var(--surface-2); border-color: transparent; }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-moon { display: block; }
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }
a.button-link {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 18px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
}

/* ---------- Homepage hero & compass panel ---------- */
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 22px; list-style: none; }
.hero-chips li { font-size: .85rem; font-weight: 600; padding: 5px 12px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.panel.compass-wrap { background: radial-gradient(circle at 50% 38%, var(--glow), transparent 62%), var(--surface); }

/* ---------- Content sections ---------- */
article.content h2 { padding-top: 8px; }
.card-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); padding: 0; margin: 16px 0 0; list-style: none; }
.card-grid li { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin: 0; box-shadow: var(--shadow); }
.card-grid li strong { display: block; margin-bottom: 2px; }
.compare { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: .95rem; background: var(--surface); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.compare th, .compare td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.compare thead th { background: var(--surface-2); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.compare tr:last-child td { border-bottom: 0; }

/* ---------- FAQ accordion ---------- */
.faq { display: grid; gap: 10px; margin-top: 16px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); transition: border-color .15s ease; }
.faq summary { -webkit-tap-highlight-color: transparent; }
.faq summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 15px 18px; min-height: var(--tap); font-weight: 650; font-size: 1.02rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: ""; flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / 14px no-repeat;
  transition: transform .2s ease; }
.faq details[open] summary::after { transform: rotate(180deg); }
.faq .faq-a { padding: 0 18px 16px; color: var(--muted); }
.faq .faq-a p { margin: 0; }

/* keep anchored headings clear of the sticky header */
[id] { scroll-margin-top: 76px; }
footer.site .foot-brand .logo { color: var(--text); }
footer.site .foot-brand .logo:hover { text-decoration: none; }

/* ---------- Compass widget (shared by compass, Qibla and Vastu pages) ---------- */
.compass-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 28px 20px; }
.dial-box { position: relative; width: min(78vw, 340px); aspect-ratio: 1; }
#dial { width: 100%; height: 100%; transition: transform .2s linear; color: var(--text); }
.needle { position: absolute; left: 50%; top: -8px; transform: translateX(-50%);
  width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent;
  border-top: 18px solid var(--north); }
.heading { font-size: clamp(2.4rem, 9vw, 3rem); font-weight: 750; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; margin: 0; line-height: 1; }
.status { color: var(--muted); text-align: center; max-width: 440px; margin: 0; font-size: .95rem; }
@media (max-width: 600px) { main { padding-top: 16px; } .lead { margin-bottom: 16px; } }

/* ---------- Tool pages: steps, Qibla, Vastu ---------- */
.step-panel { margin-bottom: 16px; }
.step-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 1.1rem; align-self: flex-start; }
.step-num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--accent); color: var(--accent-ink); font-size: .9rem; font-weight: 800; }
.controls select { min-width: 220px; max-width: 100%; }
.qibla-result { margin: 4px 0 0; font-size: 1.05rem; }
.qibla-deg { font-weight: 800; font-size: 1.35em; margin: 0 4px; color: var(--gold); }
.qibla-km { display: block; color: var(--muted); font-size: .9rem; }
.qibla-guide { margin: 0; font-weight: 700; font-size: 1.1rem; text-align: center; }
.compass-wrap.on-target { border-color: var(--ok); box-shadow: 0 0 0 2px var(--ok), var(--shadow); }
.compass-wrap.on-target .qibla-guide { color: var(--ok); }

.zone { fill: var(--surface-2); stroke: var(--border); stroke-width: .6; transition: fill .2s ease; }
.zone-odd { fill: var(--surface); }
.zone-main { fill: var(--accent-soft); }
.zone.active { fill: color-mix(in srgb, var(--north) 60%, var(--surface)); }
.zone.active + .zone-label { fill: #fff; }
.zone-label { fill: var(--text); font: 700 7px system-ui, sans-serif; text-anchor: middle; dominant-baseline: central; }
.zone-label-main { font-size: 10px; }
.zone-label-n { fill: var(--north); }
.zone-readout { text-align: center; }
.zone-name { margin: 0; font-weight: 750; font-size: 1.1rem; }
.zone-info { margin: 4px auto 0; color: var(--muted); max-width: 440px; }

.related-tools { margin-top: 28px; font-weight: 600; }
.tool-links { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 16px 0 0; }
.tool-link { display: block; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); text-decoration: none; color: var(--text); transition: border-color .15s ease, transform .15s ease; }
.tool-link:hover { border-color: var(--north); transform: translateY(-2px); }
.tool-link strong { display: block; font-size: 1.05rem; margin-bottom: 2px; }
.tool-link span { color: var(--muted); font-size: .95rem; }
@media (max-width: 600px) { nav.main a { padding: 0 8px; } }

/* ---------- Footer feature list (plain text, not buttons) ---------- */
.foot-features { display: flex; flex-wrap: wrap; gap: 10px 26px; list-style: none; padding: 0 0 24px; margin: 0 0 28px;
  border-bottom: 1px solid var(--chrome-border); color: var(--text); font-size: .95rem; font-weight: 600; }
.foot-features li { display: inline-flex; align-items: center; gap: 8px; }
.foot-features li::before { content: ""; width: 18px; height: 18px; flex: none; border-radius: 50%; background: var(--ok)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat; }

/* ---------- Vastu compass (8 directions + 4 kon) ---------- */
:root { --vz-main: #182a40; --vz-water: #1c4466; --vz-fire: #6b2f1e; --vz-earth: #57452a; --vz-air: #24505a; --vz-line: #2b405b; --vz-centre: #0f1d2e; }
:root[data-theme="light"] { --vz-main: #fbf2e1; --vz-water: #d3e5f5; --vz-fire: #f8d2bd; --vz-earth: #ead9b8; --vz-air: #d2ebe7; --vz-line: #e0cba6; --vz-centre: #fffaf1; }
.vastu-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .vastu-layout { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } }
.vastu-compass .dial-box { width: min(100%, 380px); }
.vz { stroke: var(--vz-line); stroke-width: 1; transition: fill .2s ease; }
.vz-main { fill: var(--vz-main); } .vz-water { fill: var(--vz-water); } .vz-fire { fill: var(--vz-fire); }
.vz-earth { fill: var(--vz-earth); } .vz-air { fill: var(--vz-air); }
.vz.active { stroke: var(--north); stroke-width: 2.5; }
.vz-label text { fill: var(--text); text-anchor: middle; dominant-baseline: central; font-family: system-ui, sans-serif; }
.vz-name { font-size: 9.5px; font-weight: 800; }
.vz-code { font-size: 7.5px; font-weight: 700; opacity: .75; }
.vz-label-n .vz-name, .vz-label-n .vz-code { fill: var(--north); opacity: 1; }
.vz-centre circle { fill: var(--vz-centre); stroke: var(--vz-line); }
.vz-centre text { fill: var(--muted); text-anchor: middle; dominant-baseline: central; font-family: system-ui, sans-serif; }
.vz-centre-t { font-size: 7.5px; font-weight: 700; } .vz-centre-s { font-size: 6px; }
.facing-tag { position: absolute; left: 50%; top: -30px; transform: translateX(-50%); font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--north); white-space: nowrap; }
.vastu-compass { padding-top: 44px; }

.vastu-readout { display: flex; flex-direction: column; gap: 6px; }
.vr-label { margin: 0; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.vr-name { margin: 0; font-size: clamp(1.7rem, 6vw, 2.2rem); font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.vr-hi { font-size: .6em; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.vr-en { margin: 0 0 8px; font-weight: 600; color: var(--north); }
.vr-facts { margin: 4px 0 12px; display: grid; gap: 8px; }
.vr-facts div { display: grid; grid-template-columns: 82px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.vr-facts dt { color: var(--muted); font-size: .88rem; font-weight: 600; }
.vr-facts dd { margin: 0; font-size: .95rem; }
.vr-around { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.vr-around div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; text-align: center; }
.vr-around span { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.vr-around strong { font-size: .88rem; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.vastu-table tr.active th, .vastu-table tr.active td { background: var(--accent-soft); }
.vastu-table tr.active th { box-shadow: inset 3px 0 0 var(--north); }
.compare .code { display: inline-block; margin-left: 4px; font-size: .75rem; font-weight: 800; color: var(--north); }
.note { color: var(--muted); font-size: .92rem; }

.lang-table td { font-size: 1.02rem; }
.kon-cards li { line-height: 1.55; }

/* ---------- Embed code box ---------- */
.embed-box { display: grid; gap: 10px; margin: 14px 0 8px; }
.embed-box textarea { width: 100%; font: .85rem/1.5 ui-monospace, Consolas, monospace; padding: 12px 14px; resize: vertical;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; }
.embed-box button { justify-self: start; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.lang-links { margin: -14px 0 20px; font-size: .9rem; color: var(--muted); }
.lang-links a { font-weight: 600; }

/* ---------- Sun direction tool ---------- */
.date-input { font: inherit; font-size: .95rem; min-height: var(--tap); padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.sun-place { margin: 14px 0 6px; color: var(--muted); font-size: .9rem; }
.sun-table th { width: 34%; }
.sun-legend { display: flex; gap: 18px; list-style: none; padding: 0; margin: 0; font-size: .88rem; color: var(--muted); }
.sun-legend li { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.lg-sun { background: #f5c542; } .lg-rise { background: #f0a43a; } .lg-set { background: #d9624a; }
