.calendar-page,
.gallery-page { padding: 48px 0 72px; }

.calendar-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 40px;
  padding-bottom: 40px;
}

.calendar-hero__weekday,
.gallery-hero__meta {
  margin: 0 0 10px;
  color: var(--shared-green);
  font: 900 11px/1.4 var(--shared-font);
}

.calendar-hero h1,
.gallery-hero h1 {
  margin: 0;
  font: 900 62px/.98 var(--shared-font);
  letter-spacing: 0;
}

.calendar-hero__clock {
  color: var(--shared-coral);
  font: 900 38px/1 var(--shared-font);
  font-variant-numeric: tabular-nums;
}

.calendar-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  border-top: 2px solid var(--shared-ink);
  border-bottom: 2px solid var(--shared-ink);
}

.calendar-main { min-width: 0; padding: 30px 34px 38px 0; }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.calendar-toolbar h2 { margin: 0; font: 900 24px/1 var(--shared-font); }
.calendar-toolbar__actions { display: inline-flex; align-items: center; gap: 8px; }
.calendar-toolbar__actions .command-button[hidden] { display: none; }

.calendar-weekdays,
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays span { padding: 12px 4px; color: var(--shared-muted); font: 900 9px/1 var(--shared-font); text-align: center; }
.calendar-grid { border-top: 1px solid var(--shared-line); }

.calendar-day {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 76px;
  padding: 10px;
  align-content: start;
  justify-items: start;
  border: 0;
  border-right: 1px solid var(--shared-line);
  border-bottom: 1px solid var(--shared-line);
  color: var(--shared-ink);
  background: transparent;
  cursor: pointer;
}

.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day:hover { background: #f0f8fa; }
.calendar-day[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--shared-ink); }
.calendar-day.is-outside { color: rgba(39, 49, 58, .32); }
.calendar-day__number { position: relative; z-index: 1; display: grid; width: 32px; height: 32px; place-items: center; font: 900 12px/1 var(--shared-font); }
.calendar-day.is-today .calendar-day__number { border: 2px solid var(--shared-ink); border-radius: 50%; background: var(--shared-sky); }
.calendar-day__markers { position: absolute; right: 9px; bottom: 9px; display: flex; gap: 4px; }
.calendar-day__marker { width: 8px; height: 8px; border: 1px solid var(--shared-ink); border-radius: 50%; background: var(--shared-yellow); }
.calendar-day__marker--milestone,.calendar-day__marker--anniversary { background: var(--shared-coral); }

.calendar-rail { min-width: 0; padding: 30px 0 34px 28px; border-left: 2px solid var(--shared-ink); background: #edf7f8; }
.calendar-rail__label { margin: 0 0 10px; color: var(--shared-green); font: 900 10px/1.4 var(--shared-font); }
.calendar-rail h2,.calendar-rail h3 { margin: 0; font-weight: 900; letter-spacing: 0; }
.calendar-rail h2 { font-size: 30px; line-height: 1.08; }
.calendar-rail h3 { margin-top: 32px; font-size: 18px; }
.calendar-selected { margin-top: 18px; }
.calendar-event,.upcoming-event { display: grid; grid-template-columns: 54px 1fr; gap: 12px; padding: 15px 0; border-top: 1px dashed rgba(39,49,58,.3); }
.calendar-event { grid-template-columns: 1fr; }
.calendar-event strong,.upcoming-event strong { display: block; font: 900 13px/1.35 var(--shared-font); }
.calendar-event span,.upcoming-event span,.calendar-empty-copy { display: block; margin: 5px 0 0; color: var(--shared-muted); font: 700 10px/1.55 var(--shared-font); }
.upcoming-event time { color: var(--shared-coral); font: 900 12px/1.35 var(--shared-font); }
.calendar-upcoming { margin-top: 14px; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 22px; color: var(--shared-muted); font: 800 9px/1 var(--shared-font); }
.calendar-legend i { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border: 1px solid var(--shared-ink); border-radius: 50%; vertical-align: -1px; }

@media (max-width: 980px) {
  .calendar-workspace { grid-template-columns: minmax(0, 1fr) 280px; }
  .calendar-main { padding-right: 22px; }
  .calendar-rail { padding-left: 22px; }
}

@media (max-width: 760px) {
  .calendar-page,.gallery-page { padding: 34px 0 56px; }
  .calendar-hero { grid-template-columns: 1fr; gap: 18px; padding-bottom: 28px; }
  .calendar-hero h1,.gallery-hero h1 { font-size: 40px; }
  .calendar-hero__clock { font-size: 28px; }
  .calendar-workspace { grid-template-columns: 1fr; }
  .calendar-main { padding: 24px 0 28px; }
  .calendar-rail { padding: 26px 0 30px; border-top: 2px solid var(--shared-ink); border-left: 0; }
  .calendar-day { min-height: 56px; padding: 6px; }
  .calendar-day__number { width: 28px; height: 28px; font-size: 11px; }
  .calendar-day__markers { right: 5px; bottom: 5px; gap: 2px; }
  .calendar-day__marker { width: 6px; height: 6px; }
}

@media (max-width: 420px) {
  .calendar-toolbar { align-items: flex-start; flex-wrap: wrap; }
  .calendar-toolbar h2 { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  .calendar-toolbar__actions { display: grid; grid-template-columns: repeat(3, minmax(0, auto)); max-width: 100%; }
  .calendar-toolbar__actions .command-button { grid-column: 1 / -1; justify-content: center; min-height: 34px; }
  .calendar-day { min-height: 48px; }
  .calendar-weekdays span { padding: 9px 2px; }
}

.gallery-page { padding-top: 48px; }
.gallery-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 24px; padding-bottom: 30px; }
.gallery-hero h1 { max-width: 760px; }
.gallery-hero__count { margin: 0 0 10px; color: var(--shared-muted); font: 900 11px/1.4 var(--shared-font); }
.gallery-hero__count strong { color: var(--shared-coral); font-size: 18px; }
.gallery-hero__actions { display: flex; align-items: center; gap: 14px; }
.gallery-hero__actions input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); opacity: 0; }
.gallery-dropzone { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 18px; border: 2px dashed var(--shared-ink); background: #edf7f8; }
.gallery-dropzone.is-dragover { border-color: var(--shared-coral); background: #fff1eb; }
.gallery-dropzone p { margin: 0; color: var(--shared-muted); font: 700 11px/1.6 var(--shared-font); }
.gallery-dropzone strong { color: var(--shared-ink); }
.gallery-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 0; border-bottom: 2px solid var(--shared-ink); }
.gallery-sort { display: inline-flex; align-items: center; gap: 7px; color: var(--shared-muted); font: 800 10px/1 var(--shared-font); }
.gallery-sort select { min-height: 32px; padding: 0 8px; border: 2px solid var(--shared-ink); border-radius: 3px; color: var(--shared-ink); background: #fff; font: 800 10px/1 var(--shared-font); }
.gallery-wall { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 100px; gap: 14px; padding: 22px 0 30px; }
.gallery-photo { position: relative; min-width: 0; min-height: 0; overflow: hidden; margin: 0; border: 2px solid var(--shared-ink); border-radius: 3px; background: #e5edf0; box-shadow: var(--shared-shadow); transform: rotate(-.7deg); }
.gallery-photo:nth-child(2n) { transform: rotate(.8deg); }
.gallery-photo:nth-child(3n) { transform: rotate(-.3deg); }
.gallery-photo--tall { grid-row: span 4; }
.gallery-photo--wide { grid-column: span 2; grid-row: span 3; }
.gallery-photo--short { grid-row: span 2; }
.gallery-photo.is-dragging { opacity: .4; }
.gallery-photo__open { position: absolute; inset: 0; display: block; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.gallery-photo__open img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery-photo__favorite { position: absolute; z-index: 2; top: 10px; right: 10px; display: grid; width: 32px; height: 32px; padding: 0; place-items: center; border: 2px solid var(--shared-ink); border-radius: 50%; background: #fff; cursor: pointer; }
.gallery-photo__favorite.is-active { color: var(--shared-ink); background: var(--shared-coral); }
.gallery-photo__favorite svg { width: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.gallery-photo__favorite.is-active svg { fill: currentColor; }
.gallery-photo figcaption { position: absolute; z-index: 1; right: 0; bottom: 0; left: 0; padding: 42px 14px 12px; color: #fff; background: linear-gradient(transparent, rgba(39,49,58,.84)); pointer-events: none; }
.gallery-photo figcaption strong { display: block; overflow: hidden; font: 900 13px/1.35 var(--shared-font); text-overflow: ellipsis; white-space: nowrap; }
.gallery-photo figcaption span { display: block; margin-top: 4px; font: 700 10px/1 var(--shared-font); opacity: .8; }
.gallery-photo__reorder { position: absolute; z-index: 3; top: 10px; left: 10px; display: none; gap: 4px; }
.gallery-photo__reorder button { display: grid; width: 30px; height: 30px; padding: 0; place-items: center; border: 2px solid var(--shared-ink); border-radius: 50%; background: #fff; cursor: pointer; }
.gallery-photo__reorder button:disabled { cursor: default; opacity: .35; }
.gallery-photo__reorder svg { width: 14px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 2; }
.gallery-empty { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: center; gap: 34px; padding: 24px 0 40px; border-bottom: 2px solid var(--shared-ink); }
.gallery-empty[hidden],.gallery-wall[hidden] { display: none; }
.gallery-empty img { display: block; width: 100%; border: 2px solid var(--shared-ink); box-shadow: var(--shared-shadow); }
.gallery-empty h2 { margin: 0; font: 900 30px/1.12 var(--shared-font); }
.gallery-empty p { margin: 12px 0 18px; color: var(--shared-muted); font: 700 12px/1.7 var(--shared-font); }
.gallery-empty__copy { max-width: 420px; }

dialog { max-width: calc(100vw - 28px); padding: 0; border: 2px solid var(--shared-ink); border-radius: 4px; color: var(--shared-ink); background: var(--shared-paper); box-shadow: 10px 10px 0 rgba(39,49,58,.25); }
dialog::backdrop { background: rgba(39,49,58,.66); }
.gallery-viewer { width: min(1040px, calc(100vw - 56px)); }
.gallery-viewer__panel { display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: min(680px, calc(100vh - 80px)); }
.gallery-viewer__image { display: grid; min-height: 500px; place-items: center; background: var(--shared-ink); }
.gallery-viewer__image img { display: block; max-width: 100%; max-height: 76vh; object-fit: contain; }
.gallery-viewer__side { position: relative; display: flex; flex-direction: column; padding: 36px 24px 24px; background: var(--shared-paper); }
.gallery-viewer__side h2 { margin: 0; font: 900 26px/1.15 var(--shared-font); }
.gallery-viewer__side time { display: block; margin-top: 8px; color: var(--shared-muted); font: 800 10px/1 var(--shared-font); }
.gallery-viewer__actions { display: grid; gap: 9px; margin-top: auto; }
.gallery-viewer__actions button { display: flex; align-items: center; justify-content: flex-start; gap: 8px; min-height: 40px; padding: 0 11px; border: 2px solid var(--shared-ink); border-radius: 3px; background: #fff; font: 900 10px/1 var(--shared-font); cursor: pointer; }
.gallery-viewer__actions button:hover,.gallery-viewer__actions button:focus-visible { background: #edf7f8; }
.gallery-viewer__actions svg,.gallery-viewer__close svg,.gallery-viewer__step svg { width: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.gallery-viewer__actions [data-gallery-viewer-favorite].is-active { background: var(--shared-coral); }
.gallery-viewer__close,.gallery-viewer__step { position: absolute; z-index: 2; display: grid; width: 42px; height: 42px; padding: 0; place-items: center; border: 2px solid var(--shared-ink); border-radius: 50%; background: #fff; cursor: pointer; }
.gallery-viewer__close { top: 14px; right: 14px; }
.gallery-viewer__step { top: 50%; transform: translateY(-50%); }
.gallery-viewer__step--prev { left: 14px; }
.gallery-viewer__step--next { right: 314px; }
.gallery-viewer__step:disabled { opacity: .35; cursor: default; }
.gallery-dialog { width: min(520px, calc(100vw - 28px)); padding: 28px; }
.gallery-dialog h2 { margin: 0 0 20px; font: 900 26px/1 var(--shared-font); }
.gallery-dialog label { display: grid; gap: 7px; margin-top: 15px; color: var(--shared-muted); font: 800 10px/1 var(--shared-font); }
.gallery-dialog input,.gallery-dialog textarea { width: 100%; padding: 10px 11px; border: 2px solid var(--shared-ink); border-radius: 3px; color: var(--shared-ink); background: #fff; font: 700 13px/1.5 var(--shared-font); }
.gallery-dialog textarea { min-height: 104px; resize: vertical; }
.gallery-dialog__actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.gallery-dialog__actions button { min-height: 38px; padding: 0 13px; border: 2px solid var(--shared-ink); border-radius: 3px; background: #fff; font: 900 10px/1 var(--shared-font); cursor: pointer; }
.gallery-dialog__actions button[type="submit"],.gallery-dialog__actions button[data-gallery-delete-confirm] { color: #fff; background: var(--shared-ink); }

@media (pointer: coarse) { .gallery-photo__reorder { display: flex; } }

@media (max-width: 760px) {
  .gallery-page { padding-top: 34px; }
  .gallery-hero { grid-template-columns: 1fr; align-items: start; gap: 18px; }
  .gallery-hero h1 { font-size: 40px; }
  .gallery-hero__actions { width: 100%; max-width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .gallery-dropzone { width: 100%; min-width: 0; align-items: flex-start; flex-direction: column; }
  .gallery-dropzone p { max-width: 100%; overflow-wrap: anywhere; }
  .gallery-toolbar { width: 100%; min-width: 0; align-items: flex-start; flex-direction: column; }
  .gallery-wall { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 88px; gap: 9px; }
  .gallery-photo,.gallery-photo:nth-child(2n),.gallery-photo:nth-child(3n) { transform: none; }
  .gallery-photo--tall { grid-row: span 3; }
  .gallery-photo--wide { grid-column: span 2; grid-row: span 3; }
  .gallery-photo--short { grid-row: span 2; }
  .gallery-empty { grid-template-columns: 1fr; gap: 18px; }
  .gallery-empty img { width: min(260px, 70vw); }
  .gallery-viewer { width: calc(100vw - 20px); }
  .gallery-viewer__panel { grid-template-columns: 1fr; min-height: 0; }
  .gallery-viewer__image { min-height: 56vh; }
  .gallery-viewer__side { min-height: 250px; padding: 28px 18px 18px; }
  .gallery-viewer__step--next { right: 14px; }
  .gallery-viewer__actions { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 22px; }
}
