:root {
  --bg: #1B1814;
  --card: #25211C;
  --line: #3A342C;
  --ink: #F3EDE2;
  --muted: #B5AC9E;
  --accent: #F2C063;
  --board: #26392F;
  --wood: #6B4A2E;
  --wood-dark: #4A321F;
  --chalk: 'Cabin Sketch', 'Comic Sans MS', cursive;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, sans-serif; }
button, select, input { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- chalkboard: top third ---------- */
.board-wrap { height: 33.333vh; min-height: 240px; padding: 10px 10px 0; }
.board-frame {
  height: 100%; display: flex; flex-direction: column;
  background: var(--wood); border-radius: 10px; padding: 12px 12px 0;
  box-shadow: inset 0 0 0 2px var(--wood-dark), 0 6px 18px rgba(0,0,0,.35);
}
.board-space { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.board { position: relative; flex-shrink: 0; border-radius: 4px; overflow: hidden;
  background-color: var(--board); box-shadow: inset 0 0 40px rgba(0,0,0,.45); }
.board canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.board-status { position: absolute; top: 10px; right: 12px; font-size: 13px; color: #E9E4D6;
  background: rgba(0,0,0,.35); border-radius: 999px; padding: 6px 12px; pointer-events: none; }
.board-status:empty { display: none; }

.tray { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 4px 10px; color: #FBF3E4; }
.tray-group { display: flex; align-items: center; gap: 6px; }
.tool { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px;
  background: rgba(0,0,0,.18); border: 1px solid rgba(0,0,0,.25); border-radius: 8px; cursor: pointer; font-size: 14px; }
.tool:hover { background: rgba(0,0,0,.3); }
.tool.is-on { background: #FBF3E4; color: #2B1E12; border-color: #FBF3E4; }
.tool.danger { background: #7A2E22; border-color: #5C2118; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(0,0,0,.35); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { outline: 3px solid #FBF3E4; outline-offset: 2px; }
#size { min-height: 40px; background: rgba(0,0,0,.18); border: 1px solid rgba(0,0,0,.25); border-radius: 8px; padding: 0 8px; color: #FBF3E4; }
#size option { color: #111; }
#textInput { min-height: 40px; width: min(320px, 60vw); background: #FBF3E4; color: #2B1E12; border: 0; border-radius: 8px; padding: 0 12px; }
.viewers { margin-left: auto; font-size: 13px; color: #F1E4CF; }

.rotate-hint { display: none; }

/* phones: icon-only tray in one swipeable row so the board keeps its space */
@media (max-width: 700px) {
  .board-wrap { height: auto; min-height: 0; padding: 6px 6px 0; }
  .board-space { flex: none; aspect-ratio: 16 / 9; }
  body.expanded .board-space { flex: 1; aspect-ratio: auto; }
  .board-frame { padding: 8px 8px 0; }
  .tray { flex-wrap: nowrap; overflow-x: auto; gap: 8px; padding: 6px 2px 8px; scrollbar-width: none; }
  .tray::-webkit-scrollbar { display: none; }
  .tool { padding: 6px 10px; min-width: 44px; justify-content: center; }
  .tool span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .admin .tool span { position: static; width: auto; height: auto; clip: auto; }
  .text-entry { order: -1; }
  .swatch { width: 28px; height: 28px; flex-shrink: 0; }
  .viewers { display: none; }
  body.expanded .rotate-hint { display: block; position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
    font-size: 13px; color: #E9E4D6; background: rgba(0,0,0,.4); border-radius: 999px; padding: 6px 12px; pointer-events: none; white-space: nowrap; }
}
@media (max-width: 700px) and (orientation: landscape) { body.expanded .rotate-hint { display: none; } }

body.expanded { overflow: hidden; }
body.expanded .board-wrap { position: fixed; inset: 0; height: auto; z-index: 50; padding: 0; background: var(--bg); }
body.expanded .board-frame { border-radius: 0; }

/* ---------- dashboard ---------- */
.dash { padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 16px; }
.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px; }
.dash-head h1 { margin: 0; font-family: var(--chalk); font-weight: 700; font-size: clamp(26px, 3vw, 38px); color: var(--accent); }
.dash-head p { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.dash-head .today { font-size: 16px; color: var(--ink); }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; min-width: 0; }
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; letter-spacing: .02em; color: var(--muted); text-transform: uppercase; }
.cal { grid-column: span 6; grid-row: span 2; }
.next { grid-column: span 3; }
.places { grid-column: span 3; }
.photos { grid-column: span 6; }
@media (max-width: 1100px) { .cal, .photos { grid-column: span 12; } .next, .places { grid-column: span 6; } }
@media (max-width: 640px) { .next, .places { grid-column: span 12; } .dash { padding: 14px; } }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.month-nav { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.month-nav button { width: 40px; height: 40px; display: grid; place-items: center; background: transparent; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.month-nav button:hover { background: #2F2A23; }
#monthLabel { min-width: 130px; text-align: center; }

.cal-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 760px) { .cal-body { grid-template-columns: 1fr; } }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; align-content: start; }
.month .dow { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 0; }
.day { aspect-ratio: 1 / 1; min-height: 36px; border-radius: 8px; border: 1px solid transparent; background: #2B2620;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; font-size: 14px; }
.day.out { background: transparent; color: #7D7466; }
.day.today { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.day[aria-pressed="true"] { background: var(--accent); color: #241A0C; }
.day .dots { display: flex; gap: 3px; height: 5px; }
.day .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.day[aria-pressed="true"] .dots i { background: #241A0C; }

.agenda h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 500; }
.agenda ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; max-height: 360px; overflow-y: auto; }
.agenda li { display: grid; grid-template-columns: 84px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.agenda .when { font-size: 13px; color: var(--accent); line-height: 1.35; }
.agenda .what { font-size: 15px; line-height: 1.35; }
.agenda .where { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.empty { color: var(--muted); font-size: 14px; line-height: 1.5; }

.next-body .big { font-family: var(--chalk); font-size: clamp(40px, 4.5vw, 60px); line-height: 1; color: var(--accent); }
.next-body .what { font-size: 20px; font-weight: 600; margin-top: 10px; }
.next-body .when { font-size: 14px; color: var(--muted); margin-top: 4px; }

#places { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
#places li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
#places .name { font-weight: 600; }
#places .wx { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
#places .time { font-size: 22px; font-variant-numeric: tabular-nums; }
#places .temp { font-size: 13px; color: var(--muted); text-align: right; display: block; }

.photo-frame { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #1F1B17; }
.photo-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.2s ease; }
.photo-frame img.show { opacity: 1; }
.photo-frame .empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; }

/* wall display: dashboard fits under the board without scrolling on a 1080p screen */
@media (min-width: 1500px) and (min-height: 900px) {
  .agenda ul { max-height: 300px; }
}
/* landscape laptops/monitors: give the 16:9 board more room so it isn't a small square in a big frame */
@media (orientation: landscape) and (min-width: 900px) {
  .board-wrap { height: 50vh; }
}
/* vertical wall monitor (e.g. 1080×1920): compact calendar + wider photo strip so it all fits */
@media (orientation: portrait) and (min-width: 900px) {
  .day { aspect-ratio: auto; height: 50px; }
  .agenda ul { max-height: 330px; }
  .photo-frame { aspect-ratio: 8 / 3; }
  .next-body .big { font-size: 64px; }
  #places .time { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { .photo-frame img { transition: none; } }
