/* The class rep tool. Same family as the public calendar page
   (docs/assets/calendar.css): Geist, near-black ink on light grey with white
   panels, and the year groups' colours as the signed-in calendar's accent. */

/* Geist (SIL Open Font License 1.1 - see fonts/OFL.txt), served from the tool
   itself: the CSP allows fonts from 'self' only. Latin and latin-ext subsets;
   other scripts fall back to the system font. */
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/geist-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/geist-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light dark;
  --bg: #f2f2f2;
  --surface: #ffffff;
  --surface-muted: #fafafa;
  --fg: #171717;
  --fg-soft: #404040;
  --muted: #595959;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --control-border: #949494;
  --chip-bg: #f0f0f0;
  --ink: #171717;
  --ink-fg: #ffffff;
  --focus: #0070f3;
  --link: #1a5fb4;
  --error: #b3261e;
  --error-bg: #fde8e7;
  --error-fg: #8f1d17;
  --success-bg: #e7f4ec;
  --success-fg: #14532d;
  --warning: #d98a00;
  --warning-bg: #fff1d6;
  --warning-fg: #7a4a00;
  --info-bg: #f4f6fb;
  --info-fg: #2b3445;
  --moved-bg: #e3edfb;
  --moved-fg: #183f73;
  --shadow-open: 0 4px 16px -8px rgba(0, 0, 0, 0.18);
  --accent: var(--ink);
}

/* Dark: the device's setting, unless someone chose light with the toggle
   (page/theme.ts sets data-theme on <html>), or dark when chosen. The same
   tokens twice, as on the public page - CSS can't share one block between a
   media query and a selector. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214;
    --surface: #1c1c1f;
    --surface-muted: #19191c;
    --fg: #ededed;
    --fg-soft: #d0d0d0;
    --muted: #a3a3a3;
    --border: #2e2e33;
    --border-strong: #3a3a40;
    --control-border: #6b6b73;
    --chip-bg: #2a2a2f;
    --ink: #ededed;
    --ink-fg: #121214;
    --focus: #4c9bff;
    --link: #8cb8ff;
    --error: #ff7b72;
    --error-bg: #3a1d1c;
    --error-fg: #ffb4ad;
    --success-bg: #15301f;
    --success-fg: #9be0b2;
    --warning: #f0b35a;
    --warning-bg: #33280f;
    --warning-fg: #f6cd85;
    --info-bg: #1e2433;
    --info-fg: #c9d3ea;
    --moved-bg: #1d2a40;
    --moved-fg: #b5ccf2;
    --shadow-open: 0 4px 16px -8px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #121214;
  --surface: #1c1c1f;
  --surface-muted: #19191c;
  --fg: #ededed;
  --fg-soft: #d0d0d0;
  --muted: #a3a3a3;
  --border: #2e2e33;
  --border-strong: #3a3a40;
  --control-border: #6b6b73;
  --chip-bg: #2a2a2f;
  --ink: #ededed;
  --ink-fg: #121214;
  --focus: #4c9bff;
  --link: #8cb8ff;
  --error: #ff7b72;
  --error-bg: #3a1d1c;
  --error-fg: #ffb4ad;
  --success-bg: #15301f;
  --success-fg: #9be0b2;
  --warning: #f0b35a;
  --warning-bg: #33280f;
  --warning-fg: #f6cd85;
  --info-bg: #1e2433;
  --info-fg: #c9d3ea;
  --moved-bg: #1d2a40;
  --moved-fg: #b5ccf2;
  --shadow-open: 0 4px 16px -8px rgba(0, 0, 0, 0.6);
}

:root[data-theme="light"] {
  color-scheme: light;
}

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

/* The signed-in calendar's colour - the public page's palette, by year group
   key (set on #app-section by login.ts). Whole School is the page ink. */
.app[data-hue="reception"] { --accent: #2a78d6; }
.app[data-hue="year1"] { --accent: #eb6834; }
.app[data-hue="year2"] { --accent: #1baf7a; }
.app[data-hue="year3"] { --accent: #eda100; }
.app[data-hue="year4"] { --accent: #e87ba4; }
.app[data-hue="year5"] { --accent: #008300; }
.app[data-hue="year6"] { --accent: #4a3aa7; }
.app[data-hue="fosps"] { --accent: #e34948; }
.app[data-hue="whole-school"] { --accent: var(--ink); }

/* The selected tab's underline: the accent, or a deeper shade of it where the
   public page's colour is too faint against the light grey page (under 3:1).
   Dark mode's backgrounds are dark enough for all of them. */
.app { --accent-line: var(--accent); }
.app[data-hue="year1"] { --accent-line: #c84e1f; }
.app[data-hue="year2"] { --accent-line: #14875f; }
.app[data-hue="year3"] { --accent-line: #a87000; }
.app[data-hue="year4"] { --accent-line: #c4527f; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .app { --accent-line: var(--accent); }
}

:root[data-theme="dark"] .app { --accent-line: var(--accent); }

* {
  box-sizing: border-box;
}

/* The tool toggles `hidden` on elements that also have their own `display`,
   and an author `display` beats the UA's [hidden] rule - so without this a
   "hidden" label (Repeat until, say) stayed visible. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--link);
}

h1,
h2,
h3 {
  margin: 0;
}

p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.spacer {
  flex-grow: 1;
}

.hint {
  color: var(--muted);
  font-size: 14px;
}

.error {
  color: var(--error);
  font-size: 14px;
}

/* --- Form controls ---------------------------------------------------------- */

input,
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: 8px;
  padding: 0 12px;
  min-height: 40px;
}

textarea {
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.45;
}

/* iOS Safari gives date/time inputs an intrinsic minimum width that ignores
   width: 100% (so they overflow their container) and centres their value. */
input[type="date"],
input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
}

input::-webkit-date-and-time-value {
  text-align: left;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  padding: 0;
  flex: none;
  accent-color: var(--ink);
}

/* A label wrapping its control: the label text above, the control below. */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-soft);
}

.optional {
  font-weight: 400;
  color: var(--muted);
}

/* The day of the week under a date box (see addWeekdayHints() in cardState.ts). */
.weekday {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

/* No date, no weekday - and no gap where it would be. */
.weekday:empty {
  display: none;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--fg);
  cursor: pointer;
}

/* --- Buttons ---------------------------------------------------------------- */

button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--ink);
  color: var(--ink-fg);
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.secondary-button {
  background: var(--surface);
  border-color: var(--control-border);
  color: var(--fg);
  font-weight: 500;
}

.danger-button {
  background: var(--surface);
  border-color: var(--error);
  color: var(--error);
  font-weight: 500;
}

.danger-button.confirm,
.secondary-button.confirm {
  background: var(--error);
  border-color: var(--error);
  color: #ffffff;
}

.small-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  padding: 0;
  background: var(--surface);
  border-color: var(--control-border);
  color: var(--fg);
}

/* --- Site header ------------------------------------------------------------ */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  flex-grow: 1;
}

.header-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  text-decoration: none;
  min-height: 44px;
}

.header-link:hover {
  text-decoration: underline;
}

/* Light / dark switch (page/theme.ts): the icon for the mode it's in. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 40px;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  flex: none;
}

.theme-toggle:hover {
  background: var(--chip-bg);
  color: var(--fg);
}

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

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

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

  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: none;
  }
}

/* --- Sign in ---------------------------------------------------------------- */

.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 48px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 48px -24px rgba(0, 0, 0, 0.25);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* The school crest, as on the public page (docs/assets/crest.svg). */
.login-crest {
  display: block;
  width: auto;
  height: 48px;
  flex: none;
}

.brand-crest {
  display: block;
  width: auto;
  height: 28px;
  flex: none;
}

.login-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.login-intro {
  color: var(--fg-soft);
}

.login-card input,
.login-card select {
  min-height: 44px;
}

.login-button {
  min-height: 46px;
  font-size: 15px;
}

.login-footer {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* --- Signed in -------------------------------------------------------------- */

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 96px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.calendar-heading {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.logout-link {
  align-self: flex-start;
  min-height: 44px;
  padding: 0 4px;
  border: none;
  background: none;
  color: var(--link);
  font-weight: 500;
}

.logout-link:hover {
  text-decoration: underline;
}

.logout-link.confirm {
  color: var(--error);
}

.calendar-heading-text {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.calendar-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.calendar-heading h1 {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.calendar-counts {
  color: var(--muted);
  font-size: 14px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-strong);
}

.tabs [role="tab"] {
  min-height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-short {
  display: none;
}

.tabs [role="tab"][aria-selected="true"] {
  color: var(--fg);
  font-weight: 600;
  border-bottom-color: var(--accent-line);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-title {
  font-size: 17px;
  font-weight: 600;
}

.notice {
  color: var(--muted);
  font-size: 14px;
}

.notice-dismiss {
  min-height: 32px;
  padding: 0 4px;
  border: none;
  background: none;
  color: var(--fg-soft);
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
}

.banner-success {
  background: var(--success-bg);
  color: var(--success-fg);
}

.banner-icon {
  flex: none;
}

#existing-status-text {
  flex-grow: 1;
}

.banner-action {
  min-height: 32px;
  padding: 0 4px;
  border: none;
  background: none;
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.info,
.warning {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.info {
  background: var(--info-bg);
  color: var(--info-fg);
}

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

.warning p + p {
  margin-top: 6px;
}

/* --- Search and filter ------------------------------------------------------ */

.event-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.search {
  position: relative;
  flex: 1 1 240px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search input {
  padding-left: 38px;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--chip-bg);
}

.segmented button {
  min-height: 34px;
  padding: 0 14px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--fg-soft);
  font-weight: 500;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--fg);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* --- Event list ------------------------------------------------------------- */

.event-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.month-heading {
  margin: 12px 0 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.month-heading:first-child {
  margin-top: 0;
}

.empty {
  padding: 24px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}

.past-events {
  margin-top: 4px;
}

.past-events > summary {
  display: list-item;
  padding: 12px 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-soft);
}

.past-events[open] > summary {
  margin-bottom: 8px;
}

#past-cards .event-card {
  opacity: 0.85;
}

/* --- Event cards ------------------------------------------------------------ */

.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.event-card:has(.card-summary[aria-expanded="true"]),
#draft-cards .event-card {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-open);
}

/* A saved event's folded summary: date tile, title and when, badges. */
.card-summary {
  width: 100%;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 20px;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  min-height: 0;
  border: none;
  border-radius: 12px;
  background: none;
  color: var(--fg);
  font-weight: 400;
  text-align: left;
}

.card-summary .chevron {
  color: var(--muted);
  transition: transform 0.15s;
}

.card-summary[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.date-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.date-tile-strip {
  align-self: stretch;
  height: 4px;
  background: var(--accent);
}

/* The school's own events take the "everyone" ink, as on the public page. */
.date-tile.is-school .date-tile-strip {
  background: var(--ink);
}

.date-tile-weekday {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}

.date-tile-day {
  margin-bottom: 6px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
}

.card-summary-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.card-summary-title {
  font-size: 16px;
  font-weight: 600;
}

.card-summary-when {
  font-size: 14px;
  color: var(--muted);
}

.card-summary-badges,
.card-summary-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-summary-badges:has(.card-summary-tags:empty):has(.card-summary-unsaved[hidden]) {
  display: none;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--fg-soft);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.badge-outline {
  padding: 1px 7px;
  background: none;
  border: 1px solid var(--border-strong);
}

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

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

.badge-moved {
  background: var(--moved-bg);
  color: var(--moved-fg);
}

.card-draft-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

/* A draft left out as already in the calendar: folded to its header and a
   note saying what it repeats. */
.card-already-listed {
  margin: 0;
  padding: 12px 20px;
  background: var(--warning-bg);
  color: var(--warning-fg);
  font-size: 14px;
}

.event-card.is-already-listed .card-draft-header {
  border-bottom: none;
}

.card-summary:not([hidden]) + .card-draft-header + .card-body,
.card-summary:not([hidden]) + .card-body {
  border-top: 1px solid var(--border);
}

.card-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  padding: 20px;
}

.span-2 {
  grid-column: 1 / -1;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.card-actions:not(:has(button:not([hidden]))) {
  display: none;
}

.card-unsaved {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--warning-fg);
}

.card-unsaved::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}

.card-status:empty {
  display: none;
}

/* --- Exceptions ------------------------------------------------------------- */

.exceptions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}

.exceptions-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

.exceptions-heading h3 {
  font-size: 14px;
  font-weight: 600;
}

.exceptions-heading .hint {
  font-size: 13px;
}

.exceptions-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.exceptions-list:empty {
  display: none;
}

.exception-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 8px 12px;
  font-size: 14px;
}

.exception-row + .exception-row {
  border-top: 1px solid var(--border);
}

.exception-text {
  flex-grow: 1;
}

.exception-row-scope {
  color: var(--muted);
  font-size: 13px;
}

.exception-remove-button {
  min-height: 32px;
  padding: 0 4px;
  border: none;
  background: none;
  color: var(--error);
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline;
}

.exceptions-unsaved {
  font-size: 13px;
  color: var(--warning-fg);
}

.exception-add-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.exception-grid {
  align-self: stretch;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 12px;
}

/* --- Correcting a school event's date -------------------------------------- */

.date-correction {
  border-top: 1px solid var(--border);
}

.date-correction > summary {
  display: list-item;
  padding: 12px 20px;
  cursor: pointer;
  font-size: 14px;
  color: var(--fg-soft);
}

.date-correction-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 20px 20px;
}

/* A timed correction: the date on its own row, then start and end side by
   side - not a date and a start time with the end time left alone below. */
.correction-timed {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.correction-timed > :first-child {
  grid-column: 1 / -1;
}

.correction-confirm {
  font-weight: 600;
}

.correction-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* --- Adding events ---------------------------------------------------------- */

.paste-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.paste-panel .hint {
  margin-top: 2px;
}

.paste-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.drafts-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-top: 8px;
}

.save-bar {
  position: sticky;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--ink-fg);
  box-shadow: 0 16px 32px -16px rgba(0, 0, 0, 0.45);
  font-size: 14px;
}

#save-bar-text {
  flex-grow: 1;
}

.save-bar button {
  background: var(--ink-fg);
  color: var(--ink);
}

/* --- What's on this week ---------------------------------------------------- */

.week-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

#week-list-output {
  line-height: 1.5;
}

.week-copy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.week-emoji {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

/* --- Share ------------------------------------------------------------------ */

.share-intro {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* The subscribe count: two numbers and the split by app, as tiles. */
.share-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(0, 2fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--border);
}

.share-stats[hidden] {
  display: none;
}

.share-stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 14px 16px;
  background: var(--surface);
}

.share-stat-number {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.share-stat-label {
  font-size: 13px;
  color: var(--muted);
}

.share-stat-apps {
  gap: 8px;
}

.share-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.share-platforms .badge {
  font-variant-numeric: tabular-nums;
}

.share-stats-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 16px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 13px;
}

.share-empty {
  margin: 0;
  padding: 14px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--muted);
  font-size: 14px;
}

/* The message and the QR code side by side; stacked on a phone. */
.share-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 248px;
  gap: 16px;
  align-items: start;
}

.share-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.share-card-title {
  font-size: 15px;
  font-weight: 600;
}

.share-message-field {
  display: block;
}

.share-message-field textarea {
  display: block;
  /* Grows to fit the message, so the link at the end is never cut off on a
     phone; browsers without field-sizing keep the rows from index.html. */
  field-sizing: content;
  min-height: 120px;
  line-height: 1.5;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.share-status {
  font-size: 13px;
  color: var(--muted);
}

.share-qr-card {
  align-items: center;
  text-align: center;
}

.share-qr-card .share-card-title {
  align-self: flex-start;
}

/* Always black on white, in dark mode too - scanners need the contrast. */
.share-qr {
  width: 100%;
  max-width: 208px;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.share-qr svg {
  display: block;
  width: 100%;
  height: auto;
}

/* The link the code opens, as plain selectable text. */
.share-link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  text-overflow: ellipsis;
}

.share-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.share-qr-card button {
  width: 100%;
}

@media (max-width: 720px) {
  .share-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .share-qr-card {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .share-qr-card .share-card-title {
    flex-basis: 100%;
    text-align: left;
  }

  .share-qr {
    max-width: 180px;
  }
}

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

  .share-stat-apps {
    grid-column: 1 / -1;
  }
}

/* --- Phones ----------------------------------------------------------------- */

@media (max-width: 560px) {
  .site-header-inner,
  .app {
    padding-left: 16px;
    padding-right: 16px;
  }

  .app {
    padding-top: 20px;
  }

  /* iOS Safari zooms the page into any control under 16px when it's focused,
     pushing the header off the screen. */
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .calendar-heading h1 {
    font-size: 26px;
  }

  .tab-long {
    display: none;
  }

  .tab-short {
    display: inline;
  }

  .tabs [role="tab"] {
    padding: 0 10px;
  }

  .card-summary {
    grid-template-columns: 48px minmax(0, 1fr) 20px;
    gap: 12px;
    padding: 12px;
  }

  .date-tile-day {
    font-size: 20px;
  }

  .card-fields {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }

  .card-actions,
  .card-draft-header {
    padding: 12px 16px;
  }

  .date-correction > summary,
  .date-correction-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .login-card {
    padding: 24px;
  }
}

/* An event's poster: a thumbnail (tap for full size) beside its buttons. See
   page/poster.ts. */
.poster-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.poster-thumb {
  display: block;
  line-height: 0;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  overflow: hidden;
}

.poster-thumb img {
  display: block;
  max-width: 120px;
  max-height: 160px;
  object-fit: contain;
}

.poster-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.poster-status:empty {
  display: none;
}

/* A poster full size (openPosterDialog() in page/poster.ts): as big as the
   screen allows, the whole poster always in view. */
.poster-dialog {
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.poster-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.poster-dialog img {
  display: block;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  object-fit: contain;
}

.poster-dialog-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  font-size: 24px;
  line-height: 1;
}
