/* Family Calendar 2027 — editor + print-ready pages */

:root {
  --ui-bg: #efeae3;
  --ui-bg-2: #fffdf9;
  --ui-ink: #1c1916;
  --ui-muted: #6b6258;
  --ui-line: #e4d9cc;
  --ui-accent: #8b3a3a;
  --ui-accent-2: #1e3a5f;
  --ui-ok: #2f6b4f;
  --shadow: 0 10px 40px rgba(40, 28, 18, 0.12);
  --radius: 14px;
  --font-ui: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--ui-bg);
  color: var(--ui-ink);
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

#app {
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding-top: var(--safe-t);
}

/* ===== Top bar ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--ui-bg-2);
  border-bottom: 1px solid var(--ui-line);
  z-index: 20;
  min-height: 52px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 0 0 auto;
  white-space: nowrap;
}
.brand h1 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  font-size: 1.25rem;
  margin: 0;
  letter-spacing: 0.02em;
}
.brand .year-tag {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ui-muted);
}
.topbar-controls, .topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.topbar-controls { flex: 1; }
.topbar-actions { margin-left: auto; }

.ctrl, .btn {
  border: 1px solid var(--ui-line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
}
.ctrl select, .ctrl input[type="checkbox"] { border: 0; background: transparent; outline: none; }
label.ctrl { cursor: pointer; user-select: none; }
.btn:hover { border-color: #c9b8a6; }
.btn.primary {
  background: var(--ui-accent);
  color: #fff;
  border-color: var(--ui-accent);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn {
  width: 36px; height: 36px; padding: 0;
  justify-content: center;
  border-radius: 50%;
}

.menu-btn { display: none; }

/* ===== Workspace ===== */
.workspace {
  display: grid;
  grid-template-columns: 92px 1fr minmax(240px, 300px);
  min-height: 0;
  overflow: hidden;
}

.month-nav {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 6px 12px;
  background: #e9e2d8;
  border-right: 1px solid var(--ui-line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}
.nav-item {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 0;
  text-align: left;
  overflow: hidden;
  flex: 0 0 auto;
}
.nav-item .nav-thumb {
  height: 48px;
  background: #d4caba center/cover no-repeat;
  position: relative;
}
.nav-item .nav-thumb.empty { background: repeating-linear-gradient(135deg, #ddd6cc, #ddd6cc 6px, #e8e0d6 6px, #e8e0d6 12px); }
.nav-item .nav-label {
  display: block;
  font-size: 0.7rem;
  padding: 3px 6px 5px;
  color: var(--ui-ink);
}
.nav-item.active {
  background: #fff;
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 2px rgba(139, 58, 58, 0.15);
}
.nav-item:hover { background: rgba(255,255,255,0.6); }
.nav-item.drop-over { outline: 2px dashed var(--ui-accent); }

.preview-wrap {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.7), transparent 40%),
    #d8d0c6;
}
.preview-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
  position: relative;
}
.page-scaler {
  position: relative;
  line-height: 0;
}

/* ===== Editor panel ===== */
.editor-panel {
  background: var(--ui-bg-2);
  border-left: 1px solid var(--ui-line);
  overflow-y: auto;
  padding: 14px 14px 24px;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}
.editor-panel h3 {
  margin: 0 0 10px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ui-muted);
}
.editor-panel .field { margin: 0 0 12px; }
.editor-panel label.flab {
  display: block;
  font-size: 0.72rem;
  color: var(--ui-muted);
  margin-bottom: 4px;
}
.editor-panel input[type="text"],
.editor-panel textarea,
.editor-panel select {
  width: 100%;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  outline: none;
}
.editor-panel textarea { min-height: 72px; resize: vertical; line-height: 1.4; }
.editor-panel input:focus, .editor-panel textarea:focus, .editor-panel select:focus {
  border-color: #c4a484;
  box-shadow: 0 0 0 3px rgba(196, 164, 132, 0.25);
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hint { font-size: 0.75rem; color: var(--ui-muted); margin: 0 0 10px; line-height: 1.4; }
.zoom-row { display: flex; align-items: center; gap: 8px; }
.zoom-row input[type="range"] { flex: 1; }
.divider { height: 1px; background: var(--ui-line); margin: 14px 0; }

/* ===== Calendar page (the printable sheet) ===== */
.cal-page {
  width: 1056px;  /* 11in * 96 */
  height: 1632px; /* 17in * 96 */
  background: var(--pg-bg);
  color: var(--pg-ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
  transform-origin: top left;
  font-family: var(--pg-body);
}
.cal-page.landscape { flex-direction: row; }

/* Themes on the page */
.cal-page, .theme-classic {
  --pg-bg: #fffdf8;
  --pg-out: #f0ebe3;
  --pg-ink: #1a1814;
  --pg-muted: #6a6156;
  --pg-accent: #7a2e2e;
  --pg-rule: #d9cfc0;
  --pg-head-bg: #2a3140;
  --pg-head-ink: #f6efe4;
  --pg-weekend: #f7f1e8;
  --pg-today-ring: #7a2e2e;
  --pg-heading: "Cormorant Garamond", "Palatino Linotype", Palatino, serif;
  --pg-body: "Source Serif 4", Georgia, serif;
  --pg-ui: "DM Sans", sans-serif;
  --pg-pad: 36px;
  --photo-radius: 0px;
  --frame: 14px solid #fffdf8;
}
.theme-modern {
  --pg-bg: #ffffff;
  --pg-out: #eef0f2;
  --pg-ink: #111113;
  --pg-muted: #6b7280;
  --pg-accent: #0f766e;
  --pg-rule: #e5e7eb;
  --pg-head-bg: #111113;
  --pg-head-ink: #fafafa;
  --pg-weekend: #f4f5f7;
  --pg-today-ring: #0f766e;
  --pg-heading: "DM Sans", "Helvetica Neue", sans-serif;
  --pg-body: "DM Sans", "Helvetica Neue", sans-serif;
  --pg-pad: 32px;
  --photo-radius: 0px;
}
.theme-warm {
  --pg-bg: #fbf4ea;
  --pg-out: #efe4d4;
  --pg-ink: #3a2418;
  --pg-muted: #8a6a52;
  --pg-accent: #c45c26;
  --pg-rule: #e8d5c0;
  --pg-head-bg: #8a3b1c;
  --pg-head-ink: #fff6ea;
  --pg-weekend: #f4e6d4;
  --pg-today-ring: #c45c26;
  --pg-heading: "Fraunces", Georgia, serif;
  --pg-body: "Source Serif 4", Georgia, serif;
  --pg-pad: 34px;
  --photo-radius: 18px;
}
.theme-crimson {
  --pg-bg: #fbf5e6;
  --pg-out: #f0e6cf;
  --pg-ink: #3a140f;
  --pg-muted: #8a5a2a;
  --pg-accent: #b8962e;
  --pg-rule: #e4c87a;
  --pg-head-bg: #8b1515;
  --pg-head-ink: #f7e7b0;
  --pg-weekend: #f4e6c2;
  --pg-today-ring: #8b1515;
  --pg-heading: "Cinzel", "Palatino Linotype", serif;
  --pg-body: "Cormorant Garamond", Georgia, serif;
  --pg-pad: 38px;
  --photo-radius: 0px;
}
.theme-nordic {
  --pg-bg: #f5f7f8;
  --pg-out: #e6eaed;
  --pg-ink: #1f2933;
  --pg-muted: #667684;
  --pg-accent: #3d5a6c;
  --pg-rule: #d5dde3;
  --pg-head-bg: #2c3e4a;
  --pg-head-ink: #eef3f6;
  --pg-weekend: #eef2f4;
  --pg-today-ring: #3d5a6c;
  --pg-heading: "DM Sans", "Helvetica Neue", sans-serif;
  --pg-body: "Source Serif 4", Georgia, serif;
  --pg-pad: 40px;
  --photo-radius: 2px;
}

.page-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: var(--pg-pad);
  position: relative;
}
.cal-page.landscape .page-inner { flex-direction: row; gap: 28px; }
.theme-crimson .page-inner {
  box-shadow: inset 0 0 0 3px #8b1515, inset 0 0 0 7px #d4af37;
}
.theme-classic .page-inner { box-shadow: inset 0 0 0 1px #d9cfc0, inset 0 0 0 6px transparent; }

/* Photo band */
.page-photo {
  position: relative;
  flex: 1.1 1 0;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--photo-radius);
  background: #cfc6ba;
  cursor: grab;
  touch-action: none;
}
.cal-page.landscape .page-photo { flex: 1.1 1 0; }
.page-photo:active { cursor: grabbing; }
.page-photo img.hero {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.page-photo .photo-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #7a7168;
  font-family: var(--pg-ui);
  font-size: 22px;
  padding: 24px;
  background:
    repeating-linear-gradient(135deg, #d8d0c6, #d8d0c6 12px, #e4ddd4 12px, #e4ddd4 24px);
  pointer-events: none;
}
.page-photo.drop-over { outline: 4px dashed var(--pg-accent); outline-offset: -8px; }
.page-photo .scrim {
  position: absolute; inset: 0;
  pointer-events: none;
}
.caption-overlay-bottom .scrim {
  background: linear-gradient(to top, rgba(12,10,8,0.62) 0%, rgba(12,10,8,0.0) 55%);
}
.caption-overlay-top .scrim {
  background: linear-gradient(to bottom, rgba(12,10,8,0.62) 0%, rgba(12,10,8,0.0) 55%);
}
.caption-overlay-center .scrim {
  background: linear-gradient(to bottom, rgba(12,10,8,0.15), rgba(12,10,8,0.4) 50%, rgba(12,10,8,0.15));
}

.page-caption {
  font-family: var(--pg-heading);
  color: var(--pg-ink);
}
.page-caption h2 {
  margin: 0;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.02em;
}
.page-caption .poem {
  margin: 0.35em 0 0;
  white-space: pre-wrap;
  color: var(--pg-muted);
  font-style: italic;
  line-height: 1.35;
}
.page-caption.size-sm h2 { font-size: 42px; }
.page-caption.size-sm .poem { font-size: 18px; }
.page-caption.size-md h2 { font-size: 58px; }
.page-caption.size-md .poem { font-size: 22px; }
.page-caption.size-lg h2 { font-size: 76px; }
.page-caption.size-lg .poem { font-size: 26px; }
.page-caption.font-serif, .page-caption.font-serif h2, .page-caption.font-serif .poem {
  font-family: "Cormorant Garamond", "Palatino Linotype", serif;
}
.page-caption.font-script, .page-caption.font-script h2, .page-caption.font-script .poem {
  font-family: "Caveat", "Segoe Script", cursive;
}
.page-caption.font-modern, .page-caption.font-modern h2, .page-caption.font-modern .poem {
  font-family: "DM Sans", "Helvetica Neue", sans-serif;
  font-style: normal;
}
.page-caption.font-display, .page-caption.font-display h2, .page-caption.font-display .poem {
  font-family: "Cinzel", "Palatino Linotype", serif;
  font-style: normal;
}
.page-caption.font-theme .poem { font-family: var(--pg-body); }

.caption-below, .caption-below-standalone {
  padding: 16px 4px 10px;
  flex: 0 0 auto;
}
.theme-warm .page-caption.font-theme .poem,
.page-caption.font-script .poem { font-family: "Caveat", cursive; font-style: normal; font-weight: 500; }

.page-photo .page-caption {
  position: absolute;
  left: 28px; right: 28px;
  z-index: 2;
  color: #fffdf8;
  text-shadow: 0 2px 16px rgba(0,0,0,0.35);
}
.page-photo .page-caption .poem { color: rgba(255,253,248,0.9); }
.caption-overlay-bottom { bottom: 22px; }
.caption-overlay-top { top: 22px; }
.caption-overlay-center {
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
}

.right-col {
  flex: 0.95 1 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* Grid */
.page-grid {
  flex: 1.05 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}
.cal-page.landscape .page-grid { margin-top: 0; flex: 1; }
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--pg-head-bg);
  color: var(--pg-head-ink);
  border-radius: 4px 4px 0 0;
}
.weekdays span {
  text-align: center;
  font-family: var(--pg-ui);
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 8px 2px;
  font-weight: 500;
}
.days {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  border: 1px solid var(--pg-rule);
  border-top: 0;
  min-height: 0;
}
.day {
  border-right: 1px solid var(--pg-rule);
  border-bottom: 1px solid var(--pg-rule);
  padding: 4px 5px 3px;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--pg-bg);
}
.day:nth-child(7n) { border-right: 0; }
.day.weekend { background: var(--pg-weekend); }
.day.out { color: #b3aaa0; background: var(--pg-out, #efeae3); }
.day.out .day-num { opacity: 0.55; }
.day-num {
  font-family: var(--pg-heading);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  flex: 0 0 auto;
}
.theme-modern .day-num { font-weight: 500; }
.day.highlighted {
  background: var(--hl, #f6d58a);
}
.day.highlighted.weekend { background: var(--hl, #f6d58a); }
.day-events {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 3px;
}
.evt {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  font-family: var(--pg-ui);
  font-size: 14px;
  line-height: 1.15;
}
.evt-photo {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  background: #ddd;
}
.evt-icon { font-size: 15px; flex: 0 0 auto; line-height: 1; }
.evt-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.day.clickable { cursor: pointer; }
.page-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-family: var(--pg-ui);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pg-muted);
}

/* Cover */
.cover-page .page-inner { padding: 0; }
.cover-hero {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background: #2a2430;
}
.cover-hero:active { cursor: grabbing; }
.cover-hero img.hero {
  width: 100%; height: 100%;
  object-fit: cover;
  transform-origin: center center;
  pointer-events: none;
  user-select: none;
}
.cover-hero .photo-ph {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: #d8cfc4; font-size: 28px; font-family: var(--pg-ui);
  background: linear-gradient(160deg, #2a2430, #6b3a3a 60%, #c4a06a);
}
.cover-text {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 80px 64px 72px;
  z-index: 2;
  color: #fffdf8;
  text-align: center;
  background: linear-gradient(to top, rgba(10,8,14,0.72), rgba(10,8,14,0.0) 70%);
  pointer-events: none;
}
.cover-text .kicker {
  font-family: var(--pg-ui);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 16px;
  margin: 0 0 12px;
  opacity: 0.85;
}
.cover-text h1 {
  font-family: var(--pg-heading);
  font-size: 96px;
  margin: 0;
  line-height: 0.95;
  font-weight: 700;
}
.cover-text .sub {
  font-family: var(--pg-body);
  font-size: 28px;
  margin: 18px 0 0;
  font-style: italic;
  opacity: 0.92;
}
.theme-crimson .cover-text h1 { letter-spacing: 0.08em; }
.cover-ornament {
  width: 80px; height: 2px;
  background: #d4af37;
  margin: 18px auto 0;
}

/* ===== Photo tray ===== */
.tray {
  background: var(--ui-bg-2);
  border-top: 1px solid var(--ui-line);
  padding: 8px 12px calc(8px + var(--safe-b));
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 92px;
  z-index: 20;
}
.tray-label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ui-muted);
  writing-mode: horizontal-tb;
  white-space: nowrap;
}
.tray-rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 4px;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}
.thumb {
  flex: 0 0 auto;
  width: 64px; height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  background: #ddd;
  position: relative;
  cursor: grab;
  padding: 0;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.thumb.selected { border-color: var(--ui-accent); box-shadow: 0 0 0 2px rgba(139,58,58,0.25); }
.thumb .badge {
  position: absolute;
  right: 2px; bottom: 2px;
  background: rgba(20,16,12,0.75);
  color: #fff;
  font-size: 0.58rem;
  padding: 1px 4px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.tray-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.add-photo-btn input { display: none; }

/* ===== Modals ===== */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(20, 16, 12, 0.45);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 16px calc(16px + var(--safe-b));
}
.modal {
  background: #fffdf9;
  border-radius: 16px;
  width: min(520px, 100%);
  max-height: min(90vh, 820px);
  overflow: auto;
  box-shadow: var(--shadow);
  padding: 20px 20px 16px;
}
.modal h2 { margin: 0 0 12px; font-family: "Cormorant Garamond", Georgia, serif; font-size: 1.6rem; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.icon-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}
.icon-grid button {
  border: 1px solid var(--ui-line);
  background: #fff;
  border-radius: 8px;
  font-size: 1.25rem;
  min-height: 40px;
  padding: 0;
}
.icon-grid button.selected { border-color: var(--ui-accent); background: #f8eee8; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #cfc6ba;
  padding: 0;
}
.swatch.selected { box-shadow: 0 0 0 2px var(--ui-accent); }
.seg {
  display: flex; gap: 0; border: 1px solid var(--ui-line); border-radius: 10px; overflow: hidden;
}
.seg button {
  flex: 1; border: 0; background: #fff; padding: 8px 6px; min-height: 40px; font-size: 0.8rem;
  border-right: 1px solid var(--ui-line);
}
.seg button:last-child { border-right: 0; }
.seg button.selected { background: var(--ui-accent); color: #fff; }

.welcome {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 8;
  pointer-events: none;
}
.welcome .card {
  pointer-events: auto;
  background: #fffdf9;
  padding: 28px 26px 22px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  width: min(420px, calc(100% - 32px));
  text-align: center;
}
.welcome h2 { font-family: "Cormorant Garamond", Georgia, serif; font-size: 2rem; margin: 0 0 8px; }
.welcome p { color: var(--ui-muted); margin: 0 0 16px; line-height: 1.45; }
.welcome .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + var(--safe-b));
  transform: translateX(-50%);
  background: #1c1916;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 80;
  box-shadow: var(--shadow);
  max-width: calc(100% - 32px);
}
.busy {
  position: fixed; inset: 0;
  background: rgba(255,253,249,0.72);
  z-index: 70;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px;
  font-weight: 500;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid #e4d9cc;
  border-top-color: var(--ui-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Hidden render stage for PDF / PNG */
#render-stage {
  position: absolute;
  left: -10000px;
  top: 0;
  width: 1056px;
  pointer-events: none;
}

/* Mobile */
@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto;
    overflow: hidden;
    min-height: 0;
  }
  .month-nav {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--ui-line);
    padding: 8px;
    gap: 8px;
  }
  .nav-item { flex: 0 0 70px; }
  .nav-item .nav-thumb { height: 40px; }
  .editor-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border: 0;
    border-top: 1px solid var(--ui-line);
    background: var(--ui-bg-2);
    padding: 10px 14px;
    min-height: 44px;
    border-radius: 0;
    font-size: 0.88rem;
  }
  .editor-toggle::after { content: "▾"; color: var(--ui-muted); }
  .workspace.editor-open .editor-toggle::after { content: "▴"; }
  .editor-panel {
    border-left: 0;
    border-top: 0;
    max-height: 0;
    padding: 0 14px;
    overflow: hidden;
  }
  .workspace.editor-open .editor-panel {
    max-height: 40vh;
    padding: 12px 14px 16px;
    overflow-y: auto;
    border-top: 1px solid var(--ui-line);
  }
  .topbar-controls { display: none; }
  .topbar-actions .hide-sm { display: none; }
  .menu-btn { display: inline-flex; }
  .tray { grid-template-columns: 1fr; }
  .tray-label { display: none; }
  .tray-actions { justify-content: stretch; }
  .tray-actions .btn { flex: 1; justify-content: center; }
  .brand h1 { font-size: 1.05rem; }
  .modal { border-radius: 16px 16px 8px 8px; }
  .preview-stage { padding: 8px; }
}

@media (min-width: 861px) {
  .editor-toggle { display: none; }
}

/* Print */
@media print {
  body { background: #fff; overflow: visible; height: auto; }
  #app, .toast, .modal-back, .busy, .welcome, #render-stage { display: none !important; }
  #print-root { display: block !important; }
  #print-root .cal-page {
    box-shadow: none;
    transform: none !important;
    width: 100%;
    height: 100%;
    page-break-after: always;
    break-after: page;
  }
  @page { margin: 0; }
}

#print-root { display: none; }

.access-box{border:1px solid var(--ui-line);border-radius:12px;padding:12px;margin:0 0 14px;background:#fff}
.payment-soon{margin-top:10px;padding:10px 12px;border-radius:10px;background:#f7f1e8;font-size:0.85rem;line-height:1.4;color:var(--ui-ink)}
.access-ok{color:var(--ui-ok)!important;font-weight:500}
.access-err{color:#8b3a3a!important;font-weight:500}
#discountQuote{font-weight:600;color:var(--ui-ink);margin-bottom:4px}
