:root {
  color-scheme: light;

  /* Core surfaces and text */
  --page-bg: #edf2f6;
  --page-bg-top: #e8f0f5;
  --page-glow: rgba(39, 107, 140, 0.12);
  --surface: #ffffff;
  --surface-muted: #f5f8fb;
  --surface-input: #ffffff;
  --surface-hover: #ffffff;
  --ink: #172b3a;
  --heading: #102b40;
  --muted: #617383;
  --muted-disabled: #81909d;
  --border: #d6e0e8;
  --border-strong: #b9c8d4;

  /* Brand and state colors */
  --navy: #173b57;
  --navy-dark: #102b40;
  --blue: #276b8c;
  --teal: #147d7e;
  --teal-dark: #0d6162;
  --gold: #bd842a;
  --gold-soft: #fff2d8;
  --green: #18794e;
  --green-soft: #e4f5ec;
  --red: #b42318;
  --red-soft: #fde8e7;
  --on-accent: #ffffff;

  /* Hero */
  --hero-start: rgba(23, 59, 87, 0.98);
  --hero-end: rgba(20, 125, 126, 0.92);
  --hero-border: rgba(255, 255, 255, 0.14);
  --hero-decoration: rgba(255, 255, 255, 0.06);
  --hero-muted: rgba(255, 255, 255, 0.78);
  --hero-soft: #bce9e5;
  --hero-control-border: rgba(255, 255, 255, 0.3);
  --hero-control-border-hover: rgba(255, 255, 255, 0.55);
  --hero-control-bg: rgba(255, 255, 255, 0.08);
  --hero-control-bg-hover: rgba(255, 255, 255, 0.16);
  --hero-danger-hover: rgba(180, 35, 24, 0.5);

  /* Reusable component colors */
  --focus-ring: rgba(39, 107, 140, 0.26);
  --input-focus-ring: rgba(39, 107, 140, 0.11);
  --info-border: #cae4e2;
  --info-ink: #365f60;
  --info-bg: #edf9f7;
  --rules-bg: rgba(255, 255, 255, 0.72);
  --rules-shadow: 0 8px 24px rgba(23, 59, 87, 0.04);
  --table-header-bg: #173b57;
  --table-header-ink: #ffffff;
  --excluded-bg: #f7f9fa;
  --cap-limited-bg: #fff8e8;
  --danger-border-soft: #f3c9c5;
  --toggle-off: #aebbc5;
  --toggle-knob: #ffffff;
  --toggle-inset: rgba(23, 59, 87, 0.12);
  --toggle-shadow: 0 1px 4px rgba(23, 59, 87, 0.26);
  --progress-track: #dfe8ee;
  --budget-border: #b8d7d5;
  --budget-bg: #edf9f7;
  --cost-border: #ead8a7;
  --cost-bg: #fff9e9;
  --toast-success-border: #abd8bf;
  --toast-success-ink: #125b39;
  --toast-success-bg: #e7f8ee;
  --toast-error-border: #efb5b0;
  --toast-error-ink: #84251d;
  --toast-error-bg: #fff0ef;

  --shadow: 0 18px 45px rgba(23, 59, 87, 0.09);
  --primary-shadow: 0 5px 13px rgba(20, 125, 126, 0.18);
  --toast-shadow: 0 12px 36px rgba(23, 59, 87, 0.18);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --page-bg: #0d171f;
  --page-bg-top: #142630;
  --page-glow: rgba(78, 183, 179, 0.12);
  --surface: #17242d;
  --surface-muted: #1d2d37;
  --surface-input: #1b2a34;
  --surface-hover: #223540;
  --ink: #e7eff3;
  --heading: #eaf3f7;
  --muted: #a5b5c0;
  --muted-disabled: #788a96;
  --border: #2d414e;
  --border-strong: #435a68;

  --navy: #254e64;
  --navy-dark: #dcecf3;
  --blue: #67a9c6;
  --teal: #3aa7a4;
  --teal-dark: #75d0cc;
  --gold: #d4a14f;
  --gold-soft: #3b301d;
  --green: #5ac58f;
  --green-soft: #183829;
  --red: #ef746a;
  --red-soft: #3d2224;

  --hero-start: rgba(20, 45, 60, 0.99);
  --hero-end: rgba(16, 91, 93, 0.95);
  --hero-border: rgba(180, 226, 224, 0.16);
  --hero-decoration: rgba(214, 242, 241, 0.055);
  --hero-muted: rgba(237, 248, 249, 0.78);
  --hero-soft: #a9dfdc;

  --focus-ring: rgba(103, 169, 198, 0.34);
  --input-focus-ring: rgba(103, 169, 198, 0.18);
  --info-border: #305c5c;
  --info-ink: #b8d8d6;
  --info-bg: #173234;
  --rules-bg: rgba(23, 36, 45, 0.86);
  --rules-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  --table-header-bg: #234a60;
  --table-header-ink: #f5fbfd;
  --excluded-bg: #18242c;
  --cap-limited-bg: #382f1e;
  --danger-border-soft: #76403f;
  --toggle-off: #536773;
  --toggle-knob: #edf5f7;
  --toggle-inset: rgba(0, 0, 0, 0.18);
  --toggle-shadow: 0 1px 4px rgba(0, 0, 0, 0.38);
  --progress-track: #2b3e49;
  --budget-border: #315f5d;
  --budget-bg: #183536;
  --cost-border: #68552d;
  --cost-bg: #352d1d;
  --toast-success-border: #356e51;
  --toast-success-ink: #b9e8cf;
  --toast-success-bg: #173629;
  --toast-error-border: #7a4542;
  --toast-error-ink: #ffc0ba;
  --toast-error-bg: #3b2223;

  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  --primary-shadow: 0 5px 13px rgba(0, 0, 0, 0.24);
  --toast-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}


/*
 * Prevent the document itself from scrolling horizontally.
 * Wide tables remain scrollable inside their .table-scroll containers.
 */
html {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden !important;
  overscroll-behavior-x: none;
  background: var(--page-bg);
}

body {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  overscroll-behavior-x: none;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, var(--page-glow), transparent 28rem),
    linear-gradient(180deg, var(--page-bg-top) 0, var(--page-bg) 24rem);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  padding: 0.12rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-muted);
  font-size: 0.92em;
}

.page-shell {
  width: min(1560px, calc(100% - 40px));
  min-width: 0;
  max-width: 100%;
  margin: 0 auto;
  padding: 36px 0 28px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 30px 34px;
  overflow: hidden;
  border: 1px solid var(--hero-border);
  border-radius: var(--radius-lg);
  color: var(--on-accent);
  background:
    linear-gradient(115deg, var(--hero-start), var(--hero-end)),
    linear-gradient(160deg, var(--navy), var(--teal));
  box-shadow: var(--shadow);
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -130px;
  width: 390px;
  height: 390px;
  border: 56px solid var(--hero-decoration);
  border-radius: 50%;
  pointer-events: none;
}

.hero-copy,
.hero-actions {
  position: relative;
  z-index: 1;
}

.hero-copy {
  max-width: 780px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 7px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--hero-soft);
}

.section-kicker {
  color: var(--teal);
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3.45rem);
  line-height: 1.03;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 7px;
  color: var(--heading);
  font-size: clamp(1.35rem, 2.2vw, 1.85rem);
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 5px;
  color: var(--heading);
  font-size: 1rem;
}

.hero-subtitle {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--hero-muted);
  font-size: 1rem;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 9px;
  min-width: 0px;
}

.saved-status {
  flex-basis: 100%;
  min-height: 1.3em;
  color: var(--hero-soft);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: right;
  opacity: 0;
  transition: opacity 160ms ease;
}

.saved-status.is-visible {
  opacity: 1;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 750;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.danger-button:focus-visible,
.icon-button:focus-visible,
.table-input:focus-visible,
.rules-panel summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  color: var(--on-accent);
  background: var(--teal);
  box-shadow: var(--primary-shadow);
  white-space: nowrap;
}

.primary-button:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
}

.secondary-button,
.danger-button {
  padding: 9px 13px;
  color: var(--on-accent);
  border: 1px solid var(--hero-control-border);
  background: var(--hero-control-bg);
  backdrop-filter: blur(3px);
}

.secondary-button:hover,
.danger-button:hover {
  border-color: var(--hero-control-border-hover);
  background: var(--hero-control-bg-hover);
}

.danger-button:hover {
  background: var(--hero-danger-hover);
}

.privacy-note {
  margin: 15px 0;
  padding: 13px 17px;
  border: 1px solid var(--info-border);
  border-radius: var(--radius-md);
  color: var(--info-ink);
  background: var(--info-bg);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* About and Quick Start */

.about-panel {
  margin-top: 15px;
}

.about-content {
  padding: 18px;
}

.about-intro {
  max-width: 880px;
  margin-bottom: 16px;
}

.about-intro h2 {
  margin-bottom: 7px;
  font-size: 1.35rem;
}

.about-intro p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.about-section {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 72%, var(--surface-muted));
}

.about-section h3 {
  margin-bottom: 11px;
}

.quick-start-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 1.3rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.quick-start-list li::marker {
  color: var(--teal);
  font-weight: 850;
}

.event-schedule {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.event-date-card {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.event-date-card span,
.event-date-card strong {
  display: block;
}

.event-date-card span {
  margin-bottom: 4px;
  color: var(--teal-dark);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.event-date-card strong {
  color: var(--heading);
  font-size: 0.82rem;
  line-height: 1.4;
}

.official-event-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  color: var(--teal-dark);
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.official-event-link:hover {
  color: var(--teal);
}

.official-event-link:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: 3px;
}

.about-storage-note {
  margin-top: 14px;
  padding: 11px 13px;
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  color: var(--info-ink);
  background: var(--info-bg);
  font-size: 0.8rem;
  line-height: 1.5;
}

.about-storage-note strong {
  color: var(--teal-dark);
}

.about-storage-note span {
  margin-left: 0.25em;
}

.about-disclaimer {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.rules-panel {
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--rules-bg);
  box-shadow: var(--rules-shadow);
}

.rules-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 18px;
  color: var(--heading);
  font-weight: 800;
  cursor: pointer;
  list-style-position: inside;
}

.rules-panel summary small {
  color: var(--muted);
  font-weight: 500;
}

.rules-panel[open] summary {
  border-bottom: 1px solid var(--border);
}

.rules-panel .table-scroll {
  padding: 7px 15px 15px;
}

.planner-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 350px);
  align-items: start;
  gap: 20px;
}

.planner-content {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.panel,
.summary-sticky {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
  min-width: 0;
}

.section-heading,
.subsection-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.section-heading {
  margin-bottom: 17px;
}

.subsection-heading {
  margin: 26px 0 12px;
  padding-top: 23px;
  border-top: 1px solid var(--border);
}

.section-heading p,
.subsection-heading p {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.table-scroll {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  border-radius: var(--radius-md);
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  padding: 8px;
}

.data-table td {
  padding: 6px;
}

.data-table th:first-child,
.data-table td:first-child {
  border-left: 1px solid var(--border);
}

.data-table thead th {
  color: var(--table-header-ink);
  background: var(--table-header-bg);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: left;
  white-space: nowrap;
}

.data-table thead th:first-child {
  border-top-left-radius: var(--radius-sm);
}

.data-table thead th:last-child {
  border-top-right-radius: var(--radius-sm);
}

.data-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--radius-sm);
}

.data-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--radius-sm);
}

.data-table tbody tr:nth-child(even) td {
  background: var(--surface-muted);
}

.data-table tbody tr {
  --resource-color: var(--navy);
  --resource-accent: var(--surface-muted);
}

.sources-table tbody td:first-child {
  border-left: 4px solid var(--resource-color);
}

.data-table tbody tr.is-excluded td {
  color: var(--muted-disabled);
  background: var(--excluded-bg);
}

.data-table tbody tr.is-excluded .table-input,
.data-table tbody tr.is-excluded .calculated-cell {
  opacity: 0.66;
}

.data-table tbody tr.is-cap-limited td {
  background: var(--cap-limited-bg);
}

.centered-heading,
.checkbox-cell {
  text-align: center !important;
}

.numeric-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.calculated-cell {
  min-width: 100px;
  font-variant-numeric: tabular-nums;
}

.calculated-cell strong,
.calculated-cell small,
.category-label,
.cell-note {
  display: block;
}

.calculated-cell strong {
  color: var(--heading);
}

.calculated-cell small,
.cell-note,
.category-label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.25;
}

.category-label {
  font-weight: 600;
}

.emphasized-cell {
  color: var(--heading);
  font-weight: 850;
}

.table-input {
  width: 100%;
  min-width: 0;
  height: 33px;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  transition:
    border-color 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease;
}

.table-input:hover {
  border-color: var(--border-strong);
  background: var(--surface-input);
}

.table-input:focus {
  border-color: var(--blue);
  background: var(--surface-input);
  box-shadow: 0 0 0 3px var(--input-focus-ring);
  outline: 0;
}

.source-name-cell {
  width: 39%;
  min-width: 185px;
}

.source-name-input {
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-select {
  min-width: 125px;
}

.numeric-input {
  width: 96px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.quantity-input {
  width: 78px;
}

.data-table .reorder-header,
.data-table .reorder-cell {
  width: 30px;
  min-width: 30px;
  padding: 3px;
  text-align: center;
  white-space: nowrap;
}

.data-table .row-action-cell {
  width: 36px;
  min-width: 36px;
  padding-left: 2px;
  padding-right: 2px;
  text-align: center;
  white-space: nowrap;
}

.source-reorder-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.icon-button {
  display: inline-grid;
  width: 29px;
  height: 29px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
}

.drag-handle {
  width: 22px;
  min-width: 22px;
  height: 28px;
  padding: 0;
  cursor: grab;
  font-size: 1.1rem;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle:hover,
.move-source-button:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--navy);
  background: var(--surface-muted);
}

.remove-source-button:hover {
  border-color: var(--danger-border-soft);
  color: var(--red);
  background: var(--red-soft);
}

.move-source-button {
  display: none;
}

.icon-button:disabled {
  opacity: 0.25;
  cursor: default;
}

#sourcesBody tr.is-dragging {
  opacity: 0.4;
}

#sourcesBody tr.drop-before>td {
  box-shadow: inset 0 3px 0 var(--blue);
}

#sourcesBody tr.drop-after>td {
  box-shadow: inset 0 -3px 0 var(--blue);
}

.toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 37px;
  height: 22px;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-visual {
  position: relative;
  width: 37px;
  height: 21px;
  border-radius: 999px;
  background: var(--toggle-off);
  box-shadow: inset 0 0 0 1px var(--toggle-inset);
  transition: background 130ms ease;
}

.toggle-visual::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--surface-input);
  box-shadow: var(--toggle-shadow);
  transition: transform 130ms ease;
}

.toggle input:checked+.toggle-visual {
  background: var(--teal);
}

.toggle input:checked+.toggle-visual::after {
  transform: translateX(16px);
}

.toggle input:focus-visible+.toggle-visual {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.resource-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--badge-color) 25%, white);
  border-radius: 999px;
  color: var(--badge-color);
  background: var(--badge-accent);
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.resource-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--badge-color);
}

.summary-panel {
  position: sticky;
  top: 18px;
  align-self: start;
  min-width: 0;
}

.summary-sticky {
  padding: 24px;
}

.summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.summary-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.summary-card strong {
  color: var(--heading);
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.budget-card {
  border-color: var(--budget-border);
  background: var(--budget-bg);
}

.cost-card {
  border-color: var(--cost-border);
  background: var(--cost-bg);
}

.difference-card {
  background: var(--surface-muted);
}

.difference-card strong.is-positive {
  color: var(--green);
}

.difference-card strong.is-negative {
  color: var(--red);
}

.progress-section {
  margin-top: 17px;
}

.progress-track {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--progress-track);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--teal));
  transition: width 240ms ease;
}

.progress-section p,
.summary-help {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.summary-divider {
  height: 1px;
  margin: 22px 0;
  background: var(--border);
}

.summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.compact-summary-line {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

.compact-summary-line:last-child {
  border-bottom: 0;
}

.compact-summary-line strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.compact-table td {
  height: 43px;
}


.resource-rule-note {
  margin: 0 15px 15px;
  padding: 11px 13px;
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  color: var(--info-ink);
  background: var(--info-bg);
  font-size: 0.8rem;
  line-height: 1.5;
}

.resource-rule-note strong {
  color: var(--teal-dark);
}

.theme-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.theme-select {
  height: 32px;
  padding: 4px 28px 4px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 0.76rem;
}

.theme-select:hover {
  border-color: var(--border-strong);
}

.theme-select:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

html[data-theme="dark"] .resource-badge {
  border-color: color-mix(in srgb, var(--badge-color) 42%, var(--border));
  color: color-mix(in srgb, var(--badge-color) 42%, var(--ink));
  background: color-mix(in srgb, var(--badge-color) 20%, var(--surface));
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 4px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

footer p {
  margin-bottom: 0;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(390px, calc(100% - 44px));
  padding: 12px 16px;
  border: 1px solid var(--toast-success-border);
  border-radius: var(--radius-md);
  color: var(--toast-success-ink);
  background: var(--toast-success-bg);
  box-shadow: var(--toast-shadow);
  font-size: 0.88rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.toast[data-type="error"] {
  border-color: var(--toast-error-border);
  color: var(--toast-error-ink);
  background: var(--toast-error-bg);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.visually-hidden {
  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;
}

@media (max-width: 1120px) {
  .planner-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }

  .panel {
    padding: 20px;
  }

  .source-name-cell {
    min-width: 170px;
  }
}

@media (max-width: 900px) {
  .about-grid {
    grid-template-columns: 1fr;
  }

  .page-shell {
    width: calc(100% - 24px);
    max-width: 760px;
    min-width: 0;
    padding-top: 12px;
  }

  .hero {
    display: block;
    padding: 25px;
  }

  .hero-actions {
    justify-content: flex-start;
    min-width: 0;
    margin-top: 22px;
  }

  .saved-status {
    flex-basis: auto;
    margin-right: auto;
    text-align: left;
  }

  .planner-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .summary-panel {
    position: static;
    order: -1;
    width: 100%;
  }

  .summary-sticky {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .summary-sticky>.section-kicker,
  .summary-sticky>h2,
  .progress-section,
  .summary-divider,
  .summary-sticky>h3,
  .summary-help,
  #cappedLeftovers {
    grid-column: 1 / -1;
  }

  .summary-card {
    display: block;
    margin-top: 0;
  }

  .summary-card strong {
    display: block;
    margin-top: 7px;
  }

  .data-table .reorder-header,
  .data-table .reorder-cell {
    width: 58px;
    min-width: 58px;
    padding: 3px;
  }

  .drag-handle {
    display: none;
  }

  .move-source-button {
    display: inline-grid;
    width: 25px;
    min-width: 25px;
    height: 28px;
    padding: 0;
    font-size: 1rem;
  }
}

@media (max-width: 640px) {
  .about-content {
    padding: 14px;
  }

  .about-section {
    padding: 14px;
  }

  .event-schedule {
    grid-template-columns: 1fr;
  }

  .about-storage-note strong,
  .about-storage-note span {
    display: block;
  }

  .about-storage-note span {
    margin: 3px 0 0;
  }

  .page-shell {
    width: calc(100% - 16px);
    max-width: 620px;
    min-width: 0;
    padding-bottom: 18px;
  }

  .hero,
  .panel,
  .summary-sticky {
    border-radius: 14px;
  }

  .hero {
    padding: 21px 18px;
  }

  h1 {
    font-size: 2.05rem;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .saved-status {
    grid-column: 1 / -1;
    min-height: 1em;
  }

  .secondary-button,
  .danger-button {
    padding-inline: 8px;
  }

  .privacy-note {
    font-size: 0.82rem;
  }

  .rules-panel summary {
    display: block;
  }

  .rules-panel summary small {
    display: block;
    margin: 4px 0 0 24px;
  }

  .panel,
  .summary-sticky {
    padding: 17px;
  }

  .section-heading {
    display: block;
  }

  .section-heading .primary-button {
    margin-top: 14px;
  }

  .summary-sticky {
    grid-template-columns: 1fr;
  }

  .summary-sticky>* {
    grid-column: 1 !important;
  }

  .summary-card {
    display: flex;
  }

  .summary-card strong {
    display: initial;
    margin-top: 0;
  }

  .data-table {
    font-size: 0.82rem;
  }

  .data-table th {
    padding: 7px;
  }

  .data-table td {
    padding: 6px 5px;
  }

  .max-quantity-cell {
    display: none;
  }

  footer {
    display: block;
    padding-inline: 2px;
  }

  footer p+p {
    margin-top: 8px;
  }

  .theme-control {
    margin-top: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {

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

/*
 * Mobile width containment
 *
 * Wide tables may scroll inside .table-scroll, but their intrinsic width
 * must not enlarge the planner, panels, or document.
 */
@media (max-width: 900px) {
  .planner-content,
  .summary-panel,
  .summary-sticky,
  .panel {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .planner-layout > *,
  .planner-content > * {
    min-width: 0;
    max-width: 100%;
  }
}