/* ==========================================================================
   PercentSwift — Google Material Design 3 (Material You) Unified Design System
   Mathematical, Geometric & Structural Layout Architecture (LTR & RTL)
   ========================================================================== */

@font-face {
  font-family: "PercentSwift Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/roboto-latin.woff2") format("woff2");
}

@font-face {
  font-family: "PercentSwift Arabic";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/noto-arabic.woff2") format("woff2");
}

/* --------------------------------------------------------------------------
   1. Material Design 3 Design Tokens (Light & Dark Tonal Palettes + 8dp Grid)
   -------------------------------------------------------------------------- */
:root,
[data-theme="light"] {
  color-scheme: light;

  /* M3 Primary Tonal Palette (Google Blue) */
  --md-sys-color-primary: #0b57d0;
  --md-sys-color-primary-hover: #0842a0;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d3e3fd;
  --md-sys-color-on-primary-container: #041e49;

  /* M3 Secondary Tonal Palette */
  --md-sys-color-secondary: #00639b;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #c2e7ff;
  --md-sys-color-on-secondary-container: #001d35;

  /* M3 Tertiary Tonal Palette */
  --md-sys-color-tertiary: #146c2e;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #c4eed0;
  --md-sys-color-on-tertiary-container: #072711;

  /* M3 Error Tonal Palette */
  --md-sys-color-error: #b3261e;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #f9dedc;
  --md-sys-color-on-error-container: #410e0b;

  /* M3 Surface & Tonal Elevation Hierarchy */
  --md-sys-color-surface: #f8fafd;
  --md-sys-color-surface-dim: #d8dae0;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f0f4f9;
  --md-sys-color-surface-container: #e9eef6;
  --md-sys-color-surface-container-high: #e1e7f0;
  --md-sys-color-surface-container-highest: #dae0ea;

  /* M3 On-Surface & Outline Tokens */
  --md-sys-color-on-surface: #1f1f1f;
  --md-sys-color-on-surface-variant: #444746;
  --md-sys-color-outline: #747775;
  --md-sys-color-outline-variant: #c4c7c5;
  --md-sys-color-focus-ring: rgba(11, 87, 208, 0.22);

  /* M3 Elevation Shadows */
  --md-sys-elevation-1: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --md-sys-elevation-2: 0 4px 12px rgba(15, 23, 42, 0.07), 0 1px 3px rgba(15, 23, 42, 0.05);
  --md-sys-elevation-3: 0 12px 32px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);

  /* Custom Select Chevron SVG (Light Mode) */
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23444746' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");

  /* M3 Shape Scale */
  --md-sys-shape-xs: 6px;
  --md-sys-shape-sm: 8px;
  --md-sys-shape-md: 12px;
  --md-sys-shape-lg: 16px;
  --md-sys-shape-xl: 24px;
  --md-sys-shape-2xl: 28px;
  --md-sys-shape-full: 9999px;

  /* Mathematical Spatial Grid */
  --layout-max-width: 1200px;
  --layout-gutter: clamp(16px, 4vw, 32px);
  --header-height: 72px;

  /* Typography */
  --font-sans: "PercentSwift Sans", "PercentSwift Arabic", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --md-sys-color-primary: #a8c7fa;
    --md-sys-color-primary-hover: #d3e3fd;
    --md-sys-color-on-primary: #062e6f;
    --md-sys-color-primary-container: #0842a0;
    --md-sys-color-on-primary-container: #d3e3fd;

    --md-sys-color-secondary: #7fcfff;
    --md-sys-color-on-secondary: #003355;
    --md-sys-color-secondary-container: #004a77;
    --md-sys-color-on-secondary-container: #c2e7ff;

    --md-sys-color-tertiary: #6dd58c;
    --md-sys-color-on-tertiary: #0a3818;
    --md-sys-color-tertiary-container: #0f5223;
    --md-sys-color-on-tertiary-container: #c4eed0;

    --md-sys-color-error: #f2b8b5;
    --md-sys-color-on-error: #601410;
    --md-sys-color-error-container: #8c1d18;
    --md-sys-color-on-error-container: #f9dedc;

    --md-sys-color-surface: #0e131b;
    --md-sys-color-surface-dim: #090d14;
    --md-sys-color-surface-container-lowest: #0a0f17;
    --md-sys-color-surface-container-low: #151c28;
    --md-sys-color-surface-container: #1b2332;
    --md-sys-color-surface-container-high: #252f42;
    --md-sys-color-surface-container-highest: #303b52;

    --md-sys-color-on-surface: #e3e8f0;
    --md-sys-color-on-surface-variant: #c4c7c5;
    --md-sys-color-outline: #8e918f;
    --md-sys-color-outline-variant: #343e52;
    --md-sys-color-focus-ring: rgba(168, 199, 250, 0.26);

    --md-sys-elevation-1: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
    --md-sys-elevation-2: 0 6px 16px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.28);
    --md-sys-elevation-3: 0 14px 36px rgba(0, 0, 0, 0.55), 0 4px 10px rgba(0, 0, 0, 0.35);

    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23c4c7c5' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --md-sys-color-primary: #a8c7fa;
  --md-sys-color-primary-hover: #d3e3fd;
  --md-sys-color-on-primary: #062e6f;
  --md-sys-color-primary-container: #0842a0;
  --md-sys-color-on-primary-container: #d3e3fd;

  --md-sys-color-secondary: #7fcfff;
  --md-sys-color-on-secondary: #003355;
  --md-sys-color-secondary-container: #004a77;
  --md-sys-color-on-secondary-container: #c2e7ff;

  --md-sys-color-tertiary: #6dd58c;
  --md-sys-color-on-tertiary: #0a3818;
  --md-sys-color-tertiary-container: #0f5223;
  --md-sys-color-on-tertiary-container: #c4eed0;

  --md-sys-color-error: #f2b8b5;
  --md-sys-color-on-error: #601410;
  --md-sys-color-error-container: #8c1d18;
  --md-sys-color-on-error-container: #f9dedc;

  --md-sys-color-surface: #0e131b;
  --md-sys-color-surface-dim: #090d14;
  --md-sys-color-surface-container-lowest: #0a0f17;
  --md-sys-color-surface-container-low: #151c28;
  --md-sys-color-surface-container: #1b2332;
  --md-sys-color-surface-container-high: #252f42;
  --md-sys-color-surface-container-highest: #303b52;

  --md-sys-color-on-surface: #e3e8f0;
  --md-sys-color-on-surface-variant: #c4c7c5;
  --md-sys-color-outline: #8e918f;
  --md-sys-color-outline-variant: #343e52;
  --md-sys-color-focus-ring: rgba(168, 199, 250, 0.26);

  --md-sys-elevation-1: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
  --md-sys-elevation-2: 0 6px 16px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.28);
  --md-sys-elevation-3: 0 14px 36px rgba(0, 0, 0, 0.55), 0 4px 10px rgba(0, 0, 0, 0.35);

  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23c4c7c5' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
}

/* --------------------------------------------------------------------------
   2. Base Reset, Box Model & Global Typography
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
}

html[lang^="ar"] {
  line-height: 1.7;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  overflow-x: hidden;
}

main {
  flex: 1 0 auto;
  display: block;
}

img,
svg {
  max-width: 100%;
  display: block;
}

.ps-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--md-sys-color-primary);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

a:hover {
  color: var(--md-sys-color-primary-hover);
}

:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* Screen-reader utilities & Skip Links */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip,
.skip-link {
  position: fixed;
  top: 12px;
  inset-inline-start: 16px;
  z-index: 1000;
  padding: 10px 20px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  box-shadow: var(--md-sys-elevation-2);
  transform: translateY(-200%);
  transition: transform 150ms ease;
}

.skip:focus,
.skip-link:focus {
  transform: translateY(0);
  color: var(--md-sys-color-on-primary);
}

/* --------------------------------------------------------------------------
   3. Unified Container Geometry (.wrap)
   -------------------------------------------------------------------------- */
.wrap {
  width: min(100%, calc(var(--layout-max-width) + var(--layout-gutter) * 2));
  margin-inline: auto;
  padding-inline: var(--layout-gutter);
}

/* Prevent nested .wrap from double-padding */
.wrap .wrap {
  width: 100%;
  padding-inline: 0;
}

/* --------------------------------------------------------------------------
   4. Material Design 3 Top App Bar (.app-header & .app-bar)
   -------------------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 150;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--md-sys-color-surface) 90%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--header-height);
  padding-block: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--md-sys-color-on-surface);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  flex-shrink: 0;
}

.brand:hover {
  color: var(--md-sys-color-on-surface);
}

.brand .mark {
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-md);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  display: inline-grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 800;
  box-shadow: var(--md-sys-elevation-1);
  flex-shrink: 0;
}

/* Navigation Pills (.app-nav) */
.app-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  margin-inline-start: 12px;
}

.app-nav > a,
.tool-discovery > summary {
  height: 40px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-full);
  border: 1px solid transparent;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.tool-discovery > summary::-webkit-details-marker {
  display: none;
}

.app-nav > a:hover,
.tool-discovery > summary:hover {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}

.app-nav > a[aria-current="page"],
.tool-discovery[open] > summary {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.tool-discovery > summary .ps-icon:last-child {
  width: 18px;
  height: 18px;
  transition: transform 180ms ease;
}

.tool-discovery[open] > summary .ps-icon:last-child {
  transform: rotate(180deg);
}

/* Calculator Discovery Popover Menu */
.tool-discovery {
  position: relative;
}

.discovery-panel {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-start: 0;
  z-index: 220;
  width: min(640px, calc(100vw - 32px));
  max-height: min(75vh, 520px);
  overflow-y: auto;
  padding: 12px;
  border-radius: var(--md-sys-shape-xl);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-sys-elevation-3);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.discovery-panel a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: var(--md-sys-shape-md);
  color: var(--md-sys-color-on-surface);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
  text-decoration: none;
}

.discovery-panel a .ps-icon {
  color: var(--md-sys-color-primary);
}

.discovery-panel a:hover {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}

/* Header Right Preferences (.app-preferences, .language, #theme-toggle) */
.app-preferences {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-inline-start: auto;
}

.icon-button,
#theme-toggle {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: var(--md-sys-shape-full);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.region-trigger {
  display: none !important;
}

.icon-button:hover,
#theme-toggle:hover {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border-color: var(--md-sys-color-outline);
}

/* Direct 1-Click Theme Toggle Button (Guaranteed single icon, never stacks) */
#theme-toggle {
  position: relative;
  overflow: hidden;
}

#theme-toggle .theme-icon-moon,
#theme-toggle .theme-icon-sun {
  grid-area: 1 / 1;
  width: 20px;
  height: 20px;
  pointer-events: none;
}

#theme-toggle .theme-icon-moon {
  display: block;
}

#theme-toggle .theme-icon-sun {
  display: none;
}

[data-theme="dark"] #theme-toggle .theme-icon-moon {
  display: none;
}

[data-theme="dark"] #theme-toggle .theme-icon-sun {
  display: block;
  color: #fbbc04;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #theme-toggle .theme-icon-moon {
    display: none;
  }
  :root:not([data-theme="light"]) #theme-toggle .theme-icon-sun {
    display: block;
    color: #fbbc04;
  }
}

/* Language Selector Pill & Floating Listbox */
.language {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 40px;
}

/* Hide native select when enhanced by JS */
.language select.sr-only-select {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Fallback if JS hasn't enhanced yet: single arrow, clean pill */
.language:not([data-enhanced="true"]) {
  padding-inline: 8px 12px;
  border-radius: var(--md-sys-shape-full);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
  gap: 6px;
}

.language:not([data-enhanced="true"]) > .language-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: inline-grid;
  place-items: center;
}

.language:not([data-enhanced="true"]) > .language-icon .ps-icon {
  width: 16px;
  height: 16px;
}

.language:not([data-enhanced="true"]) > select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0 4px;
  min-height: 36px;
  cursor: pointer;
}

.language:not([data-enhanced="true"]) > .language-chevron {
  display: inline-grid;
  place-items: center;
  color: var(--md-sys-color-on-surface-variant);
  pointer-events: none;
}

.language:not([data-enhanced="true"]) > .language-chevron .ps-icon {
  width: 16px;
  height: 16px;
}

/* Enhanced M3 Language Trigger Pill */
.language-trigger {
  height: 40px;
  min-height: 40px;
  padding: 0 12px 0 6px;
  border-radius: var(--md-sys-shape-full);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

[dir="rtl"] .language-trigger {
  padding: 0 6px 0 12px;
}

.language-trigger:hover {
  background: var(--md-sys-color-surface-container-high);
  border-color: var(--md-sys-color-outline);
}

.language.is-open .language-trigger {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: var(--md-sys-color-secondary);
}

.language-trigger .language-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.language-trigger .language-icon .ps-icon {
  width: 16px;
  height: 16px;
}

.language-current {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.language-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.language-badge {
  display: none;
  padding: 0;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.language-trigger .language-chevron {
  display: inline-grid;
  place-items: center;
  color: var(--md-sys-color-on-surface-variant);
  transition: transform 180ms ease;
}

.language-trigger .language-chevron .ps-icon {
  width: 16px;
  height: 16px;
}

.language.is-open .language-trigger .language-chevron {
  transform: rotate(180deg);
}

/* M3 Language Floating Listbox Popover */
.language-popover {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 260;
  min-width: 236px;
  padding: 8px;
  border-radius: var(--md-sys-shape-lg);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-sys-elevation-3);
  display: grid;
  gap: 4px;
}

.language-option {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: var(--md-sys-shape-md);
  border: 0;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  text-align: start;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.language-option:hover {
  background: var(--md-sys-color-surface-container);
}

.language-option.is-selected {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 700;
}

.language-opt-badge {
  height: 24px;
  border-radius: var(--md-sys-shape-xs);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.6875rem;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}

.language-option.is-selected .language-opt-badge {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.language-opt-check {
  width: 18px;
  height: 18px;
  opacity: 0;
  color: var(--md-sys-color-primary);
}

.language-option.is-selected .language-opt-check {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   5. Breadcrumbs, Hero & Page Headers (.breadcrumbs, .hero, .page-head)
   -------------------------------------------------------------------------- */
.breadcrumbs {
  padding-top: 20px;
  padding-bottom: 4px;
  font-size: 0.84rem;
  color: var(--md-sys-color-on-surface-variant);
}

.breadcrumbs ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.breadcrumbs li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.breadcrumbs li + li::before {
  content: "/";
  color: var(--md-sys-color-outline);
}

.breadcrumbs a {
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  font-weight: 500;
}

.breadcrumbs a:hover {
  color: var(--md-sys-color-primary);
  text-decoration: underline;
}

.breadcrumbs [aria-current="page"] {
  color: var(--md-sys-color-on-surface);
  font-weight: 600;
}

/* Unified Hero & Page Head */
.hero,
.page-head {
  padding-top: 24px;
  padding-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.breadcrumbs + .page-head,
.breadcrumbs + .hero {
  padding-top: 12px;
}

.hero h1,
.page-head h1,
.article-head h1 {
  margin: 0;
  font-size: clamp(1.75rem, 2.8vw, 2.35rem);
  line-height: 1.18;
  font-weight: 750;
  letter-spacing: -0.025em;
  color: var(--md-sys-color-on-surface);
}

.lede {
  margin: 0;
  max-width: 72ch;
  font-size: clamp(1rem, 1.15vw, 1.125rem);
  line-height: 1.6;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 400;
}

.eyebrow {
  margin: 2px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.calculator-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
}

/* --------------------------------------------------------------------------
   6. Calculator Workspace & Material 3 Form Controls
   -------------------------------------------------------------------------- */
.workspace {
  width: 100%;
  margin-bottom: 32px;
}

.ad-rail:empty {
  display: none !important;
}

.calculator {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(350px, 0.88fr);
  gap: 24px;
  align-items: start;
  padding: 28px;
  border-radius: var(--md-sys-shape-2xl);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-sys-elevation-1);
}

/* Left Card (.entry) & Right Card (.results) */
.entry,
.results {
  padding: 24px;
  border-radius: var(--md-sys-shape-xl);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

#calc-form {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

#calc-form > label[for="mode"] {
  margin: 0 0 -10px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--md-sys-color-primary);
}

/* Material 3 Outlined Select Controls (#mode, #country, #currency, #preset, #category) */
select:not(.sr-only-select) {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 48px;
  padding: 10px 42px 10px 16px;
  border-radius: var(--md-sys-shape-md);
  border: 1px solid var(--md-sys-color-outline);
  background-color: var(--md-sys-color-surface-container-lowest);
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px 18px;
  color: var(--md-sys-color-on-surface);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

[dir="rtl"] select:not(.sr-only-select) {
  padding: 10px 16px 10px 42px;
  background-position: left 14px center;
}

select:not(.sr-only-select):hover {
  border-color: var(--md-sys-color-on-surface);
}

select:not(.sr-only-select):focus,
select:not(.sr-only-select):focus-visible {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px var(--md-sys-color-focus-ring);
}

#mode {
  min-height: 52px;
  font-size: 1rem;
  border-radius: 14px;
}

/* M3 Mode Segmented Shortcuts (if present) */
.mode-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-shortcuts button {
  height: 36px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--md-sys-shape-full);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.mode-shortcuts button:hover {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.mode-shortcuts button[aria-pressed="true"] {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: var(--md-sys-color-secondary);
}

/* M3 Field Grid & Outlined Input Containers (.field-grid, .field) */
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.field-grid > .field.full,
.field-grid > .field:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  min-height: 78px;
  padding: 12px 16px;
  border-radius: var(--md-sys-shape-lg);
  border: 1px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-container-lowest);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.field:hover {
  border-color: var(--md-sys-color-on-surface);
}

.field:focus-within {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px var(--md-sys-color-focus-ring);
}

.field:has([aria-invalid="true"]) {
  border-color: var(--md-sys-color-error);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-error) 20%, transparent);
}

.field > label {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--md-sys-color-on-surface-variant);
}

.field:focus-within > label {
  color: var(--md-sys-color-primary);
}

.field input {
  width: 100%;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  outline: none;
  box-shadow: none;
}

.field input::placeholder {
  color: color-mix(in srgb, var(--md-sys-color-on-surface-variant) 48%, transparent);
  font-weight: 500;
}

.field select:not(.sr-only-select) {
  height: 34px;
  min-height: 34px;
  padding: 0 32px 0 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-position: right 4px center;
  font-size: 1.05rem;
  font-weight: 650;
  box-shadow: none;
}

[dir="rtl"] .field select:not(.sr-only-select) {
  padding: 0 0 0 32px;
  background-position: left 4px center;
}

.input-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  width: 100%;
}

.input-shell input {
  flex: 1 1 auto;
  min-width: 0;
}

.sign-button {
  width: 34px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: var(--md-sys-shape-sm);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.sign-button:hover {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: var(--md-sys-color-secondary);
}

/* Error & Help Notices inside Calculator */
.error {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--md-sys-shape-md);
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.45;
}

.error:empty {
  display: none;
}

.help {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--md-sys-color-on-surface-variant);
}

.help:empty {
  display: none;
}

.notice {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--md-sys-shape-md);
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Results Display Card (.results, .answer-card, .output-details, .controls) */
.answer-card {
  padding: 24px;
  border-radius: 18px;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
}

#r-answer {
  display: block;
  margin: 0;
  font-size: clamp(2rem, 3.6vw, 2.85rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

#result-description {
  margin: 4px 0 0;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  opacity: 0.92;
}

#result-description:empty {
  display: none;
}

.output-details {
  display: grid;
  gap: 8px;
}

.output-details:empty {
  display: none;
}

.detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-radius: var(--md-sys-shape-md);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  font-size: 0.925rem;
}

.detail span {
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
}

.detail bdi {
  color: var(--md-sys-color-on-surface);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Primary Result Action Buttons (#copy, #share) */
.results .controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

#copy,
#share,
#copy-select {
  height: 44px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--md-sys-shape-full);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

#copy,
#copy-select {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: 1px solid transparent;
}

#copy:hover:not(:disabled),
#copy-select:hover {
  background: var(--md-sys-color-primary-hover);
}

#share {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border: 1px solid transparent;
}

#share:hover:not(:disabled) {
  background: var(--md-sys-color-surface-container-highest);
}

#copy:disabled,
#share:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#copy-fallback {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--md-sys-shape-md);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
}

#copy-value {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--md-sys-shape-sm);
  border: 1px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

/* --------------------------------------------------------------------------
   7. Calculator Accordions (.calculation-details & .regional)
   -------------------------------------------------------------------------- */
.calculation-details,
.regional {
  grid-column: 1 / -1;
  border-radius: var(--md-sys-shape-lg);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  overflow: hidden;
}

.calculation-details > summary,
.regional > summary {
  padding: 16px 20px;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--md-sys-color-on-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background-color 150ms ease;
}

.calculation-details > summary::-webkit-details-marker,
.regional > summary::-webkit-details-marker {
  display: none;
}

.calculation-details > summary:hover,
.regional > summary:hover {
  background: var(--md-sys-color-surface-container-low);
}

.calculation-details > summary::after,
.regional > summary::after {
  content: "+";
  width: 28px;
  height: 28px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  display: inline-grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1;
  flex-shrink: 0;
}

.calculation-details[open] > summary::after,
.regional[open] > summary::after {
  content: "−";
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.calculation-body,
.regional-body {
  padding: 20px 24px 24px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.calculation-body h3,
#tax-name {
  margin: 4px 0 0;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--md-sys-color-on-surface-variant);
}

.formula {
  padding: 14px 18px;
  border-radius: var(--md-sys-shape-md);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  overflow-x: auto;
}

#steps {
  margin: 0;
  padding-inline-start: 22px;
  display: grid;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.925rem;
  color: var(--md-sys-color-on-surface);
}

/* Balanced Option Action Buttons (#reset & #clear) */
.option-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

#reset,
#clear {
  height: 40px;
  min-height: 40px;
  padding: 0 20px;
  border-radius: var(--md-sys-shape-full);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

#reset {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border: 1px solid transparent;
}

#reset:hover {
  background: var(--md-sys-color-surface-container-highest);
}

#clear {
  background: transparent;
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline);
}

#clear:hover {
  background: var(--md-sys-color-surface-container);
  border-color: var(--md-sys-color-on-surface);
}

/* Regional Jurisdiction & Currency Preferences Grid */
.preferences {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.preferences > div,
#tax-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preferences label,
#tax-panel label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

#tax-panel {
  padding-top: 12px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

/* --------------------------------------------------------------------------
   8. Sections, Tool Cards, Explain Grid & Resource Strip
   -------------------------------------------------------------------------- */
.material-section,
.section {
  width: 100%;
  margin-top: 40px;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-heading h2,
.material-section > h2,
.section h2 {
  margin: 0 0 16px;
  font-size: clamp(1.3rem, 2vw, 1.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--md-sys-color-on-surface);
}

.section-heading h2 {
  margin-bottom: 0;
}

.section-heading a {
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-primary);
}

.section-heading a:hover {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

/* 12-Tool Calculator Grid (.tool-grid & .tool-card) */
.tool-grid {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.tool-card {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 14px;
  min-height: 68px;
  padding: 16px 20px;
  border-radius: var(--md-sys-shape-lg);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  transition: transform 150ms ease, border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

.tool-card:hover {
  transform: translateY(-2px);
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface-container-low);
  box-shadow: var(--md-sys-elevation-1);
  color: var(--md-sys-color-on-surface);
}

.tool-card .ps-icon:first-child {
  width: 22px;
  height: 22px;
  color: var(--md-sys-color-primary);
}

.tool-card .ps-icon:last-child {
  width: 18px;
  height: 18px;
  color: var(--md-sys-color-on-surface-variant);
  transition: transform 150ms ease, color 150ms ease;
}

.tool-card:hover .ps-icon:last-child {
  color: var(--md-sys-color-primary);
  transform: translateX(3px);
}

[dir="rtl"] .tool-card .ps-icon:last-child,
[dir="rtl"] .chip .ps-icon,
[dir="rtl"] .resource-strip > a .ps-icon {
  transform: scaleX(-1);
}

/* Explain Cards & Example Chips (.explain-grid, .explain-card, .chips) */
.explain-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 32px;
  align-items: stretch;
}

.material-section .explain-grid {
  margin-top: 20px;
}

.explain-card {
  padding: 28px;
  border-radius: var(--md-sys-shape-xl);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.explain-card h2,
.explain-card h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--md-sys-color-on-surface);
}

.explain-card p {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.6;
}

.chips {
  display: grid;
  gap: 10px;
}

.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: var(--md-sys-shape-md);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.chip:hover {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: var(--md-sys-color-secondary);
}

.chip .ps-icon {
  width: 18px;
  height: 18px;
  color: var(--md-sys-color-primary);
}

/* Resource Strip Banner (.resource-strip) */
.resource-strip {
  margin-top: 32px;
  padding: 24px 28px;
  border-radius: var(--md-sys-shape-xl);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
}

.resource-strip > .ps-icon {
  width: 32px;
  height: 32px;
  color: var(--md-sys-color-primary);
}

.resource-strip h2 {
  margin: 0 0 2px;
  font-size: 1.2rem;
  font-weight: 700;
}

.resource-strip p {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.88;
}

.resource-strip > a {
  height: 44px;
  padding: 0 22px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 0.925rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.resource-strip > a:hover {
  background: var(--md-sys-color-primary-hover);
  color: var(--md-sys-color-on-primary);
}

/* --------------------------------------------------------------------------
   9. Guides Hub, Categories & Blog Cards (.post-grid, .cat-grid, .blog-grid)
   -------------------------------------------------------------------------- */
.post-grid,
.blog-grid {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
}

.post-card,
.blog-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: var(--md-sys-shape-xl);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.post-card:hover,
.blog-card:hover {
  transform: translateY(-3px);
  border-color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-2);
}

.post-card .thumb {
  aspect-ratio: 16 / 9;
  padding: 16px;
  background: var(--md-sys-color-surface-container-low);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.post-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Mathematical Grid for .pc-body so .cat and .cat-date sit side-by-side */
.pc-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  align-items: center;
  column-gap: 8px;
  row-gap: 10px;
  padding: 22px 24px 24px;
  flex: 1 1 auto;
}

.pc-body > h3,
.pc-body > p {
  grid-column: 1 / -1;
}

.pc-body .cat,
.blog-card-cat {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  width: fit-content;
}

.pc-body .cat-date {
  font-size: 0.8rem;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-body h3,
.blog-card h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.pc-body h3 a,
.blog-card h3 a {
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
}

.pc-body h3 a:hover,
.blog-card h3 a:hover {
  color: var(--md-sys-color-primary);
}

.pc-body p,
.blog-card p {
  margin: 0;
  align-self: start;
  font-size: 0.925rem;
  line-height: 1.55;
  color: var(--md-sys-color-on-surface-variant);
}

/* Localized Blog Card internal padding */
.blog-card {
  padding: 24px;
  gap: 16px;
}

.blog-card > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.blog-card-meta {
  padding-top: 14px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8125rem;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 600;
}

.blog-card-meta span:last-child {
  color: var(--md-sys-color-primary);
}

/* Category Cards (.cat-grid & .cat-card) */
.cat-grid {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(216px, 1fr));
  gap: 14px;
}

.cat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  padding: 20px 22px;
  border-radius: var(--md-sys-shape-lg);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  text-decoration: none;
  color: var(--md-sys-color-on-surface);
  transition: transform 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.cat-card:hover {
  transform: translateY(-2px);
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface-container-low);
}

.cat-card strong {
  font-size: 1rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.cat-card span {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--md-sys-color-primary);
}

/* Guide Search & Filter Toolbars (.search-box, .blog-search, .blog-categories, .guide-list) */
.search-box {
  position: relative;
  max-width: 560px;
  margin-bottom: 24px;
}

.search-box svg {
  position: absolute;
  inset-inline-start: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--md-sys-color-on-surface-variant);
  pointer-events: none;
}

.search-box input,
.blog-search input {
  width: 100%;
  height: 52px;
  padding: 0 20px 0 48px;
  border-radius: var(--md-sys-shape-full);
  border: 1px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.blog-search input {
  padding-inline: 20px;
}

.search-box input:focus,
.blog-search input:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px var(--md-sys-color-focus-ring);
}

.blog-search {
  margin-top: 32px;
  margin-bottom: 16px;
  padding: 20px 24px;
  border-radius: var(--md-sys-shape-xl);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.blog-search > div:first-child {
  flex: 1 1 320px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.blog-search label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.blog-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.blog-categories button {
  height: 38px;
  min-height: 38px;
  padding: 0 16px;
  border-radius: var(--md-sys-shape-full);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface-variant);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.blog-categories button:hover {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}

.blog-categories button[aria-pressed="true"] {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
}

/* All Guides Directory List (.guide-list & .guide-group) */
.guide-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.guide-group {
  padding: 24px;
  border-radius: var(--md-sys-shape-xl);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.guide-group h3 {
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--md-sys-color-primary-container);
  font-size: 1.15rem;
  font-weight: 700;
}

.guide-group h3 a {
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
}

.guide-group h3 a:hover {
  color: var(--md-sys-color-primary);
}

.guide-group ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-group li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.guide-group li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.guide-group li a {
  flex: 1 1 auto;
  color: var(--md-sys-color-on-surface);
  font-size: 0.925rem;
  font-weight: 500;
  line-height: 1.45;
  text-decoration: none;
}

.guide-group li a:hover {
  color: var(--md-sys-color-primary);
  text-decoration: underline;
}

.guide-date {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   10. Article Layout, Prose, Tables, Figures & FAQ (.article-layout, .prose)
   -------------------------------------------------------------------------- */
.article-head {
  padding: 16px 0 28px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
}

.article-head .meta {
  margin: 4px 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
}

.article-head .meta span + span::before {
  content: "·";
  margin-inline-end: 14px;
  color: var(--md-sys-color-outline);
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 48px;
  align-items: start;
}

.article-layout > div:first-child {
  min-width: 0;
}

/* Short Answer Callout Box (.answer-box) */
.answer-box {
  padding: 22px 24px;
  margin-bottom: 28px;
  border-radius: var(--md-sys-shape-xl);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.answer-box .kicker {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  width: fit-content;
}

.answer-box p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
}

/* Mobile & Sidebar Table of Contents (.toc-mobile, .article-aside) */
.toc-mobile {
  display: none;
  margin-bottom: 24px;
  border-radius: var(--md-sys-shape-lg);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  overflow: hidden;
}

.toc-mobile > summary {
  padding: 14px 18px;
  font-weight: 700;
  font-size: 0.925rem;
  cursor: pointer;
}

.toc-mobile .toc {
  padding: 0 18px 16px;
}

.article-aside .sticky {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  display: grid;
  gap: 20px;
}

.aside-block {
  padding: 20px 22px;
  border-radius: var(--md-sys-shape-xl);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.aside-block h2 {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--md-sys-color-on-surface-variant);
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.toc a {
  display: block;
  padding: 6px 10px;
  border-radius: var(--md-sys-shape-sm);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
}

.toc a:hover {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-primary);
}

.calc-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--md-sys-shape-md);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.calc-link:hover {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.calc-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Editorial Prose & Documentation Cards (.prose, .doc, .content.prose) */
.doc.prose,
.content.prose {
  max-width: 860px;
  padding: 32px 36px;
  border-radius: var(--md-sys-shape-xl);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.prose {
  font-size: 1.03rem;
  line-height: 1.7;
  color: var(--md-sys-color-on-surface);
}

.prose > *:first-child {
  margin-top: 0;
}

.prose > *:last-child {
  margin-bottom: 0;
}

.prose h2 {
  margin: 36px 0 14px;
  font-size: clamp(1.3rem, 2vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.28;
  color: var(--md-sys-color-on-surface);
  scroll-margin-top: calc(var(--header-height) + 20px);
}

.prose h3 {
  margin: 28px 0 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 16px;
}

.prose li {
  margin-bottom: 6px;
}

.prose code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--md-sys-color-surface-container);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* Formula Blocks & Interactive Try Callouts (.formula-block, .try) */
.formula-block {
  margin: 22px 0;
  padding: 20px 24px;
  border-radius: var(--md-sys-shape-lg);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-inline-start: 4px solid var(--md-sys-color-primary);
}

.formula-block p:first-child {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.formula-block .where {
  margin: 8px 0 0;
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
}

.try {
  margin: 22px 0;
  padding: 16px 22px;
  border-radius: var(--md-sys-shape-lg);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.try p {
  margin: 0;
  font-size: 0.95rem;
}

.try a {
  height: 40px;
  padding: 0 18px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.try a:hover {
  background: var(--md-sys-color-primary-hover);
  color: var(--md-sys-color-on-primary);
}

.try a svg {
  width: 16px;
  height: 16px;
}

/* Article Figures (.fig) */
.fig {
  margin: 26px 0;
  padding: 20px;
  border-radius: var(--md-sys-shape-xl);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.fig-zoom {
  display: block;
  border-radius: var(--md-sys-shape-md);
  overflow: hidden;
  background: var(--md-sys-color-surface-container-low);
  padding: 12px;
}

.fig img {
  width: 100%;
  height: auto;
  margin-inline: auto;
}

.fig figcaption {
  margin-top: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--md-sys-color-on-surface-variant);
}

.fig-hint {
  opacity: 0.78;
}

/* Data Tables (.table-wrap & table) */
.table-wrap {
  margin: 22px 0;
  overflow-x: auto;
  border-radius: var(--md-sys-shape-lg);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-lowest);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
  text-align: start;
}

.prose > table {
  margin: 22px 0;
  border-radius: var(--md-sys-shape-lg);
  overflow: hidden;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-lowest);
}

.prose th,
.prose td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  text-align: start;
  vertical-align: top;
}

.prose th {
  background: var(--md-sys-color-surface-container-low);
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.prose tr:last-child td {
  border-bottom: 0;
}

/* FAQ Accordion (.faq) */
.faq {
  display: grid;
  gap: 12px;
  margin: 20px 0;
}

.faq details {
  border-radius: var(--md-sys-shape-lg);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  overflow: hidden;
}

.faq summary {
  padding: 16px 20px;
  font-weight: 650;
  font-size: 0.98rem;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  width: 26px;
  height: 26px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  display: inline-grid;
  place-items: center;
  font-weight: 600;
  flex-shrink: 0;
}

.faq details[open] summary::after {
  content: "−";
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.faq details > div {
  padding: 0 20px 18px;
  color: var(--md-sys-color-on-surface-variant);
}

.post-foot {
  margin-top: 32px;
  padding: 18px 22px;
  border-radius: var(--md-sys-shape-lg);
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
}

.post-foot p {
  margin: 0;
}

.section.related {
  padding-top: 32px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

/* --------------------------------------------------------------------------
   11. Unified Material 3 Footers (.app-footer & .site-footer) & Privacy Chip
   -------------------------------------------------------------------------- */
.app-footer,
.site-footer {
  margin-top: 64px;
  padding: 44px 0 36px;
  background: var(--md-sys-color-surface-container-low);
  border-top: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
}

.app-footer .wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-footer nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
}

.app-footer nav a {
  color: var(--md-sys-color-on-surface);
  font-weight: 600;
  text-decoration: none;
}

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

.app-footer details {
  border-radius: var(--md-sys-shape-md);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  padding: 12px 16px;
}

.app-footer details > summary {
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
}

.app-footer details > p,
.app-footer details > .consent {
  margin-top: 10px;
}

.consent {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.consent input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--md-sys-color-primary);
}

.lang-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.lang-links a {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.lang-links a:hover {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

/* Site Footer Grid (.site-footer) */
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr));
  gap: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.footer-brand p {
  margin: 12px 0 0;
  max-width: 32ch;
  line-height: 1.55;
}

.footer-grid h2 {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--md-sys-color-on-surface);
}

.footer-grid ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.footer-grid a {
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  font-size: 0.875rem;
}

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

.footer-bottom {
  padding-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  font-size: 0.8125rem;
}

/* Privacy Choices Button (.ps-privacy-settings) — Clean M3 Assist Chip */
button.ps-privacy-settings,
.intl button.ps-privacy-settings {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-height: 32px;
  width: fit-content;
  margin: 0;
  padding: 0 14px;
  border-radius: var(--md-sys-shape-sm);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

button.ps-privacy-settings:hover,
.intl button.ps-privacy-settings:hover {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: var(--md-sys-color-secondary);
}

/* --------------------------------------------------------------------------
   12. Responsive Breakpoints (Desktop, Tablet & Mobile)
   -------------------------------------------------------------------------- */
@media (max-width: 980px) {
  .calculator {
    grid-template-columns: 1fr;
    padding: 22px;
  }

  .tool-grid,
  .post-grid,
  .blog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .article-layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .toc-mobile {
    display: block;
  }

  .article-aside .sticky {
    position: static;
  }

  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-header {
    min-height: auto;
  }

  .app-bar {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand prefs"
      "nav   nav";
    align-items: center;
    column-gap: 12px;
    row-gap: 8px;
    min-height: auto;
    padding-block: 10px;
  }

  .brand {
    grid-area: brand;
    min-width: 0;
  }

  .app-preferences {
    grid-area: prefs;
    margin-inline-start: 0;
  }

  .app-nav {
    grid-area: nav;
    order: initial;
    margin-inline-start: 0;
    padding: 3px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3px;
    width: 100%;
    overflow: visible;
  }

  .tool-discovery {
    position: static;
    flex: 1 1 auto;
    display: flex;
  }

  .app-nav > a,
  .tool-discovery > summary {
    flex: 1 1 auto;
    justify-content: center;
    height: 34px;
    padding: 0 12px;
    font-size: 0.84rem;
    gap: 6px;
  }

  .discovery-panel {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline: var(--layout-gutter);
    width: auto;
    max-height: min(72vh, 480px);
    grid-template-columns: 1fr;
  }

  .explain-grid,
  .guide-list,
  .preferences {
    grid-template-columns: 1fr;
  }

  .resource-strip {
    grid-template-columns: 1fr;
    text-align: start;
  }

  .resource-strip > a {
    justify-self: start;
  }

  .doc.prose,
  .content.prose {
    padding: 24px 20px;
  }
}

@media (max-width: 600px) {
  .app-bar {
    padding-block: 8px;
    row-gap: 7px;
  }

  .brand {
    gap: 9px;
    font-size: 1.0625rem;
  }

  .brand .mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 1.05rem;
  }

  .app-preferences {
    gap: 6px;
  }

  .language {
    height: 36px;
  }

  .language-trigger {
    height: 36px;
    min-height: 36px;
    padding: 0 10px 0 5px;
    gap: 6px;
  }

  [dir="rtl"] .language-trigger {
    padding: 0 5px 0 10px;
  }

  .language-trigger .language-icon {
    width: 24px;
    height: 24px;
  }

  .language-trigger .language-icon .ps-icon,
  .language-trigger .language-chevron .ps-icon {
    width: 14px;
    height: 14px;
  }

  .language-name {
    display: none;
  }

  .language-badge {
    display: inline-block;
  }

  .icon-button,
  #theme-toggle {
    width: 36px;
    height: 36px;
    min-height: 36px;
  }

  #theme-toggle .theme-icon-moon,
  #theme-toggle .theme-icon-sun {
    width: 18px;
    height: 18px;
  }

  .app-nav > a,
  .tool-discovery > summary {
    height: 32px;
    padding: 0 9px;
    font-size: 0.8125rem;
    gap: 4px;
  }

  .tool-discovery > summary .ps-icon:first-child {
    width: 15px;
    height: 15px;
  }

  .tool-discovery > summary .ps-icon:last-child {
    width: 14px;
    height: 14px;
  }

  .hero,
  .page-head {
    padding-top: 16px;
    padding-bottom: 16px;
    gap: 8px;
  }

  .calculator {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    gap: 14px;
  }

  .entry,
  .results,
  .explain-card,
  .guide-group {
    padding: 18px;
  }

  .field-grid,
  .results .controls,
  .tool-grid,
  .post-grid,
  .blog-grid,
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .hero h1,
  .page-head h1,
  .article-head h1 {
    font-size: 1.65rem;
  }
}

@media (max-width: 380px) {
  .tool-discovery > summary .ps-icon:first-child {
    display: none;
  }

  .app-nav > a,
  .tool-discovery > summary {
    padding: 0 7px;
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
