/**
 * Utsav Planner - Main Stylesheet
 * Hand-written CSS with accessible design tokens (WCAG 2.2 AA, checked by tests).
 * Strict CSP compliant: no external fonts, no inline styles required.
 *
 * Design direction: Indian textile heritage, kept quiet. A Kalamkari chintz palette
 * (ivory cotton, indigo leaves, madder red, a touch of haldi) on calm editorial
 * typography; the Phulkari diamond border is the one ornament, used sparingly.
 */

:root {
  color-scheme: light;

  /* Colour tokens - light theme (contrast pairs are tested in test_stylesheet.py) */
  --color-bg: #f7f2e8;
  --color-surface: #fffcf6;
  --color-surface-subtle: #f1e9db;
  --color-text: #1e2a31;
  --color-text-muted: #55605f;
  --color-heading: #1d3443;
  --color-border: #8a7f70;
  --color-border-subtle: #e4d9c6;

  /* Madder red for actions, indigo for structure */
  --color-primary: #9a1f2b;
  --color-primary-hover: #7c1621;
  --color-primary-text: #fffcf6;
  --color-secondary: #1d3443;
  --color-secondary-hover: #2a4a5c;
  --color-secondary-text: #fffcf6;

  /* Saffron and haldi: decoration only, never text */
  --color-accent: #d9822b;
  --color-accent-soft: #e9b46a;

  /* Interaction and feedback */
  --color-focus: #23697f;
  --color-success: #2f6b3a;
  --color-warning: #8a4b0f;
  --color-error: #b3261e;
  --color-error-bg: #fbeceb;
  --color-error-border: #e7a49f;

  /* AI transparency */
  --color-ai-bg: #eef2f1;
  --color-ai-border: #9fb7bd;
  --color-ai-text: #1d3443;

  /* "Why" spotlight: the product's core idea */
  --color-why-bg: #fbf1de;
  --color-why-border: #d9822b;
  --color-why-text: #5c3a0c;

  /* Notices and badges */
  --color-notice-info-bg: #eef2f1;
  --color-notice-info-border: #9fb7bd;
  --color-notice-success-bg: #eef5ec;
  --color-notice-success-border: #9cc5a4;
  --color-badge-warning-bg: #fbf1de;
  --color-badge-warning-border: #e9b46a;

  /* Event banner: a Phulkari madder field */
  --color-hero-bg: #8c1c25;
  --color-hero-text: #fffaf0;
  --color-hero-muted: #f6d9c8;

  /* Budget bars */
  --color-track: #e4d9c6;
  --color-meter: #1d3443;

  /* Phulkari border: ivory, rose and haldi diamonds on madder, edged in gold */
  --motif-phulkari: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='20'%3E%3Crect width='64' height='20' fill='%238c1c25'/%3E%3Crect y='1' width='64' height='1' fill='%23e3a547'/%3E%3Crect y='18' width='64' height='1' fill='%23e3a547'/%3E%3Cpath d='M8 4l5 6-5 6-5-6z' fill='%23f3e5c8'/%3E%3Cpath d='M24 4l5 6-5 6-5-6z' fill='%23d8467a'/%3E%3Cpath d='M40 4l5 6-5 6-5-6z' fill='%23e3a547'/%3E%3Cpath d='M56 4l5 6-5 6-5-6z' fill='%23f3e5c8'/%3E%3C/svg%3E");
  --motif-height: 20px;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Type: a system serif for display, the system sans for reading */
  --font-family-base: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, sans-serif;
  --font-family-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", "P052", Georgia, serif;
  --font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.5rem;
  --font-size-5xl: 3.25rem;

  --line-height-tight: 1.2;
  --line-height-base: 1.55;
  --line-height-relaxed: 1.65;

  /* Shapes: softened woodblock corners, hairline borders, almost no shadow */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgb(30 42 49 / 0.06);
  --shadow-md: 0 6px 20px -8px rgb(140 28 37 / 0.18), 0 2px 6px -2px rgb(30 42 49 / 0.08);
  --layout-max-width: 120rem;
  --nav-height: 3.25rem;
  /* Height of the pinned header plus its Phulkari band; 0 where the header scrolls */
  --header-offset: 0px;
}

/* Dark theme: follows the device unless the header switch chose Light ("data-theme"),
   and applies whenever the switch chose Dark. Both blocks hold the same tokens (tested). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #15110f;
    --color-surface: #1e1915;
    --color-surface-subtle: #29221c;
    --color-text: #f2ebdf;
    --color-text-muted: #c4b8a6;
    --color-heading: #f0dfc2;
    --color-border: #8f8476;
    --color-border-subtle: #3a3029;

    --color-primary: #f08f8a;
    --color-primary-hover: #f6aca7;
    --color-primary-text: #15110f;
    --color-secondary: #a9c6d3;
    --color-secondary-hover: #c6dbe4;
    --color-secondary-text: #15110f;

    --color-accent: #d98a3d;
    --color-accent-soft: #c99a52;

    --color-focus: #7fc3d8;
    --color-success: #8fd19e;
    --color-warning: #f0b866;
    --color-error: #f39b94;
    --color-error-bg: #3a1714;
    --color-error-border: #8c3a33;

    --color-ai-bg: #1c2628;
    --color-ai-border: #4d7480;
    --color-ai-text: #bcd5dc;

    --color-why-bg: #2e2213;
    --color-why-border: #c98a3c;
    --color-why-text: #f3d9a6;

    --color-notice-info-bg: #1c2628;
    --color-notice-info-border: #4d7480;
    --color-notice-success-bg: #172a1c;
    --color-notice-success-border: #4f8f5e;
    --color-badge-warning-bg: #2e2213;
    --color-badge-warning-border: #c98a3c;

    --color-hero-bg: #6e1820;
    --color-hero-text: #fff6ea;
    --color-hero-muted: #f2d3c4;

    --color-track: #3a3029;
    --color-meter: #a9c6d3;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 6px 20px -8px rgb(0 0 0 / 0.6), 0 2px 6px -2px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --color-bg: #15110f;
  --color-surface: #1e1915;
  --color-surface-subtle: #29221c;
  --color-text: #f2ebdf;
  --color-text-muted: #c4b8a6;
  --color-heading: #f0dfc2;
  --color-border: #8f8476;
  --color-border-subtle: #3a3029;

  --color-primary: #f08f8a;
  --color-primary-hover: #f6aca7;
  --color-primary-text: #15110f;
  --color-secondary: #a9c6d3;
  --color-secondary-hover: #c6dbe4;
  --color-secondary-text: #15110f;

  --color-accent: #d98a3d;
  --color-accent-soft: #c99a52;

  --color-focus: #7fc3d8;
  --color-success: #8fd19e;
  --color-warning: #f0b866;
  --color-error: #f39b94;
  --color-error-bg: #3a1714;
  --color-error-border: #8c3a33;

  --color-ai-bg: #1c2628;
  --color-ai-border: #4d7480;
  --color-ai-text: #bcd5dc;

  --color-why-bg: #2e2213;
  --color-why-border: #c98a3c;
  --color-why-text: #f3d9a6;

  --color-notice-info-bg: #1c2628;
  --color-notice-info-border: #4d7480;
  --color-notice-success-bg: #172a1c;
  --color-notice-success-border: #4f8f5e;
  --color-badge-warning-bg: #2e2213;
  --color-badge-warning-border: #c98a3c;

  --color-hero-bg: #6e1820;
  --color-hero-text: #fff6ea;
  --color-hero-muted: #f2d3c4;

  --color-track: #3a3029;
  --color-meter: #a9c6d3;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 6px 20px -8px rgb(0 0 0 / 0.6), 0 2px 6px -2px rgb(0 0 0 / 0.4);
  color-scheme: dark;
}

/* ========================================================================
   Base
   ======================================================================== */

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

html {
  font-family: var(--font-family-base);
  font-size: 100%;
  line-height: var(--line-height-base);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-width: 320px;
  background-color: var(--color-bg);
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  /* clip, not hidden: hidden would make body a scroll container and break sticky */
  overflow-x: clip;
}

.skip-link {
  position: absolute;
  top: -9999px;
  left: var(--space-4);
  background: var(--color-surface);
  color: var(--color-primary);
  padding: var(--space-2) var(--space-4);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 1000;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-4);
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* Never remove focus outlines */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.container {
  width: 100%;
  max-width: var(--layout-max-width);
  margin-inline: auto;
  padding-inline: clamp(var(--space-6), 3vw, var(--space-12));
}

@media (max-width: 480px) {
  .container {
    padding-inline: var(--space-4);
  }
}

/* ========================================================================
   Typography
   ======================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-display);
  font-weight: 600;
  line-height: var(--line-height-tight);
  letter-spacing: -0.01em;
  color: var(--color-heading);
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

h1:first-child,
h2:first-child,
h3:first-child {
  margin-top: 0;
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-lg); }
h4 { font-size: var(--font-size-base); }

@media (min-width: 768px) {
  h1 { font-size: var(--font-size-5xl); }
  h2 { font-size: var(--font-size-3xl); }
  h3 { font-size: var(--font-size-xl); }
}

p {
  margin-top: 0;
  margin-bottom: var(--space-4);
}

a {
  color: var(--color-primary);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration-thickness: 2px;
}

/* Small capitals used for labels, kickers and table headings */
.kicker,
caption,
th[scope="col"],
.summary dt,
.month,
.section-nav a,
legend {
  letter-spacing: 0.08em;
}

.kicker {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.lede {
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
  max-width: 36rem;
  line-height: var(--line-height-relaxed);
  margin-bottom: 0;
}

/* ========================================================================
   Site header and footer
   ======================================================================== */

.site-header {
  position: relative;
  background-color: var(--color-surface);
  padding-block: var(--space-4);
  margin-bottom: var(--motif-height);
}

/* From tablet width the header stays pinned while the page scrolls; on phones it wraps
   to two rows, so it scrolls away to leave room for the content */
@media (min-width: 641px) {
  :root {
    --header-offset: 6.125rem;
    scroll-padding-top: calc(var(--header-offset) + var(--space-4));
  }

  .site-header {
    position: sticky;
    top: 0;
    z-index: 20;
  }
}

/* The Phulkari border: the one ornament on the page */
.site-header::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: calc(-1 * var(--motif-height));
  height: var(--motif-height);
  background: var(--motif-phulkari) repeat-x left center;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-family-display);
  font-size: var(--font-size-3xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-heading);
  text-decoration: none;
}

.site-brand:hover {
  color: var(--color-heading);
}

/* The mark keeps its madder red and marigold centre in both themes */
.brand-mark {
  width: 1.75rem;
  height: 1.75rem;
  color: #9a1f2b;
  flex-shrink: 0;
}

.brand-mark-centre {
  fill: #f2b33d;
}

@media (max-width: 480px) {
  .site-brand {
    font-size: var(--font-size-2xl);
  }
}

.brand-sub {
  font-weight: 400;
  color: var(--color-text-muted);
}

.site-nav-links {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: var(--space-2);
  align-items: center;
}

.site-nav-links a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}

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

/* Header controls: quiet pills with a hairline border, filled when current */
.site-nav-links .nav-plans {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-heading);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.site-nav-links .nav-plans:hover {
  background: var(--color-surface-subtle);
  border-color: var(--color-heading);
  color: var(--color-heading);
}

.site-nav-links .nav-plans[aria-current="page"] {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
  color: var(--color-secondary-text);
}

.nav-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

/* Icon only; the current choice is spoken through aria-label and the hidden label */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: transparent;
  color: var(--color-heading);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--color-surface-subtle);
  border-color: var(--color-heading);
}

.theme-toggle[hidden],
.theme-icon {
  display: none;
}

.theme-icon {
  width: 1.2rem;
  height: 1.2rem;
}

:root:not([data-theme-choice]) .theme-icon-auto,
[data-theme-choice="auto"] .theme-icon-auto,
[data-theme-choice="light"] .theme-icon-light,
[data-theme-choice="dark"] .theme-icon-dark {
  display: block;
}

.site-main {
  flex: 1 0 auto;
  padding-block: var(--space-10) var(--space-16);
}

.site-footer {
  border-top: 1px solid var(--color-border-subtle);
  background-color: var(--color-surface);
  padding-block: var(--space-8);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-top: auto;
}

.site-footer p {
  margin: 0;
}

.status-region {
  max-width: var(--layout-max-width);
  width: 100%;
  margin-inline: auto;
  padding-inline: var(--space-6);
}

/* ========================================================================
   Tables
   ======================================================================== */

table {
  width: 100%;
  border-collapse: collapse;
  margin-block: var(--space-4) var(--space-6);
  font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums;
}

caption {
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

th, td {
  padding: var(--space-3);
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border-subtle);
}

th[scope="col"] {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  padding-block: var(--space-2);
}

th[scope="row"] {
  font-weight: 600;
  color: var(--color-text);
}

tbody tr:hover {
  background: var(--color-surface);
}

/* Below 640px every table row becomes a card */
@media (max-width: 640px) {
  table,
  thead,
  tbody,
  tr {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  tr {
    margin-bottom: var(--space-3);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
  }

  td,
  th[scope="row"] {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: var(--space-1) 0;
    border-bottom: 1px dotted var(--color-border-subtle);
    background: transparent;
    text-align: right;
  }

  td:last-child,
  th[scope="row"]:last-child {
    border-bottom: none;
  }

  td::before {
    content: attr(data-label);
    font-weight: 700;
    flex-shrink: 0;
    margin-right: var(--space-3);
    text-align: left;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  th[scope="row"] {
    font-family: var(--font-family-display);
    font-size: var(--font-size-lg);
    color: var(--color-heading);
    text-align: left;
    display: block;
    padding-bottom: var(--space-2);
  }

  caption {
    display: block;
  }

  td form {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-2);
  }

  td form label {
    flex-basis: 100%;
    font-size: var(--font-size-sm);
  }

  td form input:not([type="hidden"]) {
    width: 8rem;
  }

  /* The status cell's own label names the vendor, so it replaces the column name */
  td[data-label="Status"]::before {
    content: none;
  }

  td[data-label="Status"] form {
    flex: 1;
  }

  td[data-label="Status"] form label {
    text-align: left;
    color: var(--color-text-muted);
  }

  /* Budget lines stay compact: name and toggle, then three amounts side by side */
  .budget-table tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "name name protect"
      "planned spent left";
    column-gap: var(--space-3);
    align-items: center;
  }

  .budget-table th[scope="row"] {
    grid-area: name;
    border-bottom: none;
  }

  .budget-table td {
    display: block;
    text-align: left;
    border-bottom: none;
    padding-top: var(--space-2);
  }

  .budget-table td::before {
    display: block;
    margin: 0;
  }

  .budget-table td[data-label="Planned"] { grid-area: planned; }
  .budget-table td[data-label="Spent"] { grid-area: spent; }
  .budget-table td[data-label="Left"] { grid-area: left; }

  .budget-table td[data-label="Protect"] {
    grid-area: protect;
    justify-self: end;
    padding-top: 0;
  }

  .budget-table td[data-label="Protect"]::before {
    content: none;
  }
}

/* ========================================================================
   Controls
   ======================================================================== */

input, select, textarea, button {
  font-family: inherit;
  font-size: var(--font-size-base);
  line-height: inherit;
}

/* Default button: an indigo outline, like a block-printed frame */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1.5px solid var(--color-secondary);
  background: transparent;
  color: var(--color-secondary);
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

button:hover, .button:hover {
  background: var(--color-surface-subtle);
}

.button-primary {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-primary-text);
  letter-spacing: 0.02em;
}

.button-primary:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.button-secondary {
  background-color: var(--color-secondary);
  color: var(--color-secondary-text);
}

.button-secondary:hover {
  background-color: var(--color-secondary-hover);
}

/* On/off controls (protect, done): small, quiet until pressed */
.toggle {
  min-height: 2.25rem;
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-sm);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.toggle[aria-pressed="true"] {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
  color: var(--color-secondary-text);
}

.toggle[aria-pressed="true"]:hover {
  background: var(--color-secondary-hover);
}

.field {
  margin-bottom: var(--space-5);
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

input:not([type="checkbox"], [type="radio"]),
select,
textarea {
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}

input:not([type="checkbox"], [type="radio"]):focus,
select:focus,
textarea:focus {
  border-color: var(--color-focus);
}

.field input:not([type="checkbox"], [type="radio"]),
.field select,
.field textarea {
  width: 100%;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--color-primary);
}

.field-invalid input,
.field-invalid select,
.field-invalid textarea {
  border-color: var(--color-error);
  background: var(--color-error-bg);
}

.field-hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  margin-bottom: var(--space-1);
}

.field-error {
  font-size: var(--font-size-sm);
  color: var(--color-error);
  font-weight: 600;
  margin-top: var(--space-1);
  margin-bottom: 0;
}

.choice {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-block: var(--space-1);
  min-height: 24px;
}

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-5);
}

legend {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

/* ========================================================================
   Notices, badges and the "why"
   ======================================================================== */

.notice {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-border);
  margin-block: var(--space-4);
  font-weight: 500;
  background: var(--color-surface);
}

.notice p:last-child {
  margin-bottom: 0;
}

.notice-info {
  background: var(--color-notice-info-bg);
  border-left-color: var(--color-secondary);
}

.notice-success {
  background: var(--color-notice-success-bg);
  border-left-color: var(--color-success);
}

.notice-error {
  background: var(--color-error-bg);
  border-left-color: var(--color-error);
}

/* The new-plan form's error summary: each problem links to its field */
.error-summary ul {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
}

.error-summary li + li {
  margin-top: var(--space-1);
}

.error-summary a {
  color: var(--color-primary);
}

.error-page {
  max-width: 40rem;
  padding-block: var(--space-12);
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  list-style: none;
  margin: var(--space-6) 0 0;
  padding: 0;
}

.badge {
  display: inline-block;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-subtle);
  background: transparent;
  color: var(--color-text-muted);
  vertical-align: middle;
  white-space: nowrap;
}

.badge-error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: var(--color-error-border);
}

.badge-warning {
  background: var(--color-badge-warning-bg);
  color: var(--color-warning);
  border-color: var(--color-badge-warning-border);
}

.badge-ai {
  background: var(--color-ai-bg);
  color: var(--color-ai-text);
  border-color: var(--color-ai-border);
}

.why {
  background: var(--color-why-bg);
  border-left: 2px solid var(--color-why-border);
  color: var(--color-why-text);
  padding: var(--space-2) var(--space-3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--font-size-sm);
  font-family: var(--font-family-base);
  font-weight: 400;
  margin-top: var(--space-2);
  margin-bottom: var(--space-2);
}

/* ========================================================================
   AI labels and the "How this was generated" panel
   ======================================================================== */

.label-ai {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-ai-bg);
  color: var(--color-ai-text);
  border: 1px solid var(--color-ai-border);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.label-not-ai {
  font-style: italic;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.ai-note {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-style: italic;
  padding: var(--space-2) 0;
  border-top: 1px dashed var(--color-border-subtle);
  margin-top: var(--space-2);
}

.ai-note:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
}

/* The record of an AI answer: a quiet link under the AI note, a panel once opened */
.ai-panel {
  margin-top: var(--space-1);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
}

.ai-panel summary {
  display: inline-block;
  padding: var(--space-1) 0;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text-muted);
  list-style: revert;
  text-decoration: underline;
  text-decoration-color: var(--color-border-subtle);
  text-underline-offset: 0.2em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.ai-panel summary:hover {
  color: var(--color-text);
  text-decoration-color: currentColor;
}

.ai-panel[open] {
  margin-top: var(--space-3);
  padding: 0 var(--space-4) var(--space-4);
  border-color: var(--color-ai-border);
  background: var(--color-ai-bg);
}

.ai-panel[open] summary {
  display: block;
  padding: var(--space-3) 0;
  color: var(--color-ai-text);
  text-decoration: none;
  border-bottom: 1px solid var(--color-ai-border);
  margin-bottom: var(--space-3);
}

.ai-panel dl {
  margin: 0;
}

.ai-panel dl > div {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-1) 0;
  font-size: var(--font-size-sm);
}

.ai-panel dt {
  font-weight: 600;
  min-width: 110px;
  flex-shrink: 0;
}

.ai-panel dd {
  margin: 0;
  min-width: 0;
}

.ai-panel pre {
  overflow-x: auto;
  font-size: var(--font-size-xs);
  font-family: var(--font-family-mono);
  background: var(--color-surface);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  max-height: 300px;
  overflow-y: auto;
}

/* ========================================================================
   Landing page
   ======================================================================== */

/* Top of the home page: the pitch (70%) beside a panel of celebration pictures (30%) */
/* Home page: the pitch, the photos, then the form. On wide screens the photos are pinned
   to the window's right edge and keep cycling while the page scrolls; the full-width
   header and footer pass over them, and the pitch and form scroll on the left. */
.landing {
  display: grid;
  gap: var(--space-8);
}

@media (min-width: 1000px) {
  .page-split {
    --reel-width: clamp(20rem, 32vw, 48rem);
  }

  .page-split .site-main,
  .page-split .status-region {
    width: auto;
    margin-right: var(--reel-width);
  }

  .page-split .site-footer {
    position: relative;
    z-index: 2;
  }

  .page-split .site-header .container,
  .page-split .site-main > .container,
  .page-split .site-footer .container,
  .page-split .status-region {
    max-width: none;
  }

  .landing {
    gap: var(--space-12);
  }

  .page-split .reel {
    position: fixed;
    z-index: 1;
    inset: var(--header-offset) 0 0 auto;
    width: var(--reel-width);
  }
}

.landing-hero h1 {
  margin-bottom: var(--space-4);
}

.landing-hero .lede {
  max-width: 36rem;
}

/* How it works, as four short steps under the headline */
.how-compact {
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border-subtle);
}

.how-compact h2 {
  font-family: var(--font-family-base);
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

@media (min-width: 700px) {
  .how-compact .how {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-5) var(--space-8);
  }
}

@media (min-width: 1300px) {
  .how-compact .how {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Celebration pictures: a slow upward reel on wide screens, a sideways strip on narrow ones.
   reel.js starts it (and its pause button); without it, or with reduced motion, it is still. */
.reel {
  position: relative;
  min-width: 0;
}

.reel-window {
  height: 15rem;
  overflow: hidden;
  border-radius: var(--radius-lg);
  mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
}

.reel-track {
  display: flex;
  width: max-content;
  list-style: none;
  margin: 0;
  padding: 0;
}

.reel-slide {
  width: 15rem;
  height: 15rem;
  padding-right: var(--space-3);
}

.reel-frame {
  position: relative;
  height: 100%;
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--reel-tone, var(--color-hero-bg));
}

/* Every photo has the Phulkari band along its foot; the tone shows while it loads */
.reel-frame::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: auto 0 0;
  height: var(--motif-height);
  background: var(--motif-phulkari) repeat-x left center;
  opacity: 0.85;
}

.reel-tone-1 { --reel-tone: #8c1c25; }
.reel-tone-2 { --reel-tone: #1d3443; }
.reel-tone-3 { --reel-tone: #8a5a14; }

.reel-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reel.is-running .reel-track {
  animation: reel-sideways 27s linear infinite;
}

.reel.is-paused .reel-track,
.reel:hover .reel-track,
.reel:focus-within .reel-track {
  animation-play-state: paused;
}

@keyframes reel-sideways {
  to { transform: translateX(-50%); }
}

@keyframes reel-up {
  to { transform: translateY(-50%); }
}

/* The pause control (WCAG 2.2.2) shows only when focused from the keyboard; pointing at
   or touching the panel pauses it too. Its name is screen-reader text. */
.reel-toggle {
  position: absolute;
  z-index: 2;
  right: var(--space-2);
  bottom: calc(var(--motif-height) + var(--space-5));
  display: grid;
  place-items: center;
  width: 2rem;
  min-height: 2rem;
  padding: 0;
  border-radius: 50%;
  background: rgb(20 12 10 / 0.55);
  color: #fff6ea;
  border: 1px solid rgb(255 246 234 / 0.5);
  opacity: 0.75;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.reel-toggle:not(:focus-visible) {
  opacity: 0;
  pointer-events: none;
}

.reel-toggle:focus-visible {
  opacity: 1;
  background: rgb(20 12 10 / 0.8);
}

.reel-toggle svg {
  fill: currentColor;
}

.reel-icon-play,
.reel.is-paused .reel-icon-pause {
  display: none;
}

.reel.is-paused .reel-icon-play {
  display: block;
}

.reel-toggle[hidden] {
  display: none;
}

@media (min-width: 1000px) {
  /* The pinned column's window fills it, fading in and out at the top and bottom */
  .reel-window {
    position: absolute;
    inset: 0;
    height: auto;
    border-radius: 0;
    mask-image: linear-gradient(transparent, #000 6%, #000 94%, transparent);
  }

  .reel-frame {
    border-radius: 0;
  }

  .reel-track {
    flex-direction: column;
    width: 100%;
  }

  .reel-slide {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    padding: 0 0 var(--space-3);
  }

  .reel.is-running .reel-track {
    animation-name: reel-up;
    animation-duration: 30s;
  }
}

/* The new-plan form, in numbered steps */
.create-form {
  display: grid;
  gap: var(--space-2);
  background: var(--color-surface);
  padding: var(--space-8);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 480px) {
  .create-form {
    padding: var(--space-5);
  }
}

.form-step {
  margin: 0;
  padding: 0 0 var(--space-6);
  border-bottom: 1px solid var(--color-border-subtle);
}

.form-step + .form-step {
  padding-top: var(--space-4);
}

@media (min-width: 1200px) {
  .create-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: var(--space-12);
    padding: var(--space-10);
  }

  .create-form > :first-of-type,
  .form-submit {
    grid-column: 1 / -1;
  }

  .create-form > .form-step + .form-step {
    padding-top: var(--space-4);
  }

  .create-form > .form-step:not(:first-of-type) {
    border-bottom: none;
  }
}

.form-step > legend {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  float: left;
  width: 100%;
  margin-bottom: var(--space-5);
  font-family: var(--font-family-display);
  font-size: var(--font-size-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--color-heading);
}

.form-step > legend + * {
  clear: left;
}

.step-number {
  display: inline-grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  border: 1.5px solid var(--color-accent);
  border-radius: 50%;
  font-family: var(--font-family-base);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-heading);
}

.legend-note {
  font-family: var(--font-family-base);
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--color-text-muted);
}

/* Event type: three selectable cards */
.type-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: var(--space-3);
}

.type-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--space-3);
  align-items: start;
  align-content: start;
  padding: var(--space-4);
  background: var(--color-bg);
  border: 1.5px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.type-card input {
  position: relative;
  z-index: 1;
  margin-top: 0.15rem;
}

.type-card label {
  font-weight: 700;
  color: var(--color-heading);
  cursor: pointer;
}

/* The label covers the card, so the whole card selects the type */
.type-card label::after {
  content: "";
  position: absolute;
  inset: 0;
}

.type-card-hint {
  grid-column: 2;
  margin: var(--space-1) 0 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.type-card:hover {
  border-color: var(--color-border);
}

.type-card:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: inset 0 0 0 1px var(--color-primary);
}

.type-card:has(input:focus-visible) {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* A sample appears for the chosen type only */
.samples {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
}

.sample {
  display: none;
  font-size: var(--font-size-sm);
}

.create-form:has(#type-wedding:checked) .sample[data-event-type="wedding"],
.create-form:has(#type-birthday:checked) .sample[data-event-type="birthday"],
.create-form:has(#type-community:checked) .sample[data-event-type="community"] {
  display: block;
}

/* In side-by-side rows the inputs line up: hints and errors sit under the input
   (they stay linked to it through aria-describedby) */
.field-row .field {
  display: flex;
  flex-direction: column;
}

.field-row .field-hint {
  order: 1;
  margin-top: var(--space-1);
  margin-bottom: 0;
}

.field-row .field-error {
  order: 2;
}

/* Number fields without the spinner arrows; typing is quicker for rupees and guests */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  column-gap: var(--space-5);
}

.input-adorned {
  position: relative;
}

.adornment {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.input-adorned input {
  padding-left: var(--space-8) !important;
}

/* Functions as chips */
.functions {
  margin: 0;
}

.functions > legend {
  font-weight: 600;
  font-size: var(--font-size-base);
  text-transform: none;
  letter-spacing: 0;
  color: var(--color-text);
}

.sub-events {
  border: none;
  padding: var(--space-2) 0 0;
  margin: 0;
}

.sub-events legend {
  font-size: var(--font-size-xs);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.5rem;
  padding: var(--space-1) var(--space-4) var(--space-1) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg);
}

.chip input {
  position: relative;
  z-index: 1;
  width: 1rem;
  height: 1rem;
}

.chip label {
  font-size: var(--font-size-sm);
  cursor: pointer;
}

.chip label::after {
  content: "";
  position: absolute;
  inset: 0;
}

.chip:has(input:checked) {
  border-color: var(--color-secondary);
  background: var(--color-surface-subtle);
}

.chip:has(input:focus-visible) {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.create-form:not(:has([name="event_type"]:checked)) .sub-events,
.create-form:has([name="event_type"]:checked) .sub-events,
.create-form:has([name="event_type"]:checked) .sub-events-hint {
  display: none;
}

.create-form:has(#type-wedding:checked) .sub-events[data-event-type="wedding"],
.create-form:has(#type-birthday:checked) .sub-events[data-event-type="birthday"],
.create-form:has(#type-community:checked) .sub-events[data-event-type="community"] {
  display: block;
}

.form-submit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  padding-top: var(--space-4);
}

.form-submit .button-primary {
  min-height: 3rem;
  padding-inline: var(--space-8);
  font-size: var(--font-size-lg);
}

.form-submit .field-hint {
  margin: 0;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.panel h2 {
  font-size: var(--font-size-xl);
}

.panel p:last-child {
  margin-bottom: 0;
}

/* How it works: a real sequence, so it is numbered */
.how {
  list-style: none;
  counter-reset: how;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
}

.how li {
  counter-increment: how;
  position: relative;
  padding-left: var(--space-10);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.how li::before {
  content: counter(how);
  position: absolute;
  left: 0;
  top: -0.1rem;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1.5px solid var(--color-accent);
  border-radius: 50%;
  font-weight: 700;
  color: var(--color-heading);
}

.how strong {
  display: block;
  color: var(--color-text);
  font-size: var(--font-size-base);
}

/* ========================================================================
   My plans page
   ======================================================================== */

.plans-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.plans-header h1 {
  margin-bottom: 0;
}

.add-plan {
  min-height: 3rem;
  padding-inline: var(--space-6);
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: var(--space-5);
  list-style: none;
  margin: 0;
  padding: 0;
}

.plan-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-6) var(--space-6) calc(var(--space-5) + var(--motif-height));
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.plan-tile::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: var(--motif-height);
  background: var(--motif-phulkari) repeat-x left center;
}

.plan-tile:hover,
.plan-tile:focus-within {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-border);
}

.plan-tile h2 {
  margin: 0;
  font-size: var(--font-size-2xl);
}

.plan-tile h2 a {
  color: var(--color-heading);
  text-decoration: none;
}

/* The whole tile opens the plan; the title stays the link's name */
.plan-tile h2 a::before {
  content: "";
  position: absolute;
  inset: 0;
}

.plan-tile-type,
.plan-tile-days {
  margin: 0;
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.plan-tile-meta {
  margin: 0 0 var(--space-4);
  color: var(--color-text-muted);
}

.plan-tile-days {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
}

.plan-tile-days strong {
  font-family: var(--font-family-display);
  font-size: var(--font-size-2xl);
  letter-spacing: 0;
  color: var(--color-primary);
  margin-right: var(--space-1);
}

.empty-plans {
  max-width: 36rem;
}

/* ========================================================================
   Dashboard: event banner and section navigation
   ======================================================================== */

.event-header {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-6);
  background: var(--color-hero-bg);
  color: var(--color-hero-text);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-8) calc(var(--space-8) + var(--motif-height));
  margin-bottom: var(--space-6);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.event-header::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: var(--motif-height);
  background: var(--motif-phulkari) repeat-x left center;
}

.event-header h1,
.event-header .kicker {
  color: var(--color-hero-text);
}

.event-header .kicker {
  opacity: 1;
  color: var(--color-hero-muted);
}

.event-header h1 {
  margin-bottom: var(--space-2);
}

.event-header :focus-visible {
  outline-color: var(--color-hero-text);
}

.event-header-main {
  flex: 1 1 22rem;
  min-width: 0;
}

.event-meta {
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-2);
}

.event-header .preferences {
  color: var(--color-hero-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
  max-width: 40rem;
  margin-bottom: 0;
}

.event-header-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-3);
  text-align: right;
}

.countdown {
  margin: 0;
  color: var(--color-hero-muted);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.countdown-number {
  display: block;
  font-family: var(--font-family-display);
  font-size: var(--font-size-4xl);
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  color: var(--color-hero-text);
}

.event-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
}

.banner-button {
  min-height: 2.5rem;
  line-height: 1.25;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-hero-muted);
  color: var(--color-hero-text);
  background: transparent;
  font-size: var(--font-size-sm);
}

.banner-button:hover {
  color: var(--color-hero-text);
  background: rgb(255 255 255 / 0.12);
}

@media (max-width: 640px) {
  .event-header {
    padding: var(--space-6) var(--space-5) calc(var(--space-6) + var(--motif-height));
  }

  .event-header-side {
    align-items: flex-start;
    text-align: left;
  }

  .event-actions {
    justify-content: flex-start;
  }
}

.preferences {
  font-style: italic;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* Section menu: a sticky bar on narrow screens, a side rail on wide ones */
.section-nav {
  position: sticky;
  top: var(--header-offset);
  z-index: 10;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border-subtle);
  margin-bottom: var(--space-8);
}

.section-nav ul {
  display: flex;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.section-nav a {
  display: block;
  padding: var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--color-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.section-nav a:hover,
.section-nav a[aria-current] {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

@media (max-width: 480px) {
  .section-nav a {
    padding-inline: var(--space-2);
  }
}

@media (min-width: 1100px) {
  .dashboard-layout {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: var(--space-12);
    align-items: start;
  }

  /* A full-height rail: the line fills up to the section in view (sections.js) */
  .section-nav {
    top: calc(var(--header-offset) + var(--space-6));
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-offset) - var(--space-12));
    height: calc(100dvh - var(--header-offset) - var(--space-12));
    min-height: 24rem;
    border-bottom: none;
    background: transparent;
    margin: 0;
  }

  .section-nav ul {
    flex: 1;
    flex-direction: column;
    gap: 0;
    overflow: visible;
    border-left: 1px solid var(--color-border-subtle);
  }

  .section-nav li {
    display: flex;
    flex: 1;
  }

  .section-nav a {
    flex: 1;
    padding: var(--space-2) var(--space-4);
    margin-left: -1px;
    border-bottom: none;
    border-left: 2px solid transparent;
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    transition: color 0.15s ease, border-color 0.3s ease;
  }

  .section-nav a:hover {
    border-left-color: var(--color-border);
  }

  .section-nav a.is-past {
    border-left-color: var(--color-primary);
    color: var(--color-text);
  }

  .section-nav a[aria-current] {
    border-left-color: var(--color-primary);
    color: var(--color-primary);
  }

  .site-main section[id] {
    scroll-margin-top: var(--space-6);
  }
}

.dashboard-main {
  min-width: 0;
}

/* Sections land below the sticky navigation */
.site-main section[id] {
  scroll-margin-top: var(--nav-height);
}

/* Each plan section reads as a chapter */
#plan-area > section,
#change-manager,
#history {
  padding-top: var(--space-8);
  margin-top: var(--space-8);
  border-top: 1px solid var(--color-border-subtle);
}

#plan-area > section:first-of-type {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

/* What to do next: the few things that matter now, above the detail */
.next-list {
  margin: var(--space-3) 0 var(--space-2);
  padding: var(--space-4) var(--space-5) var(--space-4) var(--space-10);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-md);
  max-width: 48rem;
}

.next-list li + li {
  margin-top: var(--space-2);
}

.next-what {
  font-weight: 600;
}

.next-when {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums;
}

.next-links {
  font-size: var(--font-size-sm);
  margin: 0;
}

.estimate-note {
  margin: calc(-1 * var(--space-2)) 0 var(--space-4);
}

/* Questions to ask a vendor, folded under its name */
.vendor-questions {
  margin-top: var(--space-2);
  font-family: var(--font-family-base);
  font-size: var(--font-size-sm);
  font-weight: 400;
}

.vendor-questions summary {
  cursor: pointer;
  color: var(--color-primary);
  font-weight: 600;
}

.vendor-questions ul {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
}

.vendor-questions li + li {
  margin-top: var(--space-1);
}

/* ========================================================================
   Budget
   ======================================================================== */

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
}

.summary > div {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-top: 2px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
}

.summary dt {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-weight: 700;
}

.summary dd {
  font-family: var(--font-family-display);
  font-size: var(--font-size-3xl);
  font-weight: 600;
  margin: var(--space-1) 0 0;
  color: var(--color-heading);
  font-variant-numeric: lining-nums tabular-nums;
}

@media (max-width: 480px) {
  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary dd {
    font-size: var(--font-size-2xl);
  }
}

.budget-meter {
  margin-bottom: var(--space-6);
}

.budget-meter p {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

/* Planned-versus-spent bars (decorative: the amounts are always in the text) */
.meter {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  max-width: 14rem;
  height: 4px;
  margin-top: var(--space-2);
  border: none;
  border-radius: 2px;
  background: var(--color-track);
  overflow: hidden;
}

.budget-meter .meter {
  max-width: none;
  height: 6px;
}

.meter::-webkit-progress-bar {
  background: var(--color-track);
  border-radius: 2px;
}

.meter::-webkit-progress-value {
  background: var(--color-meter);
  border-radius: 2px;
}

.meter::-moz-progress-bar {
  background: var(--color-meter);
  border-radius: 2px;
}

.meter-over::-webkit-progress-value {
  background: var(--color-error);
}

.meter-over::-moz-progress-bar {
  background: var(--color-error);
}

/* ========================================================================
   Ideas
   ======================================================================== */

.ideas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: var(--space-4);
  list-style: none;
  padding: 0;
  margin: var(--space-4) 0 0;
}

.ideas li {
  display: flex;
  flex-direction: column;
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
}

/* AI-curated ideas carry a Kantha running stitch inside the frame */
.ideas-ai li {
  outline: 1px dashed var(--color-accent);
  outline-offset: -6px;
}

.ideas h3 {
  margin: 0 0 var(--space-2);
}

.ideas li p:not(.why) {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.ideas li .why {
  margin-top: auto;
  margin-bottom: 0;
}

.retry-ai {
  margin-top: var(--space-4);
}

/* ========================================================================
   Timeline: months along a stitched thread
   ======================================================================== */

.month {
  font-family: var(--font-family-base);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: var(--space-6) 0 var(--space-2);
}

.tasks {
  list-style: none;
  margin: 0 0 0 var(--space-2);
  padding: 0;
  border-left: 1.5px dashed var(--color-border);
}

.tasks li {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) 0 var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--color-border-subtle);
}

.tasks li:last-child {
  border-bottom: none;
}

/* Diamond markers, filled with haldi when the task is done */
.tasks li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 1.35rem;
  width: 10px;
  height: 10px;
  background: var(--color-bg);
  border: 1.5px solid var(--color-secondary);
  transform: rotate(45deg);
}

.tasks li.done::before {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.tasks li.done .task-title {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.tasks li .why {
  order: 1;
  flex-basis: 100%;
  margin: 0;
}

.tasks form {
  margin-left: auto;
}

.tasks form + form {
  margin-left: 0;
}

/* Remove, on items the user added: quieter than the main actions */
.button-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-muted);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  padding-inline: var(--space-2);
}

.button-quiet:hover {
  background: transparent;
  color: var(--color-primary);
}

/* Adding your own task or vendor */
#add-task-heading,
#add-vendor-heading {
  margin-top: var(--space-8);
}

.own-remove {
  display: inline;
}

.own-remove .button-quiet {
  min-height: 1.5rem;
  padding-block: 0;
  font-family: var(--font-family-base);
  font-size: var(--font-size-sm);
}

.own-item-form {
  max-width: 40rem;
  margin-top: var(--space-3);
}

.task-title {
  font-weight: 600;
  flex: 1 1 14rem;
}

.task-due {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.calendar-export {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

/* Controls inside tables are compact so the numbers stay the focus */
td form {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

td form label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

td button,
td select,
td input:not([type="hidden"]) {
  min-height: 2.25rem;
  font-size: var(--font-size-sm);
}

td button {
  padding: var(--space-1) var(--space-3);
  border-width: 1px;
}

td input:not([type="hidden"]) {
  width: 7rem;
}

td select {
  padding-block: var(--space-1);
}

#add-expense-form {
  max-width: 36rem;
}

/* Vendor status: the label sits above the control, so every row lines up */
td[data-label="Status"] form label {
  flex-basis: 100%;
}

/* ========================================================================
   Change Manager
   ======================================================================== */

#change-manager > form,
.change-form-toggle,
.change-result {
  max-width: 48rem;
}

.change-result {
  margin-top: var(--space-4);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
}

.change-proposal {
  border-left: 3px solid var(--color-primary);
}

.change-clarification {
  border-left: 3px solid var(--color-warning);
}

.change-off_topic,
.change-invalid {
  border-left: 3px solid var(--color-error);
}

.change-unavailable,
.change-nothing_to_change {
  border-left: 3px solid var(--color-text-muted);
}

.proposal {
  padding: var(--space-4) 0 0;
  margin-top: var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
}

.proposal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
}

.field-changes {
  list-style: none;
  padding: 0;
  margin: var(--space-3) 0;
}

.field-changes li {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border-subtle);
  font-size: var(--font-size-sm);
}

.field-changes li:last-child {
  border-bottom: none;
}

.change-form {
  margin-top: var(--space-4);
}

.change-form-toggle {
  margin-top: var(--space-5);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.change-form-toggle summary {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  font-weight: 500;
  color: var(--color-text-muted);
}

.change-form-toggle[open] {
  padding: 0 var(--space-4) var(--space-4);
}

.alternatives {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-top: var(--space-4);
  font-weight: 400;
}

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

.alternatives li {
  padding-block: var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
}

.alternatives h4 {
  margin: 0 0 var(--space-2);
}

/* ========================================================================
   History
   ======================================================================== */

.history {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 48rem;
}

.history li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-subtle);
  font-size: var(--font-size-sm);
}

.history li:last-child {
  border-bottom: none;
}

.history-changes li {
  border-bottom: none;
  padding: var(--space-1) 0;
}

.history-status {
  font-weight: 700;
  text-transform: uppercase;
  font-size: var(--font-size-xs);
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-surface-subtle);
  letter-spacing: 0.08em;
}

/* ========================================================================
   htmx indicator
   ======================================================================== */

/* Behaviour: required by docs/UI_CONTRACT.md; restyle freely but keep these rules.
   htmx's own indicator styles are off (CSP has no inline styles), so a busy message
   is hidden until htmx marks it as in flight. */
.htmx-indicator {
  display: none;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-style: italic;
  padding: var(--space-2) 0;
}

.htmx-indicator.htmx-request,
.htmx-request .htmx-indicator {
  display: block;
}

/* ========================================================================
   Motion: the event page eases in, and answers, notices and new ideas fade
   in when they arrive. prefers-reduced-motion (above) turns all of it off.
   ======================================================================== */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.landing-hero,
.event-header {
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.landing-main,
.dashboard-layout {
  animation: rise 0.6s 0.1s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.change-result,
.alternatives,
.status-region .notice {
  animation: rise 0.35s ease-out both;
}

.ideas-new li {
  animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.ideas-new li:nth-child(2) { animation-delay: 0.06s; }
.ideas-new li:nth-child(3) { animation-delay: 0.12s; }
.ideas-new li:nth-child(4) { animation-delay: 0.18s; }
.ideas-new li:nth-child(5) { animation-delay: 0.24s; }

.ideas li {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ideas li:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Print (F15): the plan on paper. Controls are hidden and colours become ink on white,
   whatever the screen theme. */
.print-only,
.print-button[hidden] {
  display: none;
}

@media print {
  :root:root {
    --color-bg: #ffffff;
    --color-surface: #ffffff;
    --color-surface-subtle: #ffffff;
    --color-text: #000000;
    --color-text-muted: #333333;
    --color-border: #666666;
    --color-border-subtle: #cccccc;
    --color-primary: #000000;
    --color-success: #000000;
    --color-warning: #000000;
    --color-error: #000000;
    --color-error-bg: #ffffff;
    --color-ai-bg: #ffffff;
    --color-ai-text: #000000;
    --color-why-bg: #ffffff;
    --color-why-text: #000000;
    --color-notice-info-bg: #ffffff;
    --color-notice-success-bg: #ffffff;
    --color-badge-warning-bg: #ffffff;
    --color-heading: #000000;
    --color-hero-bg: #ffffff;
    --color-hero-text: #000000;
    --color-hero-muted: #333333;
    --color-track: #dddddd;
    --color-meter: #000000;
    --shadow-sm: none;
    --shadow-md: none;
  }

  .skip-link,
  .site-header,
  .event-actions,
  .section-nav,
  .event-header::after,
  .site-footer,
  .status-region,
  .site-main form,
  .no-print,
  .print-button,
  .calendar-export,
  .ai-panel,
  .htmx-indicator,
  #personalization,
  #plan-alternatives,
  #add-expense-heading,
  #change-manager,
  #history {
    display: none !important;
  }

  .print-only {
    display: inline;
  }

  body {
    font-size: 11pt;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .event-header {
    padding: 0 0 var(--space-4);
    border-bottom: 1px solid #000000;
    border-radius: 0;
  }

  .ideas-ai li {
    outline: none;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  tr,
  li,
  .notice {
    break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }
}
