/* ---------- Tokens ---------- */
:root {
  --bg: #E9ECE5;
  --surface: #FFFFFF;
  --surface-2: #F4F6F1;
  --cell: #FFFFFF;
  --ink: #1B2420;
  --muted: #5B6862;
  --line: #D3D9CF;
  --line-strong: #B9C2B5;
  --today: #EDF3E8;
  --break: #E2E6DD;
  --bell: #E3A92B;
  --bell-soft: #F7E3B2;
  --bell-ink: #3A2A00;
  --danger: #B3261E;
  --shadow: 0 1px 2px rgb(20 30 25 / .08), 0 8px 24px rgb(20 30 25 / .08);

  --f-display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --f-body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, monospace;
  --f-note: "Patrick Hand", "Comic Sans MS", "Chalkboard SE", cursive;

  --timecol: 100px;
  --rowh: 64px;
  --radius: 8px;
  --frame: var(--line);
  --dim: #DCE0D8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17201D;
    --surface: #1F2B27;
    --surface-2: #25332E;
    --cell: #1F2B27;
    --ink: #EEF1EA;
    --muted: #9DABA4;
    --line: #33423C;
    --line-strong: #46574F;
    --today: #243630;
    --break: #1A2521;
    --dim: #111916;
    --bell-soft: #4A3A12;
    --bell-ink: #2A1E00;
    --danger: #F2B8B5;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17201D;
  --surface: #1F2B27;
  --surface-2: #25332E;
  --cell: #1F2B27;
  --ink: #EEF1EA;
  --muted: #9DABA4;
  --line: #33423C;
  --line-strong: #46574F;
  --today: #243630;
  --break: #1A2521;
  --dim: #111916;
  --bell-soft: #4A3A12;
  --bell-ink: #2A1E00;
  --danger: #F2B8B5;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
  color-scheme: dark;
}

/* Teacher Cris: colors taken from the logo — parchment, navy, gold, burnt orange */
:root[data-theme="cris"] {
  --bg: #E9DAC0;
  --surface: #FBF6EC;
  --surface-2: #F3EADA;
  --cell: #FBF6EC;
  --ink: #1D2F5E;
  --muted: #6A5536;
  --line: #DCCBAA;
  --line-strong: #C4AC80;
  --today: #F6E9C8;
  --break: #EFE2C9;
  --dim: #DDCDB0;
  --bell: #A94F0C;
  --bell-soft: #F3D9BC;
  --bell-ink: #FFFFFF;
  --frame: #B8872A;
  --danger: #A3261E;
  --shadow: 0 1px 2px rgb(60 40 10 / .12), 0 8px 24px rgb(60 40 10 / .12);
  color-scheme: light;
}
:root[data-theme="cris"] body { background: linear-gradient(160deg, #EFE3CC, #E3D1B2); }
:root[data-theme="cris"] .grid { border-width: 2px; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 var(--f-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--bell); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); margin: 0 0 12px; }
.small { font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap; font-weight: 700; font-size: 14px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: var(--surface-2); }
a.btn { text-decoration: none; }
.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: min(380px, 100%); background: var(--surface); border-radius: 14px;
  padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px;
}
.site-mark { display: flex; align-items: center; gap: 10px; font: 800 22px/1 var(--f-display); letter-spacing: .04em; text-transform: uppercase; }
.site-mark img { border-radius: 10px; }
.auth-form { display: grid; gap: 14px; }
.auth-foot { margin: 0; font-size: 14px; color: var(--muted); }
.auth-title { font: 800 34px/1 var(--f-display); margin: 6px 0 0; letter-spacing: .01em; }
.auth-help { margin: 0; color: var(--muted); }

/* ---------- Fields ---------- */
.field { display: grid; gap: 5px; margin: 0; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 700; font-size: 13px; }
.field small { font-weight: 400; color: var(--muted); display: block; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
}
.field textarea { resize: vertical; min-height: 76px; }
.field.inline { display: inline-flex; align-items: center; gap: 6px; }
.field.inline input { width: 70px; min-height: 34px; padding: 4px 8px; }
.form-error { color: var(--danger); margin: 0; min-height: 0; font-size: 14px; }
.form-error:empty { display: none; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

/* ---------- App shell ---------- */
.shell { max-width: 1480px; margin: 0 auto; padding: 16px 20px 32px; }
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; min-width: 0; color: inherit; text-decoration: none; border-radius: var(--radius); }
.brand-logo { width: 52px; height: 52px; object-fit: contain; flex: none; }
.brand-text { display: grid; min-width: 0; }
.brand-title { font: 700 13px/1.2 var(--f-body); color: var(--muted); letter-spacing: .02em; }
.week-label { font: 800 30px/1.05 var(--f-display); letter-spacing: .01em; margin: 0; }
.nav { display: flex; gap: 6px; align-items: center; }
.save-state { font-size: 12px; color: var(--muted); min-width: 60px; text-align: right; }
.save-state.error { color: var(--danger); font-weight: 700; }

/* Now / next strip */
.bell-strip {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.bell-card {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); min-width: 0;
}
.bell-card.now { background: var(--bell); border-color: var(--bell); color: var(--bell-ink); }
.bell-card .tag { font: 500 11px/1 var(--f-mono); text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.bell-card .what { font: 800 20px/1.1 var(--f-display); letter-spacing: .01em; }
.bell-card .when { font: 500 13px/1 var(--f-mono); }

/* ---------- The grid ---------- */
.grid {
  display: grid;
  grid-template-columns: var(--timecol) repeat(var(--days), minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--frame); border-radius: 12px; overflow: hidden;
  position: relative;
}
.g-head {
  padding: 10px 10px 8px; border-bottom: 1px solid var(--line-strong);
  border-left: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: baseline; gap: 8px;
}
.g-head.corner { border-left: 0; }
.g-head .dow { font: 800 20px/1 var(--f-display); letter-spacing: .03em; text-transform: uppercase; }
.g-head .dnum { font: 500 13px/1 var(--f-mono); color: var(--muted); }
.g-head.is-today { background: var(--ink); color: var(--bg); }
.g-head.is-today .dnum { color: inherit; opacity: .75; }

.g-time {
  padding: 8px 10px; border-top: 1px solid var(--line);
  display: grid; align-content: start; gap: 2px;
}
.g-time .t-label { font-weight: 700; font-size: 13px; }
.g-time .t-range { font: 500 12px/1.2 var(--f-mono); color: var(--muted); white-space: nowrap; }
.g-time.is-break { display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; padding: 4px 10px; background: var(--break); }
.g-time.is-break .t-label { font-size: 12px; color: var(--muted); }
.g-time.is-break .t-range { font-size: 11px; }
.g-time.is-now { box-shadow: inset 4px 0 0 var(--bell); }
.g-time.is-now .t-label::after { content: " · now"; color: var(--bell); }

.g-cell {
  border-top: 1px solid var(--line); border-left: 1px solid var(--line);
  background: transparent; padding: 0; margin: 0; min-height: var(--rowh);
  cursor: pointer; position: relative;
  border-right: 0; border-bottom: 0; border-radius: 0;
}
.g-cell.is-break { min-height: 28px; background: var(--break); }
.g-cell.is-today { background: var(--today); }
.g-cell.is-break.is-today { background: var(--break); }
.g-cell:hover::after, .g-cell:focus-visible::after {
  content: "+"; position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font: 800 22px/1 var(--f-display);
}
.readonly .g-cell { cursor: default; }
.readonly .g-cell:hover::after { content: none; }

/* Entries */
.g-stack { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 3px; min-width: 0; z-index: 1; pointer-events: none; }
.entry {
  pointer-events: auto;
  flex: 1; min-height: 0; min-width: 0;
  display: flex; flex-direction: column; justify-content: flex-start;
  text-align: left; padding: 6px 8px 7px; gap: 1px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--cell); color: var(--ink); cursor: pointer; overflow: hidden;
}
.entry.has-color { border-color: rgb(0 0 0 / .12); }
.entry:hover { filter: brightness(.97); }
.readonly .entry { cursor: default; }
.entry .e-head {
  font: 800 22px/1 var(--f-display); letter-spacing: .01em;
  overflow-wrap: anywhere;
}
.entry .e-head.is-room { font-size: 28px; letter-spacing: .02em; }
.entry .e-body { font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; white-space: pre-line; }
.entry.compact { flex-direction: row; align-items: baseline; gap: 6px; padding: 3px 7px; }
.entry.compact .e-head { font-size: 15px; }
.entry.compact .e-body { font-size: 12px; white-space: normal; }
.entry.allday { justify-content: center; align-items: center; text-align: center; }
.entry.allday .e-head { font-size: 26px; text-transform: uppercase; letter-spacing: .04em; }
.entry.is-now { outline: 3px solid var(--bell); outline-offset: -1px; }

/* ---------- Dialogs ---------- */
dialog.sheet {
  border: 0; padding: 0; border-radius: 14px; width: min(520px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  max-height: calc(100vh - 32px);
}
dialog.sheet.wide { width: min(680px, calc(100vw - 24px)); }
dialog::backdrop { background: rgb(15 22 19 / .5); }
.sheet-body { padding: 18px 20px 20px; display: grid; gap: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font: 800 28px/1 var(--f-display); margin: 0; letter-spacing: .01em; }
.sheet-foot { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.row3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.swatch-row { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 1px solid rgb(0 0 0 / .18); display: grid; place-items: center; font-size: 14px;
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.swatch.none { background: var(--cell); color: var(--muted); }
.repeat { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); }

.set-sec { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.set-sec h3 { margin: 0; font: 800 20px/1 var(--f-display); letter-spacing: .02em; text-transform: uppercase; }
.set-sec .muted { margin: 0; }
.slot-table { display: grid; gap: 6px; }
.slot-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto auto; gap: 6px; align-items: center; }
.slot-row input[type="text"], .slot-row input[type="time"] {
  min-height: 36px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); width: 100%;
}
.slot-row .check { font-weight: 400; font-size: 13px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; min-height: 36px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface-2); font: 500 12px var(--f-mono); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 100; max-width: calc(100vw - 32px); font-weight: 700;
}

/* ---------- Day picker (phones) ---------- */
.daypick { display: none; gap: 6px; margin-bottom: 10px; overflow-x: auto; }
.daypick button {
  flex: 1; min-width: 52px; padding: 6px 4px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer;
  display: grid; gap: 2px; justify-items: center;
}
.daypick .dow { font: 800 16px/1 var(--f-display); text-transform: uppercase; letter-spacing: .04em; }
.daypick .dnum { font: 500 11px/1 var(--f-mono); color: var(--muted); }
.daypick button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.daypick button[aria-pressed="true"] .dnum { color: inherit; }
.daypick button.is-today:not([aria-pressed="true"]) { border-color: var(--bell); box-shadow: inset 0 -3px 0 var(--bell); }

@media (max-width: 760px) {
  .shell { padding: 12px 16px 24px; }
  .week-label { font-size: 24px; }
  .daypick { display: flex; }
  :root { --timecol: 96px; --rowh: 58px; }
  .g-time .t-range { font-size: 11px; }
  .row3 { grid-template-columns: 1fr 1fr; }
  .row3 .field:first-child { grid-column: 1 / -1; }
  .row2 { grid-template-columns: 1fr; }
  .slot-row { grid-template-columns: 1fr 1fr 1fr; }
  .slot-row .slot-name { grid-column: 1 / -1; }
  .topbar .hide-sm { display: none; }
  .brand-logo { width: 40px; height: 40px; }
}

/* ---------- Wallpaper ---------- */
.wallpaper {
  --u: 1vw;
  --h: 100vh;
  --timecol: calc(8.6 * var(--u));
  --rowh: 0px;
  height: var(--h); width: calc(100 * var(--u)); overflow: hidden;
  /* top padding leaves room for the Mac menu bar */
  padding: 34px calc(1.4 * var(--u)) calc(1.2 * var(--u)); display: grid; grid-template-rows: minmax(0, 1fr);
  background: var(--bg);
}
.wallpaper .grid { height: 100%; grid-template-rows: auto; }
.wallpaper .g-cell { min-height: 0; cursor: default; }
.wallpaper .g-cell:hover::after { content: none; }
.wallpaper .g-head .dow { font-size: clamp(16px, calc(1.5 * var(--u)), 30px); }
.wallpaper .g-head .dnum { font-size: clamp(11px, calc(.8 * var(--u)), 16px); }
.wallpaper .g-time .t-label { font-size: clamp(11px, calc(.8 * var(--u)), 16px); }
.wallpaper .g-time .t-range { font-size: clamp(10px, calc(.75 * var(--u)), 15px); }
.wallpaper .entry { padding: calc(.35 * var(--u)) calc(.5 * var(--u)); }
.wallpaper .entry .e-head { font-size: clamp(14px, calc(1.35 * var(--u)), 28px); }
.wallpaper .entry .e-head.is-room { font-size: clamp(18px, calc(1.8 * var(--u)), 38px); }
.wallpaper .entry .e-body { font-size: clamp(10px, calc(.8 * var(--u)), 16px); }
.wallpaper .entry.compact .e-head { font-size: clamp(11px, calc(.95 * var(--u)), 20px); }
.wallpaper .entry.compact .e-body { font-size: clamp(10px, calc(.75 * var(--u)), 15px); }
.wallpaper .entry.allday .e-head { font-size: clamp(16px, calc(1.6 * var(--u)), 34px); }
.wallpaper .g-time.is-now .t-label::after { content: ""; }
.wallpaper.capture { position: fixed; left: -100000px; top: 0; }

/* Logo / name in the grid's top-left corner */
.g-head.corner { justify-content: center; align-items: center; padding: 4px; }
.corner-brand { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; text-align: center; }
.corner-brand img { display: block; height: 44px; width: auto; max-width: 100%; object-fit: contain; }
/* Every header row matches the logo's height so side-by-side weeks line up */
.wallpaper { --headh: clamp(40px, calc(3.8 * var(--u)), 88px); }
.wallpaper:not([data-weeks="1"]) { --headh: clamp(34px, calc(3 * var(--u)), 70px); }
.wallpaper .g-head { height: var(--headh); overflow: hidden; }
.wallpaper .corner-brand img { height: calc(var(--headh) - 8px); }
.corner-name { font: 800 clamp(12px, calc(1 * var(--u, 10px)), 22px)/1 var(--f-display); letter-spacing: .02em; text-transform: uppercase; color: var(--ink); overflow-wrap: anywhere; }

/* Settings: logo + teachers */
.logo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-preview { width: 64px; height: 64px; border-radius: 10px; border: 1px dashed var(--line-strong); display: grid; place-items: center; overflow: hidden; background: var(--surface-2); }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.teacher-list { display: grid; gap: 6px; }
.teacher-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.teacher-name { margin-right: auto; min-width: 0; }
#invite-box { display: grid; gap: 6px; }

/* Side-by-side weeks share the first week's time column */
.grid.no-times .g-time, .grid.no-times .g-head.corner { display: none !important; }

/* Weekends with nothing scheduled */
.g-head.is-dim { color: var(--muted); }
.g-head.is-dim .dow { opacity: .7; }
.g-cell.is-dim, .g-cell.is-dim.is-break { background: var(--dim); }
.g-head.is-dim { background: var(--dim); }

/* Wallpaper: several weeks */
.wallpaper .wp-weeks { display: grid; gap: calc(.9 * var(--u)); min-height: 0; }
.wallpaper .wp-weeks > .grid { height: 100%; min-height: 0; }
.wallpaper[data-weeks="3"] .entry .e-head, .wallpaper[data-weeks="4"] .entry .e-head { font-size: clamp(11px, calc(.95 * var(--u)), 20px); }
.wallpaper[data-weeks="3"] .entry .e-head.is-room, .wallpaper[data-weeks="4"] .entry .e-head.is-room { font-size: clamp(13px, calc(1.2 * var(--u)), 26px); }
.wallpaper[data-weeks="3"] .entry .e-body, .wallpaper[data-weeks="4"] .entry .e-body { font-size: clamp(9px, calc(.65 * var(--u)), 14px); }
.wallpaper[data-weeks="3"] .entry.allday .e-head, .wallpaper[data-weeks="4"] .entry.allday .e-head { font-size: clamp(10px, calc(.8 * var(--u)), 18px); letter-spacing: 0; }
.wallpaper[data-weeks="3"] .g-head .dow, .wallpaper[data-weeks="4"] .g-head .dow { font-size: clamp(12px, calc(1 * var(--u)), 22px); }
.wallpaper[data-weeks="3"] .g-head, .wallpaper[data-weeks="4"] .g-head { padding: 4px 6px; gap: 4px; flex-wrap: wrap; }
.wallpaper[data-weeks="3"] .entry, .wallpaper[data-weeks="4"] .entry { padding: 2px 4px; }
.wallpaper[data-weeks="3"] .g-stack, .wallpaper[data-weeks="4"] .g-stack { padding: 2px; gap: 2px; }
.wallpaper[data-weeks="4"] .g-time, .wallpaper[data-weeks="3"] .g-time { padding: 2px 6px; }
.wallpaper:not([data-weeks="1"]) { --timecol: calc(6.4 * var(--u)); }
.wallpaper:not([data-weeks="1"]) .g-head { padding: 6px 6px 5px; gap: 2px 6px; flex-wrap: wrap; }
.wallpaper:not([data-weeks="1"]) .g-head .dnum { font-size: clamp(9px, calc(.7 * var(--u)), 14px); }
.wallpaper[data-weeks="2"] .entry.allday .e-head { font-size: clamp(12px, calc(1.1 * var(--u)), 24px); letter-spacing: .02em; }
.entry.allday .e-head { overflow-wrap: break-word; }
/* 3–4 weeks: one-line entries and times so everything still fits */
.wallpaper[data-weeks="3"] .entry.compact, .wallpaper[data-weeks="4"] .entry.compact { padding: 0 4px; align-items: center; }
.wallpaper[data-weeks="3"] .entry.compact .e-head, .wallpaper[data-weeks="4"] .entry.compact .e-head { font-size: clamp(10px, calc(.75 * var(--u)), 16px); line-height: 1.1; }
.wallpaper[data-weeks="3"] .entry:not(.allday), .wallpaper[data-weeks="4"] .entry:not(.allday) { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 0 4px; }
.wallpaper[data-weeks="3"] .entry .e-body, .wallpaper[data-weeks="4"] .entry .e-body { white-space: normal; }
.wallpaper[data-weeks="3"] .g-time, .wallpaper[data-weeks="4"] .g-time { display: flex; flex-wrap: wrap; align-items: center; gap: 0 5px; align-content: center; }
.wallpaper[data-weeks="2"] .entry .e-head.is-room { font-size: clamp(16px, calc(1.5 * var(--u)), 32px); }

/* Wallpaper preview toolbar (not shown on the live link or in the image) */
.wp-tools {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  padding: 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow); width: max-content; max-width: calc(100vw - 32px);
}
.wp-tools select { min-height: 36px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.wp-tools .lbl { font-size: 13px; font-weight: 700; padding-left: 4px; }
.wp-tools.hidden-tools { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) { .wp-tools { transition: opacity .25s; } }

/* ---------- View switcher + multi-week + month ---------- */
.subbar { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 12px; }
.subbar .bell-strip { margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 0 12px; min-height: 36px; font: 700 13px var(--f-body); color: var(--ink); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.view-select { display: none; min-height: 38px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); font-weight: 700; }

.week-block + .week-block { margin-top: 18px; }
.week-block-label { font: 500 13px/1 var(--f-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px 2px; }

.month { display: grid; background: var(--surface); border: 1px solid var(--frame); border-radius: 12px; overflow: hidden; }
:root[data-theme="cris"] .month { border-width: 2px; }
.m-head { padding: 8px 10px; font: 800 18px/1 var(--f-display); letter-spacing: .04em; text-transform: uppercase; border-bottom: 1px solid var(--line-strong); }
.m-head.is-weekend { color: var(--muted); background: var(--dim); }
.m-cell {
  min-height: 132px; padding: 4px 5px 6px; border-top: 1px solid var(--line); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 3px; min-width: 0; cursor: pointer;
}
.m-head + .m-head, .m-head:first-child { border-left: 1px solid var(--line); }
.m-cell:hover { background: var(--surface-2); }
.readonly .m-cell { cursor: default; }
.m-cell.is-dim { background: var(--dim); }
.m-cell.is-out { background: var(--break); }
.m-cell.is-out .m-num { opacity: .5; }
.m-cell.is-today { background: var(--today); box-shadow: inset 0 0 0 2px var(--ink); }
.m-num { font: 500 13px/1 var(--f-mono); color: var(--muted); padding: 2px 2px 3px; }
.m-cell.is-today .m-num { color: var(--ink); font-weight: 700; }
.m-more { border: 0; background: none; padding: 1px 4px; text-align: left; font: 700 12px var(--f-body); color: var(--muted); cursor: pointer; text-decoration: underline; }

.chip {
  display: flex; align-items: baseline; gap: 5px; width: 100%; min-width: 0; text-align: left;
  padding: 2px 6px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--cell); color: var(--ink);
  font: 400 12px/1.3 var(--f-body); cursor: pointer;
}
.chip.has-color { border-color: rgb(0 0 0 / .12); }
.chip:hover { filter: brightness(.96); }
.readonly .chip { cursor: default; }
.chip-time { font: 500 11px/1.3 var(--f-mono); opacity: .75; flex: none; }
.chip-text { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chip.allday { justify-content: center; }
.chip.allday .chip-text { font: 800 13px/1.2 var(--f-display); letter-spacing: .04em; text-transform: uppercase; }

/* phones: compact month + day list */
.month.compact .m-cell { min-height: 58px; padding: 3px; }
.month.compact .m-head { font-size: 13px; padding: 6px 4px; text-align: center; }
.m-dots { display: flex; flex-wrap: wrap; gap: 3px; padding: 0 2px; }
.m-dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid rgb(0 0 0 / .2); }
.agenda { display: grid; gap: 10px; }
.ag-day { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 10px; display: grid; gap: 5px; }
.ag-day.is-today { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--bell); }
.ag-head { display: flex; align-items: baseline; gap: 8px; }
.ag-head .dow { font: 800 18px/1 var(--f-display); text-transform: uppercase; letter-spacing: .03em; }
.ag-head .dnum { font: 500 12px/1 var(--f-mono); color: var(--muted); margin-right: auto; }
.agenda .chip { font-size: 14px; padding: 5px 8px; }
.agenda .chip-text { white-space: normal; }
.ag-empty { margin: 0; }
@media (max-width: 760px) {
  .seg { display: none; }
  .view-select { display: block; }
}

/* ---------- Sticky notes ---------- */
.notes-layer { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.wallpaper { position: relative; }
.wallpaper .notes-layer { position: absolute; }
.sticky {
  position: absolute; pointer-events: auto; width: 210px;
  background: var(--paper); color: #2A2620; border: 1px solid rgb(0 0 0 / .1);
  border-radius: 2px 2px 12px 2px;
  box-shadow: 0 1px 3px rgb(0 0 0 / .14), 0 10px 24px rgb(0 0 0 / .18);
  transform: rotate(var(--tilt));
  font: 400 20px/1.25 var(--f-note);
  padding: 0 12px 14px;
}
.sticky { touch-action: none; cursor: grab; }
.sticky textarea { cursor: text; touch-action: auto; }
.notes-list .sticky { cursor: default; touch-action: auto; }
.sticky.dragging { cursor: grabbing; transform: rotate(0deg) scale(1.03); box-shadow: 0 2px 4px rgb(0 0 0 / .16), 0 18px 36px rgb(0 0 0 / .24); z-index: 2; }
.sticky-bar {
  display: flex; align-items: center; gap: 4px; height: 30px;
  margin: 0 -12px 4px; padding: 0 6px;
  background: rgb(0 0 0 / .05); border-radius: 2px 2px 0 0;
  cursor: grab; touch-action: none; user-select: none;
}
.sticky.dragging .sticky-bar { cursor: grabbing; }
.sticky-grip { border: 0; background: none; color: rgb(0 0 0 / .45); font-size: 15px; line-height: 1; padding: 4px; cursor: grab; border-radius: 4px; }
.sticky-colors { display: flex; gap: 4px; margin-right: auto; }
.sticky-dot { width: 15px; height: 15px; border-radius: 50%; border: 1px solid rgb(0 0 0 / .28); padding: 0; cursor: pointer; }
.sticky-dot[aria-pressed="true"] { outline: 2px solid #2A2620; outline-offset: 1px; }
.sticky-done {
  border: 0; border-radius: 99px; padding: 4px 9px; cursor: pointer;
  background: rgb(0 0 0 / .08); color: #2A2620; font: 700 12px/1 var(--f-body); white-space: nowrap; flex: none;
}
.sticky-done:hover, .sticky-done:focus-visible { background: #2A2620; color: var(--paper); }
@media (hover: hover) {
  .sticky:not(:hover):not(:focus-within) .sticky-colors,
  .sticky:not(:hover):not(:focus-within) .sticky-done { opacity: 0; }
}
.sticky-text {
  display: block; width: 100%; min-height: 1.25em; margin: 0; padding: 0; border: 0;
  background: transparent; color: inherit; font: inherit; resize: none; overflow: hidden;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
textarea.sticky-text:focus { outline: none; }
textarea.sticky-text::placeholder { color: rgb(42 38 32 / .45); }
.sticky-tape {
  width: 64px; height: 16px; margin: -8px auto 8px;
  background: rgb(255 255 255 / .55); box-shadow: 0 1px 2px rgb(0 0 0 / .12);
}
/* Wallpaper notes scale with the screen */
.wallpaper .sticky { width: clamp(150px, calc(13 * var(--u)), 320px); font-size: clamp(15px, calc(1.25 * var(--u)), 30px); padding: 0 calc(.9 * var(--u)) calc(.9 * var(--u)); }
.wallpaper .sticky .sticky-bar { margin: 0 calc(-.9 * var(--u)) 4px; }
/* Phones: notes sit in a row above the schedule instead of floating over it */
.notes-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 12px; margin: 4px 0 14px; }
.notes-list .sticky { position: relative; width: auto; font-size: 18px; }
.notes-list .sticky-colors { gap: 3px; flex-wrap: wrap; }
.notes-list .sticky-dot { width: 13px; height: 13px; }
.note-btn { background: #FFF1A8; border-color: #E4CF63; color: #2A2620; }
.note-btn:hover { background: #FFE981; }
.toast { display: flex; align-items: center; gap: 12px; }
.toast-action { border: 0; background: var(--bg); color: var(--ink); font: 700 13px var(--f-body); padding: 6px 12px; border-radius: 8px; cursor: pointer; }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translate(-50%, 8px); opacity: 0; } }
}
