:root {
  /* Day theme: soft sky + warm paper */
  --bg: #e8f0f7;
  --bg-gradient: linear-gradient(
    165deg,
    #dbeafe 0%,
    #f0f9ff 35%,
    #fffbeb 70%,
    #fefce8 100%
  );
  --surface: #ffffff;
  --surface2: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0284c7;
  --separator: #cbd5e1;
  /* Icon / photo tiles: white so PNGs with white matte blend cleanly */
  --icon-well: #ffffff;
  --chip: var(--icon-well);
  --chip-border: var(--separator);
  --radius: 0;
  --radius-btn: 0;
  --space-1: 0.375rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --font: "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-gradient);
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

html {
  height: 100%;
}

body.page--kiosk {
  min-height: 100%;
  min-height: 100dvh;
  height: 100%;
  display: flex;
  flex-direction: column;
}

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

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) calc(var(--space-4) * 1.5);
}

.page.page--kiosk {
  max-width: none;
  margin: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  padding: max(var(--space-2), env(safe-area-inset-top))
    max(var(--space-2), env(safe-area-inset-right))
    max(var(--space-2), env(safe-area-inset-bottom))
    max(var(--space-2), env(safe-area-inset-left));
  /* Share vertical space across rows (slots scale with window height) */
  --kiosk-slot-today: clamp(3rem, calc((100dvh - 9rem) / 5.5), 42vh);
  --kiosk-slot-side: clamp(2.25rem, calc((100dvh - 9rem) / 7.5), 28vh);
  --kiosk-meta-today: clamp(2.25rem, calc((100dvh - 9rem) / 12), 5rem);
}

#root {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

.page--kiosk .kiosk-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

.page--kiosk .kiosk-schedule-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page--kiosk .schedule-wrap.kiosk-schedule-wrap {
  padding: var(--space-1);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.toolbar h1 {
  margin: 0;
  font-size: 1.25rem;
  flex: 1 1 auto;
}

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

.btn {
  appearance: none;
  border-radius: var(--radius-btn);
  padding: var(--space-2) var(--space-4);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--separator);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.btn:hover {
  background: #f1f5f9;
}

.btn--primary {
  background: var(--accent);
  color: #ffffff;
  border-color: #0369a1;
}

.btn--primary:hover {
  background: #0369a1;
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--separator);
}

.week-label {
  min-width: 10rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

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

.status {
  font-size: 0.85rem;
  color: var(--muted);
}

.status--error {
  color: #b91c1c;
}

.status--ok {
  color: #15803d;
}

.schedule-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: var(--space-2);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
}

.schedule {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 640px;
}

.schedule th,
.schedule td {
  padding: var(--space-2) var(--space-2);
  vertical-align: middle;
  border-bottom: 1px solid var(--separator);
}

.schedule th {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.schedule th.day-today {
  color: #0369a1;
}

.schedule .row-label {
  width: 7rem;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.schedule .row-label--meta {
  color: var(--text);
  font-size: 1rem;
}

.page--admin .row-label--drop {
  cursor: copy;
  min-height: 2.75rem;
  vertical-align: middle;
  border: 1px dashed var(--separator);
  border-radius: var(--radius);
  background: rgba(241, 245, 249, 0.9);
  font-size: 0.9rem;
}

.page--admin .admin-hint {
  margin: 0 0 var(--space-3);
  font-size: 0.8rem;
  color: var(--muted);
}

/* One hairline between meta (Tuli/Guests) and slot rows — avoid double border with guest row */
.schedule tbody tr:has(+ tr.row-separator) td {
  border-bottom: none;
}

.schedule tr.row-separator td {
  padding: 0;
  height: 0;
  line-height: 0;
  font-size: 0;
  border: none;
  border-top: 1px solid var(--separator);
  background: transparent;
}

.cell {
  min-height: 3.25rem;
  min-width: 4.5rem;
}

.cell--tuli {
  min-height: 3.5rem;
}

.cell--guests {
  min-height: 4rem;
}

.drop-zone {
  min-height: 3rem;
  border-radius: var(--radius);
  background: var(--icon-well);
  border: 1px solid var(--chip-border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  transition: border-color 0.15s, background 0.15s;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* Morning / Nap / Afternoon: same row height with or without an icon */
.schedule tr.slot-row td.cell.schedule-slot {
  vertical-align: middle;
}

.page--kiosk .schedule tr.slot-row td.cell.schedule-slot {
  padding: var(--space-2);
}

.drop-zone.slot-slot {
  box-sizing: border-box;
  width: 100%;
  min-height: 4rem;
  height: 4rem;
  padding: 0;
  overflow: hidden;
  align-items: stretch;
  justify-content: stretch;
}

/* Icon fills the slot (tile), not a small circle inside */
.drop-zone.slot-slot > .icon-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  min-width: 0;
  min-height: 0;
  border-radius: var(--radius);
  border: none;
  box-shadow: none;
  font-size: clamp(1.75rem, 5vmin, 2.75rem);
}

.drop-zone.slot-slot > .icon-chip .chip-img {
  border-radius: inherit;
}

.drop-zone.slot-slot > .empty-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 4rem;
  width: 100%;
}

.page--kiosk .drop-zone.slot-slot {
  /* Glyphs often exceed the font box; hidden clips tops/bottoms of emoji */
  overflow: visible;
  padding: min(0.35rem, 2.5%);
  box-sizing: border-box;
}

.page--kiosk .drop-zone.slot-slot > .icon-chip {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: visible;
  padding: 0.1em 0.14em;
  box-sizing: border-box;
}

.page--kiosk .drop-zone.slot-slot > .icon-chip .emoji {
  display: block;
  line-height: 1;
  overflow: visible;
}

.page--kiosk .drop-zone.slot-slot > .empty-hint {
  min-height: 100%;
  font-size: clamp(1rem, 4vw, 1.35rem);
}

.drop-zone--fixed {
  cursor: default;
  touch-action: auto;
}

.page--admin .drop-zone--fixed:hover {
  border-color: transparent;
}

.page--admin .drop-zone.sortable-ghost {
  opacity: 0.45;
}

.page--admin .drop-zone.sortable-drag {
  opacity: 0.9;
}

.page--admin .drop-zone:hover {
  border-color: var(--accent);
}

.guests {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  border-radius: var(--radius);
  background: var(--icon-well);
  padding: var(--space-2);
  border: 1px solid var(--chip-border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.page--admin .guests:hover {
  border-color: var(--separator);
}

.icon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius);
  background: var(--icon-well);
  border: 1px solid var(--chip-border);
  font-size: 1.5rem;
  line-height: 1;
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.page--kiosk .icon-chip {
  width: clamp(2.5rem, 8vw, 3.25rem);
  height: clamp(2.5rem, 8vw, 3.25rem);
  font-size: clamp(1.35rem, 5vw, 2rem);
}

.icon-chip:active {
  cursor: grabbing;
}

.icon-chip .emoji {
  pointer-events: none;
}

.icon-chip .chip-img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  padding: 3px;
  box-sizing: border-box;
  border-radius: inherit;
  pointer-events: none;
  display: block;
  background: var(--icon-well);
}

.palette {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--separator);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.palette h2 {
  margin: 0 0 var(--space-3);
  font-size: 1rem;
  color: var(--muted);
}

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

.palette .icon-chip {
  cursor: grab;
}

.empty-hint {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  width: 100%;
  pointer-events: none;
}

.page--kiosk .empty-hint {
  font-size: clamp(0.7rem, 2.5vw, 0.85rem);
}

/* Kiosk: 3-day strip — today column emphasized without heavy column borders */
.page--kiosk .schedule.kiosk-3day {
  table-layout: fixed;
  width: 100%;
  max-width: min(44rem, 100%);
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  height: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.page--kiosk .kiosk-col-label {
  width: 6.5rem;
  min-width: 6.5rem;
}

.page--kiosk .kiosk-col-past {
  width: 21%;
}

.page--kiosk .kiosk-col-today {
  width: 58%;
}

.page--kiosk .kiosk-col-future {
  width: 21%;
}

/* Side headers: no uppercase (fits “Yesterday” / “Tomorrow”), room to wrap on narrow screens */
.page--kiosk .schedule.kiosk-3day thead th {
  text-transform: none;
  letter-spacing: 0.02em;
}

.page--kiosk .kiosk-col-heading {
  display: block;
  line-height: 1.15;
  max-width: 100%;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.page--kiosk a.kiosk-col-heading--today,
.page--kiosk a.kiosk-col-heading--today:visited {
  color: #0369a1;
  text-decoration: none;
}

.page--kiosk a.kiosk-col-heading--today:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.page--kiosk .kiosk-col-heading--today {
  font-size: clamp(1.65rem, 7.5vw, 2.5rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #0369a1;
}

.page--kiosk .schedule th.day-col--past .kiosk-col-heading,
.page--kiosk .schedule th.day-col--future .kiosk-col-heading {
  font-size: clamp(0.85rem, 3.6vw, 1.05rem);
  font-weight: 700;
  color: #94a3b8;
}

.page--kiosk .schedule th.day-col--today {
  padding: 0.5rem 0.45rem 0.6rem;
  vertical-align: middle;
  background: #f0f9ff;
  border: none;
  box-shadow: none;
}

.page--kiosk .schedule th.day-col--past,
.page--kiosk .schedule th.day-col--future {
  padding: 0.45rem 0.2rem;
  background: #f1f5f9;
  border: none;
  box-shadow: none;
}

.page--kiosk .schedule td.day-col--today {
  padding: 0.4rem 0.45rem;
  background: #f0f9ff;
  border: none;
  box-shadow: none;
}

.page--kiosk .schedule td.day-col--past,
.page--kiosk .schedule td.day-col--future {
  padding: 0.35rem 0.25rem;
  background: #f1f5f9;
  border: none;
  box-shadow: none;
}

/* Inner cards: solid white wells + light border (photos with white matte read clean) */
.page--kiosk .drop-zone,
.page--kiosk .guests {
  background: var(--icon-well);
}

.page--kiosk .day-col--today .drop-zone,
.page--kiosk .day-col--today .guests {
  border: 1px solid var(--separator);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.page--kiosk .day-col--past .drop-zone,
.page--kiosk .day-col--future .drop-zone,
.page--kiosk .day-col--past .guests,
.page--kiosk .day-col--future .guests {
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.page--kiosk .icon-chip,
.page--kiosk .icon-chip .chip-img {
  background: var(--icon-well);
}

/* Emoji / ZWJ sequences draw outside the em-box; avoid clipping in kiosk */
.page--kiosk .icon-chip {
  overflow: visible;
}

.page--kiosk .icon-chip .emoji {
  line-height: 1;
  overflow: visible;
}

.page--kiosk .day-col--today .drop-zone.slot-slot {
  min-height: var(--kiosk-slot-today);
  height: var(--kiosk-slot-today);
  border-color: var(--separator);
}

.page--kiosk .day-col--past .drop-zone.slot-slot,
.page--kiosk .day-col--future .drop-zone.slot-slot {
  min-height: var(--kiosk-slot-side);
  height: var(--kiosk-slot-side);
}

.page--kiosk .day-col--today .cell--tuli .drop-zone:not(.slot-slot),
.page--kiosk .day-col--today .cell--guests .guests {
  min-height: var(--kiosk-meta-today);
}

/* Slightly conservative caps so glyphs + padding fit; overflow visible catches ink */
.page--kiosk .day-col--today .drop-zone.slot-slot > .icon-chip {
  font-size: clamp(2.25rem, 11vmin, 4rem);
}

.page--kiosk .day-col--past .drop-zone.slot-slot > .icon-chip,
.page--kiosk .day-col--future .drop-zone.slot-slot > .icon-chip {
  font-size: clamp(1.45rem, 6.5vmin, 2.35rem);
}

.page--kiosk .day-col--today .drop-zone:not(.slot-slot) .icon-chip {
  width: clamp(3.25rem, 14vw, 5rem);
  height: clamp(3.25rem, 14vw, 5rem);
  font-size: clamp(1.65rem, 6vw, 2.5rem);
  border-width: 1px;
  border-color: var(--separator);
}

.page--kiosk .schedule.kiosk-3day tbody td {
  overflow: visible;
}

.page--kiosk .schedule .row-label--slot {
  white-space: normal;
  text-align: center;
  vertical-align: middle;
}

.page--kiosk .schedule .row-label__stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.15rem 0;
}

.page--kiosk .schedule .row-label__emoji {
  font-size: clamp(1.85rem, 5.5vmin, 2.75rem);
  line-height: 1;
  overflow: visible;
  padding: 0.08em 0;
}

.page--kiosk .schedule .row-label__words {
  display: block;
  font-size: clamp(0.72rem, 2.1vw, 0.88rem);
  font-weight: 700;
  color: var(--muted);
  line-height: 1.15;
}

.page--kiosk .schedule .row-label--meta.row-label--slot .row-label__words {
  color: var(--text);
}
