:root {
  color-scheme: light; font-family: system-ui, sans-serif; color: var(--ink);
  background: linear-gradient(135deg, #fdf2f9 0%, #f4edff 100%) fixed;
  --ink: #3a1e4d; --muted: #7a5a8e; --purple: #8b4fd6; --pink: #e0418f;
  --card: #ffffff; --line: #e6d3f0; --event: #fdf1f8;
  --personal: #8b4fd6; --work: #b06ad9; --girls: #e0418f;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; background: transparent; }
[hidden] { display: none !important; }
#missing { padding: 24px; min-height: 100dvh; display: grid; place-items: center; font-size: 30px; }
#display { height: 100dvh; display: flex; flex-direction: column; padding: 24px 30px; gap: 18px; }
header { display: grid; grid-template-columns: 1fr auto; gap: 14px 28px; align-items: center; flex: none; }
.brand { font-size: 14px; letter-spacing: .22em; color: var(--pink); font-weight: 650; margin-bottom: 5px; }
#date { font-size: clamp(28px, 2.3vw, 46px); font-weight: 650; color: var(--ink); }
.header-right { text-align: right; }
#clock { font-size: 46px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--purple); }
.status { font-size: 14px; color: var(--muted); }
#offline { color: #c2296f; font-weight: 600; margin-left: 10px; }
nav { display: flex; gap: 6px; }
button { font: inherit; font-size: 18px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 9px 19px; cursor: pointer; }
button.selected { background: var(--purple); border-color: var(--purple); color: #fff; }
button:focus-visible { outline: 3px solid var(--pink); }
#navigation { display: flex; align-items: center; gap: 8px; grid-column: 1; grid-row: 3; }
#period { margin-left: 12px; font-size: 22px; color: var(--muted); }
.legend { display: flex; gap: 22px; justify-content: flex-end; font-size: 17px; grid-column: 2; grid-row: 2 / 4; }
.personal { --space: var(--personal); } .work { --space: var(--work); } .girls { --space: var(--girls); } .neutral { --space: var(--pink); }
.legend span { color: var(--space); }
main { min-height: 0; flex: 1; display: flex; flex-direction: column; gap: 12px; }
#calendar { touch-action: pan-y; }
.slide-next { animation: slide-next 180ms ease-out; }
.slide-prev { animation: slide-prev 180ms ease-out; }
@keyframes slide-next { from { transform: translateX(40px); opacity: .4; } to { transform: translateX(0); opacity: 1; } }
@keyframes slide-prev { from { transform: translateX(-40px); opacity: .4; } to { transform: translateX(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .slide-next, .slide-prev { animation: none; } }
main.day { background: transparent; border: 0; border-radius: 0; box-shadow: none; }
main.day > .grid { grid-template-columns: minmax(0, 1fr); }
main.day .day-events { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-content: start; }
main.day .day-events .event { padding: 20px; margin: 0; }
main.day .day-events .event-title { font-size: 32px; }
main.day .day-events .event-time { font-size: 22px; }
@media (max-width: 1200px) { main.day .day-events { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (orientation: portrait), (max-width: 750px) { main.day .day-events { grid-template-columns: 1fr; } }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; min-height: 0; flex: 1; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 14px; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 2px 8px rgba(139, 79, 214, .07); }
h2 { font-size: 20px; margin: 0; padding: 14px 12px; font-weight: 600; color: var(--ink); }
.is-today { border: 2px solid var(--purple); background: #f6efff; }
.is-today > h2 { color: var(--purple); }
.day-events { overflow-y: auto; min-height: 0; padding: 0 9px 9px; }
.event { border-left: 4px solid var(--space); background: var(--event); padding: 10px 11px; margin-bottom: 9px; border-radius: 8px; overflow-wrap: anywhere; }
.event-title { font-size: 21px; line-height: 1.3; color: var(--ink); }
.event-time { font-size: 16px; color: var(--purple); font-weight: 600; margin-bottom: 4px; }
.empty { font-size: 17px; color: #a68bb8; padding: 14px 2px; }
.overdue { flex: none; display: flex; gap: 14px; align-items: center; border: 1px solid #f3a6c8; background: #ffeaf3; padding: 10px; border-radius: 14px; max-height: 160px; }
.overdue h2 { color: #c2296f; flex: none; }
.overdue .event { background: var(--card); }
.overdue-list { display: flex; gap: 10px; overflow: auto; min-width: 0; }
.overdue .event { flex: 0 0 260px; margin: 0; max-height: 130px; overflow-y: auto; }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--muted); font-size: 18px; font-weight: 600; }
.month .grid { grid-template-rows: repeat(6, minmax(0, 1fr)); gap: 6px; }
.month h2 { padding: 5px 10px; font-size: 18px; }
.month .event { padding: 2px 6px; margin-bottom: 3px; }
.month .event-title { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.month .day-events { padding: 0 5px 4px; }
.dim { opacity: .5; }
.more { color: var(--pink); font-size: 15px; font-weight: 600; }
.agenda { overflow-y: auto; }
.agenda .grid { display: block; flex: none; }
.agenda .day { margin-bottom: 14px; }
.agenda .day-events { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; overflow: visible; }
.agenda .is-today .event-title { font-size: 30px; }
.agenda .is-today h2 { font-size: 28px; }
@media (orientation: portrait) {
  #display { padding: 20px; }
  #date { font-size: 32px; }
  .legend { gap: 12px; }
  .week .grid { overflow-y: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(250px, 1fr); }
  .agenda .day-events { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #period { font-size: 18px; }
}
@media (max-width: 750px) {
  #display { padding: 10px; }
  #date { font-size: 24px; } #clock { font-size: 28px; }
  .legend { grid-row: auto; grid-column: 1 / -1; justify-content: flex-start; }
  #navigation { flex-wrap: wrap; }
  button { padding: 8px 12px; }
  .month .event-title { font-size: 14px; }
  .overdue { display: block; }
  .agenda .day-events { grid-template-columns: 1fr; }
}

nav { flex-wrap: wrap; }
#fullscreen { color: var(--purple); padding: 6px 12px; }
.fullscreen-hint { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 10; max-width: calc(100% - 24px); width: max-content; padding: 9px 18px; border-radius: 999px; background: var(--card); color: var(--purple); box-shadow: 0 3px 14px rgba(139, 79, 214, .18); font-size: 17px; text-align: center; pointer-events: none; }
#install { color: var(--pink); }
.key-entry { max-width: 100%; }
#key-form { font-size: 18px; }
#key-form label { display: block; color: var(--muted); margin-bottom: 8px; }
#key-form > div { display: flex; flex-wrap: wrap; gap: 10px; }
#display-key { min-width: 0; max-width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
#display-key:focus-visible { outline: 3px solid var(--pink); }
#key-error { color: var(--pink); }
.dad { --custody-bg: #e3efff; --custody-text: #1f5fae; --custody-border: #9cc3f2; }
.mom { --custody-bg: #fde3ef; --custody-text: #b02a6b; --custody-border: #f3a6c8; }
.other { --custody-bg: #f1ebf8; --custody-text: #5f4b73; --custody-border: #e6d3f0; }
.custody, .custody-banner, .custody-chip { background: var(--custody-bg); color: var(--custody-text); border: 1px solid var(--custody-border); }
.custody { flex: none; min-height: 30px; padding: 3px 9px; font-size: 17px; font-weight: 600; border-radius: 8px; margin: 0 9px 8px; overflow-wrap: anywhere; }
.custody-banner { flex: none; font-size: 30px; padding: 16px 20px; border-radius: 14px; margin: 0 9px 16px; }
.custody-next { font-size: 18px; margin-top: 6px; }
.custody-chip { display: inline-block; font-size: 17px; font-weight: 600; padding: 3px 10px; border-radius: 8px; margin-top: 6px; }
.custody-legend { display: flex; justify-content: flex-end; gap: 16px; font-size: 17px; font-weight: 600; margin-top: 6px; }
.custody-legend span, .custody-corner { color: var(--custody-text); }
.month .custody-dad { background: #e4efff; border: 1px solid #9cc3f2; }
.month .custody-mom { background: #fde4f0; border: 1px solid #f3a6c8; }
.month .day.is-today { border: 2px solid var(--purple); }
.month .custody-other { background: #f1ebf8; }
.month .day { position: relative; }
.custody-corner { position: absolute; top: 6px; right: 8px; font-size: 16px; font-weight: 600; }
.month .day:has(.custody-corner) > h2 { padding-right: 75px; }
