/* Horaris UPF: neutral warm greys, one accent (blue), system type.
   Light/dark via prefers-color-scheme. */
:root {
  color-scheme: light dark;
  --bg: #faf9f7;
  --surface: #ffffff;
  --fill: #f0efec;
  --fill-strong: #e5e3df;
  --text: #1d1d1f;
  --text-muted: #63636a;
  --hairline: rgb(0 0 0 / 0.08);
  --accent: #0066cc;          /* links, focus, selected states */
  --accent-fill: #0071e3;     /* filled buttons (white text, 4.6:1) */
  --accent-fill-hover: #0077ed;
  --accent-on: #ffffff;
  --accent-soft: #e8f1fc;
  --accent-ink: #00448a;      /* text on --accent-soft */
  --header-bg: rgb(250 249 247 / 0.78);
  --warn-bg: #fdf3dc;
  --warn-text: #7a4b00;
  --success-bg: #e3f5e8;
  --success-text: #1b6b34;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.04);
  --shadow-pop: 0 6px 24px rgb(0 0 0 / 0.12);
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --dur: 180ms;
  --content: 40rem;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f10;
    --surface: #1c1c1e;
    --fill: #242426;
    --fill-strong: #2f2f32;
    --text: #f5f5f7;
    --text-muted: #a1a1a8;
    --hairline: rgb(255 255 255 / 0.09);
    --accent: #4aa3ff;
    --accent-fill: #0071e3;
    --accent-fill-hover: #1a82f0;
    --accent-on: #ffffff;
    --accent-soft: #11294a;
    --accent-ink: #b9daff;
    --header-bg: rgb(15 15 16 / 0.72);
    --warn-bg: #3a2c10;
    --warn-text: #f5d38a;
    --success-bg: #12301d;
    --success-text: #9be2b0;
    --shadow: none;
    --shadow-pop: 0 8px 28px rgb(0 0 0 / 0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.2; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 0.18em; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Shell ---------- */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.header-inner {
  max-width: var(--content); margin-inline: auto; padding: 0 20px;
  height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; flex: none; display: block; }
.brand-name { font-weight: 650; font-size: 1.0625rem; letter-spacing: -0.02em; }
.badge {
  font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
  background: var(--fill); border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}

.shell { max-width: var(--content); margin-inline: auto; padding: 0 20px 56px; }
.disclaimer-inline { margin: 14px 0 0; font-size: 0.8125rem; color: var(--text-muted); }
.disclaimer-inline a { color: inherit; text-decoration: underline; }

main { padding-top: 28px; }

.app-footer {
  margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--hairline);
  font-size: 0.8125rem; color: var(--text-muted); overflow-wrap: anywhere;
}
.app-footer a { color: inherit; text-decoration: underline; }
.app-footer a:hover { color: var(--text); }

/* ---------- Type ---------- */
.page-head { margin-bottom: 24px; }
.page-title, .sel-title { font-size: clamp(1.875rem, 6vw, 2.5rem); font-weight: 700; margin: 0 0 8px; letter-spacing: -0.03em; }
.step-sub { color: var(--text-muted); margin: 0; font-size: 1.0625rem; line-height: 1.5; }
.ext-hint { margin: 6px 0 28px; font-size: 0.875rem; color: var(--text-muted); }
h2 { font-size: 1.25rem; font-weight: 650; margin: 32px 0 12px; }

/* ---------- Messages ---------- */
.missatge, .avis { border-radius: var(--radius); padding: 14px 16px; font-size: 0.9375rem; }
.missatge { background: var(--fill); color: var(--text); margin: 0; }
.avis { background: var(--warn-bg); color: var(--warn-text); margin: 12px 0; }
.avis ul { margin: 6px 0 0; padding-left: 18px; }
/* Re-subscribe notice: must be seen, but it's guidance, not an error. */
.republish {
  background: var(--accent-soft); color: var(--accent-ink);
  border-left: 3px solid var(--accent-fill); border-radius: 10px;
  padding: 8px 12px; margin: 0 0 12px; font-size: 0.875rem; line-height: 1.45;
}
.republish p { margin: 0; }
.republish details { margin-top: 2px; }
.republish summary { cursor: pointer; color: var(--accent); font-weight: 600; width: fit-content; }
.republish details p { margin-top: 4px; }
.pendents { background: var(--fill); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; font-size: 0.9375rem; }
.pendents p { margin: 0; }
.pendents ul { margin: 6px 0 0; padding-left: 18px; color: var(--text-muted); }

/* ---------- Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .field-label { font-size: 0.8125rem; color: var(--text-muted); font-weight: 600; }
.field select, .picker select {
  width: 100%; border: none; border-radius: var(--radius-sm); background: var(--fill);
  color: var(--text); padding: 10px 36px 10px 14px; min-height: 44px; font-size: 1rem;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%238a8a8f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 12px 8px;
}

/* Segmented control (trimestre). */
.segmented-field { border: none; margin: 0 0 16px; padding: 0; min-width: 0; }
.segmented-field legend { padding: 0; margin-bottom: 6px; }
.segmented {
  display: flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--fill);
  width: 100%; max-width: 100%; overflow-x: auto;
}
.segmented label { flex: 1 1 0; min-width: max-content; position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: flex; align-items: center; justify-content: center; min-height: 38px; padding: 6px 14px;
  border-radius: 8px; font-size: 0.9375rem; font-weight: 500; color: var(--text); white-space: nowrap;
  transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.segmented input:checked + span {
  background: var(--surface); font-weight: 600;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12), 0 0 0 0.5px rgb(0 0 0 / 0.04);
}
@media (prefers-color-scheme: dark) { .segmented input:checked + span { background: var(--fill-strong); } }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Search. */
.search-box { position: relative; margin: 0 0 12px; }
.search-box input {
  width: 100%; border: 1px solid transparent; border-radius: 999px; background: var(--fill);
  color: var(--text); min-height: 48px; padding: 10px 18px 10px 44px; font-size: 1.0625rem;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.search-box input::placeholder { color: var(--text-muted); opacity: 1; }
.search-box input:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-muted); pointer-events: none; }

/* Disclosures (filters, how-to). */
.filters, details.howto { border-radius: var(--radius); background: var(--fill); margin-bottom: 8px; }
.filters > summary, details.howto > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 46px; padding: 11px 16px; font-size: 0.9375rem; font-weight: 500; color: var(--text); border-radius: var(--radius);
}
.filters > summary::-webkit-details-marker, details.howto > summary::-webkit-details-marker { display: none; }
.filters > summary::after, details.howto > summary::after {
  content: ""; flex: none; width: 8px; height: 8px; margin-right: 4px;
  border-right: 1.6px solid var(--text-muted); border-bottom: 1.6px solid var(--text-muted);
  transform: rotate(45deg) translateY(-2px); transition: transform var(--dur) var(--ease);
}
.filters[open] > summary::after, details.howto[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.filters-body { padding: 2px 16px 14px; display: grid; gap: 0 12px; grid-template-columns: 1fr; }
.filters-body .field select { background-color: var(--surface); }
@media (min-width: 560px) { .filters-body { grid-template-columns: 1fr 1fr; } .filters-body .field:first-child { grid-column: 1 / -1; } }
details.howto .howto-body { padding: 0 16px 16px; font-size: 0.9375rem; color: var(--text-muted); }
.check { display: flex; align-items: center; gap: 10px; font-size: 0.9375rem; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent-fill); margin: 0; }

.trimestre-note { margin: 10px 0; font-size: 0.8125rem; color: var(--text-muted); }
.trimestre-note:empty { display: none; }
.search-empty, .results-count { margin: 12px 4px; font-size: 0.875rem; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  cursor: pointer; border: none; border-radius: 999px; background: var(--fill); color: var(--accent);
  padding: 10px 18px; font-weight: 600; font-size: 0.9375rem; min-height: 44px;
  transition: background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--fill-strong); }
.btn:active { transform: scale(0.97); }
.btn-small { flex: none; padding: 7px 16px; font-size: 0.875rem; min-height: 36px; }
.btn-primary { background: var(--accent-fill); color: var(--accent-on); }
.btn-primary:hover { background: var(--accent-fill-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--fill); }
.result-row .btn-small { min-height: 44px; }

/* ---------- Search results ---------- */
.results { list-style: none; margin: 0; padding: 4px 0; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.result + .result .result-row { box-shadow: inset 0 1px 0 var(--hairline); }
.result-row { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 18px; }
.result-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.r-name { font-weight: 600; font-size: 1rem; overflow-wrap: anywhere; }
.r-meta { font-size: 0.8125rem; color: var(--text-muted); overflow-wrap: anywhere; }
.pill {
  display: inline-block; font-size: 0.6875rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--fill); color: var(--text-muted); vertical-align: 0.1em;
}

/* Group / subgroup picker: options as chips. */
.grup-picker { padding: 6px 18px 18px; }
.grup-picker fieldset { border: none; margin: 10px 0 0; padding: 0; min-width: 0; }
.picker-legend { padding: 0; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.option-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.option {
  position: relative; display: flex; align-items: center; min-height: 44px; max-width: 100%;
  padding: 8px 16px; border-radius: var(--radius); background: var(--fill); cursor: pointer;
  transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.option:hover { background: var(--fill-strong); }
.option:has(input:checked) { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 2px var(--accent); }
.option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.radio-dot { display: none; }
.option-label { min-width: 0; display: flex; flex-direction: column; }
.option-title { font-weight: 600; font-size: 0.9375rem; }
.option-meta { font-size: 0.8125rem; color: var(--text-muted); margin: 0; overflow-wrap: anywhere; }
.option:has(input:checked) .option-meta { color: inherit; opacity: 0.85; }
.grup-picker > .option-meta { margin-top: 10px; }
.picker-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Selection ---------- */
.my-selection { margin-top: 40px; }
.my-selection h2 { margin: 0 0 12px; }
.my-selection h2:focus { outline: none; }
.my-selection .count { color: var(--text-muted); font-weight: 400; }
.my-selection > .action-btn { margin-top: 16px; }
.selection { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chip {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  padding: 10px 8px 10px 16px; font-size: 0.9375rem; font-weight: 500;
}
@media (prefers-color-scheme: dark) { .chip { background: var(--surface); } }
.chip-row { list-style: none; }
.chip-row .grup-picker { background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); margin-top: -8px; padding-top: 4px; }
.chip-row:has(.grup-picker) .chip { border-radius: var(--radius) var(--radius) 0 0; }
.chip-meta { color: var(--text-muted); font-size: 0.8125rem; font-weight: 400; }
.chip-actions { display: flex; gap: 2px; flex: none; }
.chip-remove {
  flex: none; background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: 0.875rem; font-weight: 500; padding: 6px 10px; min-height: 36px; border-radius: 999px;
  transition: background-color var(--dur) var(--ease);
}
.chip-remove:hover { background: var(--fill); }
.edit-row { margin: 0 0 24px; font-size: 0.875rem; color: var(--text-muted); }
.edit-row a { font-weight: 600; }

.picker { margin-bottom: 14px; }
.picker label { display: block; font-size: 0.9375rem; margin-bottom: 6px; }

/* ---------- Subscribe actions ---------- */
.actions { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 24px; }
.actions-secondary { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 600px) {
  .actions-secondary { grid-template-columns: 1fr 1fr; }
  .actions-secondary > :first-child { grid-column: 1 / -1; }
}
.action-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  text-decoration: none; cursor: pointer; border: none; border-radius: 999px;
  background: var(--fill); color: var(--accent); padding: 10px 18px; min-height: 46px; width: 100%;
  font-weight: 600; font-size: 0.9375rem; line-height: 1.25;
  transition: background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.action-btn:hover { background: var(--fill-strong); text-decoration: none; }
.action-btn:active { transform: scale(0.98); }
.action-btn.primary { background: var(--accent-fill); color: var(--accent-on); min-height: 54px; font-size: 1.0625rem; }
.action-btn.primary:hover { background: var(--accent-fill-hover); }
.action-btn .icon { flex: none; width: 20px; height: 20px; }
.action-btn .sub { font-weight: 400; font-size: 0.8125rem; opacity: 0.8; }
.actions-secondary > div { position: relative; display: flex; }

.toast {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--success-bg); color: var(--success-text);
  border-radius: 999px; padding: 6px 14px; font-size: 0.8125rem; font-weight: 600; text-align: center;
}
.toast[data-show="true"] { display: block; animation: fade-in var(--dur) var(--ease); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.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;
}

/* ---------- Week view ----------
   Mobile (default): one day at a time as a list. >= 720px: positioned grid. */
.week { margin-top: 48px; }
.week-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.week-head h2 { margin: 0; font-size: 1.25rem; }
.week-nav { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--fill); }
.nav-btn {
  cursor: pointer; border: none; border-radius: 999px; background: transparent; color: var(--text);
  min-height: 38px; min-width: 44px; padding: 4px 14px; font-size: 0.9375rem; font-weight: 600;
  transition: background-color var(--dur) var(--ease);
}
.nav-btn[data-nav="prev"], .nav-btn[data-nav="next"] { font-size: 1.25rem; line-height: 1; padding: 0 12px; }
.nav-btn:not(:disabled):hover { background: var(--fill-strong); }
.nav-btn:disabled { cursor: default; color: var(--text-muted); opacity: 0.55; }

.day-picker { display: flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--fill); margin-bottom: 14px; }
.day-chip {
  flex: 1 1 0; min-width: 0; cursor: pointer; border: none; border-radius: 8px; background: transparent;
  color: var(--text); min-height: 44px; padding: 4px 2px; font-size: 0.8125rem; font-weight: 500;
  transition: background-color var(--dur) var(--ease);
}
.day-chip:hover { background: var(--fill-strong); }
.day-chip[aria-pressed="true"] { background: var(--surface); font-weight: 650; box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
@media (prefers-color-scheme: dark) { .day-chip[aria-pressed="true"] { background: var(--fill-strong); } }

.week-hours { display: none; }
.day { display: none; }
.day.is-active { display: block; }
.day-head { display: none; }
.day-col { list-style: none; margin: 0; padding: 0; }
.day-empty { margin: 0; padding: 16px 4px; color: var(--text-muted); font-size: 0.9375rem; }

/* Pastel blocks, stable hue per subject (data-color from week-render). */
.ev[data-color="0"], .swatch[data-color="0"] { --h: 25; }
.ev[data-color="1"], .swatch[data-color="1"] { --h: 245; }
.ev[data-color="2"], .swatch[data-color="2"] { --h: 150; }
.ev[data-color="3"], .swatch[data-color="3"] { --h: 300; }
.ev[data-color="4"], .swatch[data-color="4"] { --h: 80; }
.ev[data-color="5"], .swatch[data-color="5"] { --h: 200; }
.ev[data-color="6"], .swatch[data-color="6"] { --h: 350; }
.ev[data-color="7"], .swatch[data-color="7"] { --h: 115; }
.ev {
  --ev-bg: oklch(94.5% 0.04 var(--h));
  --ev-bar: oklch(64% 0.13 var(--h));
  --ev-ink: oklch(32% 0.07 var(--h));
  --ev-muted: oklch(40% 0.06 var(--h));
}
@media (prefers-color-scheme: dark) {
  .ev {
    --ev-bg: oklch(34% 0.08 var(--h));
    --ev-bar: oklch(74% 0.14 var(--h));
    --ev-ink: oklch(96% 0.02 var(--h));
    --ev-muted: oklch(86% 0.04 var(--h));
  }
}
.ev {
  display: grid; grid-template-columns: 6.25rem 1fr; column-gap: 12px; padding: 12px 14px; margin-bottom: 8px;
  border-radius: 12px; background: var(--ev-bg); color: var(--ev-ink);
  box-shadow: inset 3px 0 0 var(--ev-bar);
  font-size: 0.9375rem; line-height: 1.35;
}
.ev-time { grid-row: 1 / span 3; font-variant-numeric: tabular-nums; color: var(--ev-muted); font-size: 0.875rem; font-weight: 500; }
.ev-name { font-weight: 650; }
.ev-meta { color: var(--ev-muted); font-size: 0.8125rem; }
.ev-overlap { font-size: 0.75rem; font-weight: 700; color: var(--warn-text); }
.ev .ev-overlap { color: var(--ev-ink); text-decoration: underline wavy; text-decoration-thickness: 1px; }

@media (min-width: 720px) {
  /* The grid breaks out of the content column, never wider than the viewport. */
  .week { position: relative; left: 50%; transform: translateX(-50%); width: min(60rem, calc(100vw - 40px)); }
  .day-picker { display: none; }
  .week-body {
    --hour-h: 56px;
    display: grid; grid-template-columns: 52px repeat(var(--days), minmax(0, 1fr));
    border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); box-shadow: var(--shadow);
    padding: 0 6px 6px 0;
  }
  .week-hours {
    display: block; grid-row: 2; grid-column: 1;
    font-size: 0.6875rem; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums;
  }
  .week-hours span { display: block; height: var(--hour-h); padding: 0 10px 0 0; transform: translateY(-0.5em); }
  .week-body::before { content: ""; grid-row: 1; grid-column: 1; }
  .day, .day.is-active { display: contents; }
  .day-head {
    display: block; grid-row: 1; grid-column: var(--col); margin: 0; padding: 14px 4px 12px; text-align: center;
    font-size: 0.8125rem; font-weight: 600; color: var(--text-muted);
  }
  .day.is-today .day-head { color: var(--accent); }
  .day-col {
    grid-row: 2; grid-column: var(--col); position: relative; height: calc(var(--hours) * var(--hour-h));
    background-image: repeating-linear-gradient(to bottom, var(--hairline) 0, var(--hairline) 1px, transparent 1px, transparent var(--hour-h));
  }
  .day-empty { display: none; }
  .ev {
    position: absolute; top: var(--top); height: var(--height);
    left: calc(var(--left) + 2px); width: calc(var(--width) - 4px);
    display: block; margin: 0; padding: 4px 6px 4px 9px; overflow: hidden;
    border-radius: 8px; font-size: 0.75rem; line-height: 1.25;
    transition: box-shadow var(--dur) var(--ease);
  }
  .ev:hover, .ev:focus-within { z-index: 1; overflow: visible; height: auto; min-height: var(--height); box-shadow: inset 3px 0 0 var(--ev-bar), var(--shadow-pop); }
  .ev > span { display: block; }
  .ev-time { font-size: 0.6875rem; }
  .ev-overlap { font-size: 0.625rem; }
}

/* ---------- Privacy / prose ---------- */
.prose { font-size: 1rem; line-height: 1.65; }
.prose .page-title { margin-bottom: 24px; }
.prose h2 { font-size: 1.25rem; margin: 40px 0 10px; }
.prose p { margin: 0 0 16px; }
.prose ul { margin: 0 0 16px; padding-left: 22px; }
.prose li { margin-bottom: 8px; }
.prose li::marker { color: var(--text-muted); }
.prose code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.875em;
  background: var(--fill); padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere;
}

/* ---------- Small screens ---------- */
@media (max-width: 420px) {
  .header-inner, .shell { padding-inline: 16px; }
  .ev { grid-template-columns: 5.5rem 1fr; }
  .result-row { padding-left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .btn:active, .action-btn:active { transform: none; }
}

/* ---------- Calendar mode: one calendar or one per subject ---------- */
.cal-mode { border: none; margin: 20px 0 12px; padding: 0; min-width: 0; display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .cal-mode { grid-template-columns: 1fr 1fr; } }
.mode-card {
  position: relative; display: flex; flex-direction: column; gap: 4px; cursor: pointer;
  background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius);
  padding: 14px 16px 14px 44px; border: 2px solid transparent;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.mode-card input {
  position: absolute; left: 16px; top: 16px; width: 18px; height: 18px; margin: 0;
  accent-color: var(--accent-fill);
}
.mode-card:has(input:checked) { border-color: var(--accent-fill); background: var(--accent-soft); }
.mode-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode-card input:focus-visible { outline: none; }
.mode-title { font-weight: 650; font-size: 1rem; color: var(--text); }
.mode-desc { font-size: 0.875rem; color: var(--text-muted); }
.mode-preview { display: flex; gap: 6px; margin-top: 6px; min-height: 10px; }

/* Same hues as the week grid (data-color slots from colorSlots). */
.swatch { --h: 25; flex: none; display: inline-block; width: 22px; height: 8px; border-radius: 999px; background: oklch(64% 0.13 var(--h)); }
.swatch-same { background: var(--accent-fill); }
@media (prefers-color-scheme: dark) { .swatch { background: oklch(74% 0.14 var(--h)); } .swatch-same { background: var(--accent); } }

.subject-list { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 8px; }
.subject-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius); padding: 10px 12px 10px 14px;
}
.subject-name { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 200px; font-weight: 600; font-size: 0.9375rem; }
.subject-name .swatch { width: 12px; height: 12px; }
.subject-actions { display: grid; grid-template-columns: repeat(3, auto); gap: 6px; }
@media (max-width: 559px) { .subject-actions { grid-template-columns: repeat(3, 1fr); width: 100%; } }
.mini-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 6px 12px;
  border-radius: 999px; background: var(--fill); color: var(--accent); font-weight: 600; font-size: 0.8125rem;
  text-decoration: none; white-space: nowrap; transition: background-color var(--dur) var(--ease);
}
.mini-btn:hover { background: var(--fill-strong); text-decoration: none; }
@media (max-width: 380px) { .mini-btn { padding: 6px 6px; font-size: 0.75rem; } }
