:root {
  color-scheme: light dark;
  --border: color-mix(in srgb, currentColor 18%, transparent);
  --muted: color-mix(in srgb, currentColor 60%, transparent);
}

body {
  /* Full bleed so the sticky header can span the viewport; the container below
     does the width limiting instead. */
  margin: 0;
  padding: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: Canvas;
}

.container {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

/* The chat view needs more room than the default reading column. */
.container:has(.chat-layout) {
  max-width: 62rem;
}

/* --- Sticky header --------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  /* Semi-opaque + blur so content scrolling underneath stays legible.
     The solid fallback matters: without it, backdrop-filter being
     unsupported leaves the bar transparent and unreadable. */
  background: Canvas;
  background: color-mix(in srgb, Canvas 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

@supports not (backdrop-filter: blur(1px)) {
  .site-header { background: Canvas; }
}

.site-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  max-width: 62rem;
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 0 0 auto;
}

.brand-mark {
  width: 1.35rem;
  height: 1.35rem;
  fill: #b33128;
  flex: 0 0 auto;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-right: auto;
  /* Four tabs don't fit beside the brand and account on a phone: scroll
     sideways rather than pushing the account controls off screen. */
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.site-nav a {
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  white-space: nowrap;
}

.site-nav a:hover {
  color: inherit;
  background: color-mix(in srgb, currentColor 8%, transparent);
}

.site-nav a[aria-current="page"] {
  color: inherit;
  font-weight: 600;
  background: color-mix(in srgb, currentColor 10%, transparent);
}

.site-account {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 0 0 auto;
  /* Keeps the account controls right-aligned when the nav is hidden
     (signed out). With the nav present, its own auto margin does this. */
  margin-left: auto;
}

.site-account .who {
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
  font-size: 0.88rem;
  white-space: nowrap;
}

.btn:hover {
  background: color-mix(in srgb, currentColor 8%, transparent);
}

.btn-primary {
  border-color: transparent;
  background: #b33128;
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: #9c2a22;
}

@media (max-width: 34rem) {
  .site-bar { gap: 0.6rem; padding: 0.6rem 0.9rem; }
  .brand-text { display: none; }
  .site-account .who { display: none; }
  .site-nav a { padding: 0.35rem 0.5rem; }
}

form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

input {
  flex: 1 1 12rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
}

button {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:hover {
  background: color-mix(in srgb, currentColor 8%, transparent);
}

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

li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

li.empty {
  color: var(--muted);
  border-bottom: none;
}

.item-desc {
  color: var(--muted);
  font-size: 0.9rem;
}

li button {
  margin-left: auto;
  padding: 0.2rem 0.55rem;
}

/* --- First aid chat ------------------------------------------------- */

/* Decorative, so alt="" and hidden from assistive tech. Cropped rather than
   letterboxed on narrow screens -- the mark stays centred via the SVG's own
   preserveAspectRatio="xMidYMid slice". */
.hero {
  display: block;
  width: 100%;
  height: clamp(7rem, 18vw, 11rem);
  object-fit: cover;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 15rem 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 46rem) {
  .chat-layout {
    grid-template-columns: 1fr;
  }
}

.chat-sidebar form {
  margin-bottom: 0.75rem;
}

.chat-list li {
  display: block;
  padding: 0.4rem 0.5rem;
  border-bottom: none;
  border-radius: 6px;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.chat-list li.active {
  background: color-mix(in srgb, currentColor 10%, transparent);
}

.chat-list a {
  color: inherit;
  text-decoration: none;
}

.notice {
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.transcript {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.msg {
  margin-bottom: 1.25rem;
}

.msg-role {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.msg-body {
  /* Model output is plain text with meaningful line breaks and indentation. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-user .msg-body {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: color-mix(in srgb, currentColor 8%, transparent);
}

/* Waiting for a reply: a spinner after whatever text has arrived, with a
   label while there is none yet. */
.msg-body.streaming::after {
  content: "";
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  margin-left: 0.4em;
  vertical-align: -0.15em;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: #b33128;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.msg-body.streaming:empty::before {
  content: "Thinking…";
  color: var(--muted);
}
.msg-body.streaming:empty::after { margin-left: 0.5em; }

@keyframes spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .msg-body.streaming::after { animation-duration: 2.4s; }
}

.msg-error .msg-body { color: #b33128; }

.empty-state {
  color: var(--muted);
}

.flash {
  padding: 0.55rem 0.8rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.upload-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.upload-form label {
  font-size: 0.85rem;
  font-weight: 600;
  flex-basis: 100%;
}

.upload-form input[type="file"] {
  flex: 1 1 14rem;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}

.upload-form .hint {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.msg-upload .msg-body {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  white-space: normal;
}

.msg-upload details {
  margin-top: 0.4rem;
  font-size: 0.8rem;
}

.msg-upload summary {
  cursor: pointer;
  color: var(--muted);
}

.download {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 0.6rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.download:hover {
  background: color-mix(in srgb, currentColor 8%, transparent);
}

.download span {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
}

.msg-upload pre {
  max-height: 18rem;
  overflow: auto;
  padding: 0.5rem;
  margin: 0.4rem 0 0;
  border-radius: 6px;
  background: color-mix(in srgb, currentColor 6%, transparent);
  font-size: 0.75rem;
  white-space: pre-wrap;
}

/* --- Signed-out landing page -------------------------------------------- */

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: clamp(3rem, 12vh, 7rem) 0 2rem;
}

.landing-mark {
  width: 3.5rem;
  height: 3.5rem;
  fill: #b33128;
  margin-bottom: 1.5rem;
}

.landing-tagline {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.landing-lede {
  max-width: 28rem;
  margin: 1rem 0 2rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.landing-cta {
  padding: 0.6rem 1.3rem;
  font-size: 1rem;
}

/* --- Household profile ------------------------------------------------------ */

.container:has(.profile-layout) { max-width: 62rem; }

.page-title { margin: 0 0 1rem; font-size: 1.6rem; letter-spacing: -0.01em; }

.privacy-note {
  margin: 0 0 1.25rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-left: 4px solid #2f7d4f;
  border-radius: 6px;
  font-size: 0.92rem;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 1.75rem;
  align-items: start;
}
@media (max-width: 48rem) { .profile-layout { grid-template-columns: 1fr; } }

.profile-layout h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
.profile-current-head { display: flex; justify-content: space-between; align-items: baseline; }
.profile-links { font-size: 0.9rem; }

.profile-section h3 {
  margin: 1rem 0 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.profile-section dl { margin: 0; display: grid; grid-template-columns: minmax(7rem, 2fr) 3fr; gap: 0.3rem 0.75rem; }
.profile-section dt { font-size: 0.88rem; color: var(--muted); }
.profile-section dd { margin: 0; font-size: 0.92rem; overflow-wrap: anywhere; }
.profile-section dd.unknown { color: var(--muted); font-style: italic; }

.tag {
  display: inline-block;
  padding: 0 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.72rem;
  color: var(--muted);
  vertical-align: middle;
}

.proposal {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid #d9a33a;
  border-radius: 8px;
  background: color-mix(in srgb, #d9a33a 8%, Canvas);
}
.proposal h3 { margin: 0 0 0.25rem; font-size: 1.02rem; }
.proposal .hint, .profile-form .hint, .hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.6rem; }
.proposal-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.proposal-actions .btn { cursor: pointer; font: inherit; font-size: 0.88rem; }

table.changes { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.changes th, table.changes td {
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.changes th { font-weight: 600; color: var(--muted); font-size: 0.8rem; }
table.changes .before { color: var(--muted); }
table.history .when, table.history .how { white-space: nowrap; color: var(--muted); font-size: 0.82rem; }

.inline-form { display: block; margin-top: 0.5rem; }
.link-button {
  border: none;
  background: none;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.85rem;
}

.profile-form { display: block; }
.profile-form fieldset {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.profile-form legend { font-weight: 600; padding: 0 0.3rem; }
.profile-form .field { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.6rem 0; }
.profile-form .field > span { font-size: 0.9rem; font-weight: 500; }
.profile-form small { color: var(--muted); font-size: 0.8rem; }
.profile-form input, .profile-form select, .profile-form textarea {
  /* The global `input { flex: 1 1 12rem }` would stretch these vertically
     inside the column-direction .field label. */
  flex: none;
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: Canvas;
  color: inherit;
  width: 100%;
  box-sizing: border-box;
}
.profile-form table.rows { width: 100%; border-collapse: collapse; }
.profile-form table.rows th { text-align: left; font-size: 0.8rem; color: var(--muted); font-weight: 500; padding: 0.2rem; }
.profile-form table.rows td { padding: 0.2rem; }
.profile-form table.rows td:nth-child(2) { width: 6.5rem; }
.form-actions { display: flex; gap: 0.5rem; }
.form-actions .btn { cursor: pointer; font: inherit; }
.flash-error { border-color: #b33128; }

/* --- Go bags --------------------------------------------------------------- */

.container:has(.go-bag-layout), .container:has(.go-bag-plan-full) { max-width: 72rem; }
.lede { color: var(--muted); margin: -0.5rem 0 1.25rem; max-width: 46rem; }
.profile-gap { border-left-color: #d9a33a; }

.go-bag-layout {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 3fr);
  gap: 1.75rem;
  align-items: start;
}
@media (max-width: 56rem) { .go-bag-layout { grid-template-columns: minmax(0, 1fr); } }
.go-bag-chat { position: sticky; top: 4.5rem; }
.go-bag-chat h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
.go-bag-chat .transcript { max-height: 55vh; overflow-y: auto; }
.quick-prompts { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: -0.75rem 0 0.5rem; }
.quick-prompts .btn { cursor: pointer; font: inherit; font-size: 0.85rem; }

.plan-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.plan-head h2 { margin: 0; font-size: 1.3rem; }
.plan-actions { display: flex; gap: 0.5rem; }
.plan-actions .btn { cursor: pointer; font: inherit; font-size: 0.88rem; }

.plan-climate {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
}
.plan-climate h3 { margin: 0 0 0.3rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.plan-climate p { margin: 0 0 0.6rem; }
.plan-climate p:last-child { margin-bottom: 0; }

.bag { margin: 0 0 0.9rem; border: 1px solid var(--border); border-radius: 8px; padding: 0 1rem; overflow-x: auto; }
.bag > summary { cursor: pointer; padding: 0.75rem 0; display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; }
.bag-name { font-weight: 650; font-size: 1.02rem; }
.bag-meta { color: var(--muted); font-size: 0.85rem; }
.bag h4 { margin: 1rem 0 0.3rem; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.bag[open] { padding-bottom: 0.75rem; }

table.items { width: 100%; min-width: 34rem; border-collapse: collapse; font-size: 0.9rem; }
table.items th { text-align: left; font-size: 0.75rem; font-weight: 500; color: var(--muted); padding: 0.25rem 0.4rem; border-bottom: 1px solid var(--border); }
table.items td { padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.items .check { width: 1.5rem; }
table.items .check input { flex: none; margin: 0.15rem 0 0; }
table.items .item-name { font-weight: 550; min-width: 9rem; }
table.items .qty { white-space: nowrap; }
table.items .season { white-space: nowrap; color: var(--muted); font-size: 0.82rem; }
table.items .why { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }
table.items .rotate { font-size: 0.82rem; margin-top: 0.15rem; color: #2f7d4f; }
table.items .status-note { font-size: 0.82rem; margin-top: 0.15rem; color: #b06d00; }

.badge {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0 0.35rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}
.badge-essential { background: #b33128; color: #fff; }
.badge-recommended { border: 1px solid var(--border); color: var(--muted); }
.badge-optional { color: var(--muted); }

.plan-versions h3 { font-size: 0.95rem; margin: 1.5rem 0 0.5rem; }
.plan-versions ul { margin: 0; }
.plan-versions li { padding: 0.2rem 0; border: none; }

@media print {
  .site-header, .go-bag-chat, .plan-actions, .lede, .profile-gap, .plan-versions { display: none !important; }
  .go-bag-layout { display: block; }
  .bag { break-inside: avoid-page; border: none; padding: 0; }
  .bag > summary { list-style: none; }
  details.bag > *:not(summary) { display: block !important; }
  .container { max-width: none; padding: 0; }
}

/* --- Classes ------------------------------------------------------------------ */

.container:has(.classes-layout) { max-width: 66rem; }
.classes-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 1.75rem;
  align-items: start;
}
@media (max-width: 52rem) { .classes-layout { grid-template-columns: minmax(0, 1fr); } }

.learn-form { display: block; }
.learn-form fieldset { border: none; padding: 0; margin: 0 0 1rem; }
.learn-form legend { font-weight: 600; margin-bottom: 0.5rem; }
.learn-form .field { display: flex; flex-direction: column; gap: 0.3rem; margin: 0 0 0.6rem; }
.learn-form textarea {
  font: inherit; padding: 0.5rem; border: 1px solid var(--border);
  border-radius: 6px; background: Canvas; color: inherit;
}
.learn-form .btn { cursor: pointer; font: inherit; }

.topic-chips { display: flex; flex-direction: column; gap: 0.4rem; }
.topic-chip {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 0.55rem;
  align-items: start;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.topic-chip:has(input:checked) { border-color: #b33128; background: color-mix(in srgb, #b33128 7%, Canvas); }
.topic-chip input { flex: none; grid-row: span 2; margin-top: 0.2rem; }
.chip-topic { font-weight: 550; font-size: 0.93rem; }
.chip-reason { color: var(--muted); font-size: 0.8rem; }

.class-history h3 { font-size: 0.95rem; margin: 1.5rem 0 0.4rem; }
.class-history ul { margin: 0; }
.class-history li { border: none; padding: 0.2rem 0; display: block; }
.class-history a[aria-current] { font-weight: 600; }

.class-search-head h2 { margin: 0; font-size: 1.15rem; }
.class-section { margin-top: 1.25rem; }
.class-section h3 { margin: 0 0 0.5rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.class-section h3 .hint { text-transform: none; letter-spacing: 0; }
.class-card { padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: 8px; margin: 0 0 0.6rem; }
.class-card h4 { margin: 0 0 0.2rem; font-size: 1rem; }
.class-card p { margin: 0.2rem 0 0; font-size: 0.92rem; }
.class-meta { color: var(--muted); font-size: 0.84rem !important; }

.searching { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); }
.spinner {
  flex: none;
  width: 1.1rem; height: 1.1rem;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: #b33128;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* --- Profile nudge and welcome ------------------------------------------------ */

.profile-nudge {
  background: color-mix(in srgb, #d9a33a 12%, Canvas);
  border-bottom: 1px solid color-mix(in srgb, #d9a33a 45%, transparent);
  font-size: 0.9rem;
}
.profile-nudge-inner {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0.6rem 1.25rem;
  display: flex;
  gap: 0.75rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.profile-nudge-actions { display: flex; align-items: center; gap: 0.75rem; }
.profile-nudge-actions form { margin: 0; display: inline; }

.profile-welcome {
  margin: 0 0 1.25rem;
  padding: 1rem 1.15rem;
  border: 1px solid #b33128;
  border-radius: 8px;
  background: color-mix(in srgb, #b33128 5%, Canvas);
}
.profile-welcome h2 { margin: 0 0 0.4rem; font-size: 1.15rem; }
.profile-welcome p { margin: 0.4rem 0 0; }

/* --- Admin ----------------------------------------------------------------------- */

.container:has(.admin-page) { max-width: 76rem; }
.admin-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.admin-head .page-title { margin-bottom: 0.25rem; }
.period-picker { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.period-picker a {
  padding: 0.3rem 0.65rem; border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.85rem; color: inherit; text-decoration: none;
}
.period-picker a[aria-current] { background: #b33128; border-color: #b33128; color: #fff; }

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.6rem;
  margin: 1.25rem 0 0.5rem;
}
.stat { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.8rem; display: flex; flex-direction: column; }
.stat-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.admin-section { margin-top: 1.75rem; }
.admin-section h2 { font-size: 1.05rem; margin: 0 0 0.5rem; }
.admin-section-head { display: flex; justify-content: space-between; align-items: center; }
.admin-section-head .btn { font-size: 0.82rem; }
.table-scroll { overflow-x: auto; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
table.admin-table th, table.admin-table td { padding: 0.4rem 0.55rem; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.admin-table thead th { font-size: 0.75rem; color: var(--muted); font-weight: 500; }
table.admin-table tbody th { font-weight: 550; }
table.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
table.admin-table .cost { font-weight: 600; }
table.admin-table tfoot th, table.admin-table tfoot td { border-top: 2px solid var(--border); font-weight: 650; }
table.admin-table .when { color: var(--muted); }
.sub-id { color: var(--muted); font-size: 0.72rem; font-weight: 400; }

/* --- First aid kit builder ---------------------------------------------------- */

.kit-builder { max-width: 34rem; }
.kit-builder h2 { margin: 0 0 0.35rem; font-size: 1.25rem; }
.kit-form { display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; }
.kit-form .field { display: flex; flex-direction: column; gap: 0.3rem; width: 100%; }
.kit-form .field > span { font-weight: 550; font-size: 0.92rem; }
.kit-form select, .kit-form input {
  flex: none; width: 100%; box-sizing: border-box; font: inherit;
  padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 6px;
  background: Canvas; color: inherit;
}
.kit-form .btn { cursor: pointer; font: inherit; }
/* The description box only appears when "Other" is chosen. */
.kit-other { display: none !important; }
.kit-form:has(option[value="other"]:checked) .kit-other { display: flex !important; }

/* --- Coming soon pages ----------------------------------------------------------- */

.coming-soon { text-align: center; padding: clamp(2rem, 8vh, 4.5rem) 0 2rem; }
.coming-soon h2 { margin: 0.75rem 0 0.25rem; font-size: clamp(1.5rem, 4vw, 2.1rem); letter-spacing: -0.01em; }
.coming-soon .lede { margin: 0.5rem auto 0; max-width: 32rem; }
.coming-soon-badge {
  display: inline-block;
  margin: 0;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: color-mix(in srgb, #d9a33a 18%, Canvas);
  border: 1px solid color-mix(in srgb, #d9a33a 50%, transparent);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --- Research service (app/templates/research/) --------------------------- */
.source-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1rem;
}
.source-meta dt { font-weight: 600; }
.source-meta dd { margin: 0; overflow-wrap: anywhere; }
.source-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 70vh;
  overflow: auto;
  padding: 1rem;
  border: 1px solid currentColor;
  border-radius: 6px;
}
#source-list tr[aria-current="true"] { font-weight: 600; }
.source-content {
  max-width: 48rem;
  padding: 1rem 1.25rem;
  border-left: 3px solid currentColor;
}
.source-content blockquote { margin-left: 1rem; font-style: italic; }
.research-form {
  display: grid;
  gap: 0.5rem;
  max-width: 48rem;
  margin-bottom: 2rem;
}
.research-form input,
.research-form textarea { width: 100%; box-sizing: border-box; }
.research-form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.research-form .form-actions { margin-bottom: 0.75rem; }

/* --- Research: Vendor Entry ----------------------------------------------- */
.vendor-form {
  display: grid;
  gap: 0.4rem;
  max-width: 40rem;
  margin-bottom: 2rem;
}
.vendor-form input[type="text"],
.vendor-form input[type="url"],
.vendor-form input[type="email"],
.vendor-form select,
.vendor-form textarea { width: 100%; box-sizing: border-box; }
.vendor-form label { margin-top: 0.4rem; }
.field-error { margin: 0; font-size: 0.875rem; color: #b42318; }
.vendor-form [aria-invalid="true"] { border-color: #b42318; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.star-rating { border: 0; padding: 0; margin: 0.4rem 0 0; }
.star-rating legend { padding: 0; margin-bottom: 0.25rem; }
.stars { display: inline-flex; flex-direction: row-reverse; gap: 0.15rem; }
.stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.stars label { cursor: pointer; margin: 0; line-height: 0; }
.stars svg {
  width: 2rem; height: 2rem;
  fill: transparent; stroke: var(--muted); stroke-width: 1.5;
  transition: fill 0.1s, stroke 0.1s;
}
/* The checked star and every star after it in the DOM (to its left on screen). */
.stars input:checked ~ label svg,
.stars label:hover svg,
.stars label:hover ~ label svg { fill: #f5b301; stroke: #d99a00; }
.stars input:focus-visible + label { outline: 2px solid currentColor; outline-offset: 2px; border-radius: 4px; }
.star-clear { display: inline-flex; gap: 0.35rem; align-items: center; margin-left: 0.75rem; font-size: 0.875rem; color: var(--muted); }

.btn-small { padding: 0.2rem 0.6rem; font-size: 0.85rem; }
.vendor-table tr[aria-current="true"] td { background: color-mix(in srgb, #f5b301 14%, transparent); }
.vendor-stars { white-space: nowrap; font-size: 1.1rem; }
.vendor-stars .on { color: #f5b301; }
.vendor-stars .off { color: var(--border); }
/* Match the global `input` look for the select and textarea; keep it off radios. */
.vendor-form select,
.vendor-form textarea {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
}
.vendor-form select { appearance: auto; min-height: 2.4rem; }
.vendor-form input[type="radio"] { flex: none; padding: 0; border: 0; width: auto; }
/* Edit scrolls the form to the top; keep its heading clear of the sticky header. */
#vendor-form { scroll-margin-top: 5rem; }
.vendor-date { white-space: nowrap; font-size: 0.85rem; color: var(--muted); }
.vendor-dates { margin: -0.25rem 0 0.25rem; }
/* Vendor categories: a checkbox list, two columns where there is room. */
.category-picker { border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.75rem 0.75rem; margin: 0.4rem 0 0; }
.category-picker legend { padding: 0 0.25rem; }
.category-picker[aria-invalid="true"] { border-color: #b42318; }
/* Columns, not a grid, so the alphabetical order runs down each column. */
.category-options { columns: 2 14rem; column-gap: 1rem; }
.vendor-form .category-option { display: flex; align-items: center; gap: 0.45rem; margin: 0 0 0.3rem; cursor: pointer; break-inside: avoid; }
.vendor-form .category-option input[type="checkbox"] { flex: none; width: auto; padding: 0; margin: 0; }
.vendor-categories .tag { display: inline-block; margin: 0 0.25rem 0.25rem 0; white-space: nowrap; }

/* --- Vendor list: wide ------------------------------------------------------
   Every other research page keeps the 44rem reading column; this one grows
   to nearly the full window so links and notes have room. The form inside
   stays at its own max-width. Below ~1400px the table scrolls sideways
   inside .table-scroll rather than crushing the columns. */
.container:has(#vendor-list) { max-width: min(100%, 120rem); }
.vendor-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.vendor-table th,
.vendor-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.vendor-table th { font-size: 0.8rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.vendor-table td:first-child { width: 1%; }
.vendor-table td:nth-child(2) { min-width: 8rem; font-weight: 600; }
.vendor-categories { min-width: 7rem; max-width: 11rem; }
.vendor-categories .tag { white-space: normal; }
.link-label {
  display: block;
  font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
}
/* Links: label above, the address on one line, cut with an ellipsis; the
   full URL is in the title and is what the link opens. */
/* Grows with the window: ~20rem at 1440px, up to 30rem on wide screens. */
.vendor-links { width: clamp(15rem, 22vw, 30rem); }
.vendor-link { margin-bottom: 0.45rem; }
.vendor-link a {
  display: block; max-width: clamp(15rem, 22vw, 30rem);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vendor-table td:nth-child(5) { min-width: 10rem; overflow-wrap: anywhere; }
/* Notes take whatever width is left. */
.vendor-notes { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 16rem; }
.vendor-dates-cell { white-space: nowrap; }
.vendor-dates-cell .vendor-date { margin-bottom: 0.3rem; }
.source-description { font-size: 0.875rem; margin: 0.15rem 0; }

/* --- Research: Practice Drills ------------------------------------------------- */
.container:has(#drill-list) { max-width: min(100%, 120rem); }
.drill-form { max-width: 52rem; }
.drill-incident { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.drill-incident select { padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: inherit; font: inherit; }
.drill-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0 1rem; }
.drill-row .drill-wide { grid-column: span 2; }
.drill-row input, .drill-row select { width: 100%; box-sizing: border-box; }
.vendor-form input[type="number"] { width: 100%; box-sizing: border-box; }
.drill-deps { columns: 2 18rem; }
.drill-priority { display: inline-flex; margin-right: 1.25rem; }
.priority {
  display: inline-block; min-width: 1.5em; text-align: center; font-weight: 700; font-size: 0.8rem;
  border-radius: 999px; padding: 0.05rem 0.4rem; color: #fff;
}
.priority-1 { background: #b42318; }
.priority-2 { background: #b54708; }
.priority-3 { background: #667085; }
.drill-table .drill-phase th {
  text-align: left; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: inherit; background: color-mix(in srgb, currentColor 6%, transparent); padding-top: 0.6rem;
}
.drill-task { min-width: 22rem; }
.drill-instructions { white-space: pre-wrap; margin: 0.2rem 0; font-size: 0.875rem; }
.drill-deps-cell div { margin-bottom: 0.2rem; }

/* --- Other Resources ------------------------------------------------------- */
.resource-list { list-style: none; padding: 0; margin: 0; }
/* display: block overrides the global `li { display: flex }` (Item example). */
.resource { display: block; padding: 0.85rem 0; border-bottom: 1px solid var(--border); }
.resource-link { font-weight: 600; overflow-wrap: anywhere; }
.resource .tag { margin-left: 0.4rem; vertical-align: middle; }
.resource-description { margin: 0.3rem 0 0.15rem; }
.resource-host { margin: 0; font-size: 0.8rem; color: var(--muted); }
.drill-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; }
.drill-head .page-title { margin: 0; }
.drill-head .drill-incident { margin: 0; }
.drill-head .btn-primary { margin-left: auto; }
.drill-form-open { border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
#drill-form { scroll-margin-top: 5rem; }
/* The drill table shares .vendor-table; undo the vendor column minimums
   (2nd = vendor name, 5th = email) that don't fit this table's columns. */
.drill-table td:nth-child(2) { min-width: 0; width: 3rem; font-weight: 400; }   /* seq */
.drill-table td:nth-child(5) { min-width: 0; width: 6rem; overflow-wrap: normal; } /* role */
.drill-table td:nth-child(6) { min-width: 8rem; }                                  /* condition */
.drill-deps-cell { min-width: 10rem; font-size: 0.85rem; }
.drill-task { min-width: 20rem; }

/* --- ReadySetGO drills ------------------------------------------------------ */
.container:has(.drill-steps) { max-width: 56rem; }
.drill-start { display: grid; gap: 0.5rem; margin-bottom: 1.5rem; }
/* The plan (#drill-setup) sits in the form for its Start button; only the controls are narrow. */
.drill-start > :not(#drill-setup), #drill-setup > .drill-timer { max-width: 28rem; }
.drill-start select { padding: 0.5rem 0.65rem; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: inherit; font: inherit; }
.drill-timer {
  display: flex; align-items: center; gap: 1rem; margin: 0.5rem 0 1rem;
  padding: 0.75rem 1rem; border: 2px solid var(--border); border-radius: 12px; width: fit-content;
}
.drill-clock { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 5.5rem; }
.drill-timer-button { font-size: 1.1rem; padding: 0.55rem 1.4rem; }
.drill-timer-running { border-color: #b42318; }
.drill-timer-low .drill-clock { color: #b42318; }
.drill-people { list-style: disc; padding-left: 1.25rem; }
.drill-people li { display: list-item; border: 0; padding: 0.1rem 0; }
.drill-steps { list-style: none; padding: 0; margin: 0; }
.drill-steps-phase {
  display: block; border: 0; margin-top: 1rem; padding: 0.3rem 0;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.drill-step { display: flex; align-items: flex-start; gap: 1rem; justify-content: space-between; }
.drill-step-main { flex: 1; min-width: 0; }
.drill-step-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.drill-step-num { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.5rem; }
.drill-assignee { margin-left: auto; font-size: 0.85rem; padding: 0.1rem 0.55rem; border: 1px solid var(--border); border-radius: 999px; }
.drill-step-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; justify-content: flex-end; min-width: 12rem; }
.drill-step-completed { opacity: 0.75; }
.drill-step-failed { opacity: 0.75; }
.drill-done { color: #067647; font-weight: 600; }
.drill-failed { color: #b42318; font-weight: 600; }
.drill-fail-button { border-color: #b42318; color: #b42318; }
.drill-waiting { width: 100%; text-align: right; }
.drill-steps .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.drill-assumed { margin: 1.25rem 0; }
.drill-result { display: flex; gap: 1.5rem; align-items: flex-start; margin: 1rem 0; }
.drill-grade { display: inline-block; font-weight: 800; text-align: center; border-radius: 8px; padding: 0 0.4rem; color: #fff; background: #667085; }
.drill-grade-big { font-size: 3.5rem; line-height: 1; padding: 0.6rem 1.1rem; border-radius: 14px; }
.drill-grade-A, .drill-grade-B { background: #067647; }
.drill-grade-C { background: #b54708; }
.drill-grade-D, .drill-grade-F { background: #b42318; }
.drill-score { font-size: 1.2rem; font-weight: 600; margin: 0 0 0.25rem; }
.drill-breakdown { list-style: none; padding: 0; }
.drill-breakdown li { display: block; border: 0; padding: 0.15rem 0; }

/* --- First aid kits saved by the agent (chat transcript) ------------------ */
.kit { margin-top: 0.75rem; padding: 0.75rem 0.9rem; border: 1px solid var(--border); border-radius: 10px; }
.kit-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.kit-head h3 { margin: 0; font-size: 1.05rem; }
.kit-notes { white-space: pre-wrap; font-size: 0.9rem; color: var(--muted); }
.kit-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.kit-table th, .kit-table td { text-align: left; vertical-align: top; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); }
.kit-table thead th { font-size: 0.75rem; color: var(--muted); }
.kit-category th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; background: color-mix(in srgb, currentColor 6%, transparent); }
.kit-status { font-size: 0.8rem; color: #b54708; margin-top: 0.15rem; }

.drill-na { color: var(--muted); font-weight: 600; }
.drill-step-not_applicable { opacity: 0.6; }
.drill-na-button { color: var(--muted); }
.leave-confirm { max-width: 26rem; border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; }
.leave-confirm::backdrop { background: rgb(0 0 0 / 0.35); }
.leave-confirm p { font-size: 1.1rem; font-weight: 600; margin-top: 0; }
/* "Preparing the drill…" shows only while the pulldown's request is in flight
   (HTMX adds .htmx-request to the hx-indicator element). */
.drill-preparing { display: none; }
.drill-preparing.htmx-request { display: block; }
#drill-setup:empty { display: none; }
.drill-feedback { margin: 1.5rem 0; }
.drill-feedback h2 { font-size: 1.05rem; margin: 0 0 0.5rem; }
.drill-feedback textarea {
  display: block; width: 100%; box-sizing: border-box; padding: 0.5rem 0.65rem; border: 1px solid var(--border);
  border-radius: 6px; background: transparent; color: inherit; font: inherit; margin-bottom: 0.5rem;
}
.drill-feedback-saved { color: #027a48; font-weight: 600; }
.category-picker #v-edit-categories { margin-top: 0.75rem; }
.category-editor:empty { display: none; }
.category-editor { margin-top: 0.75rem; padding: 0.75rem; border: 1px solid var(--border); border-radius: 8px; }
.category-edit-list { list-style: none; padding: 0; margin: 0 0 0.75rem; display: grid; gap: 0.4rem; }
.category-edit-list li, .category-add { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.category-edit-list input, .category-add input { flex: 1 1 14rem; }
.category-edit-list .field-error, .category-add .field-error { flex-basis: 100%; margin: 0; }
.category-add { margin-bottom: 0.75rem; }
.category-add label { flex-basis: 100%; font-size: 0.9rem; }
