:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
[hidden] { display: none !important; }
/* Layout: one screen, no page scroll. The clock and next-up float over a quiet dune landscape, and the calendar sits on one big sheet of frosted glass. Single warm look by choice; its tone follows the time of day. */
:root {
  color-scheme: light;
  --ink: #2B2018;
  --ink-2: #47382C;
  --ink-3: #5F4E40;
  --accent: #5A3F2C;
  --accent-ink: #FBF5EC;
  --now: #A33F1C;
  --warn: #7A3E00;
  --rule: rgba(70, 46, 28, .15);
  --edge: rgba(255, 255, 255, .62);
  --shade: rgba(74, 48, 28, .18);
  --c-personal: #3B7CC4;
  --c-work: #B9661A;
  --c-family: #1F8A66;
  --c-other: #9460C8;
  --c-spare: #CC4F60;
  --c-holiday: #8A7868;
  --sky-1: #EBDCC9; --sky-2: #DCC6AE;
  --dune-1: #CFB497; --dune-2: #BEA080; --dune-3: #AB8B6B;
  --sun: #FFF6E5;
  --glass-1: rgba(255, 255, 255, .46);
  --glass-2: rgba(255, 255, 255, .2);
  --display: "Outfit", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --text: "Figtree", -apple-system, "Segoe UI", system-ui, sans-serif;
  --fs: clamp(13px, 1.6vw, 19px);
}
html[data-phase="morning"] { --sky-1: #F3E7D8; --sky-2: #E7D4BF; --dune-1: #DCC3A8; --dune-2: #CDAF90; --dune-3: #BA9877; --sun: #FFF2DA; }
html[data-phase="evening"] {
  --sky-1: #CDB39A; --sky-2: #AE9278; --dune-1: #9F8268; --dune-2: #8C7059; --dune-3: #775D49; --sun: #F2C79A;
  --glass-1: rgba(255, 244, 232, .46); --glass-2: rgba(255, 244, 232, .26); --edge: rgba(255, 244, 232, .45);
  --ink-2: #3E3025; --ink-3: #4A3A2D;
}
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
body { background: var(--sky-2); color: var(--ink); font-family: var(--text); font-size: var(--fs); line-height: 1.3; display: flex; flex-direction: column; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Scenery */
.scene, .scene svg, .sun { position: fixed; }
.scene { inset: 0; z-index: -1; background: linear-gradient(to bottom, var(--sky-1), var(--sky-2)); overflow: hidden; }
.scene svg { inset: 0; width: 100%; height: 100%; }
.scene .d1 { fill: var(--dune-1); }
.scene .d2 { fill: var(--dune-2); }
.scene .d3 { fill: var(--dune-3); }
.sun { width: 34vmin; height: 34vmin; margin: -17vmin 0 0 -17vmin; border-radius: 50%; background: radial-gradient(circle, var(--sun) 0 34%, transparent 70%); }

/* Glass */
.glass {
  position: relative; isolation: isolate;
  background: linear-gradient(140deg, var(--glass-1), var(--glass-2));
  -webkit-backdrop-filter: blur(16px) saturate(155%);
  backdrop-filter: blur(16px) saturate(155%);
  border: 1px solid var(--edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .72), inset 0 -1px 0 rgba(255, 255, 255, .16), 0 10px 28px var(--shade);
}
.glass::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .34) 0%, rgba(255, 255, 255, 0) 26%, rgba(255, 255, 255, 0) 74%, rgba(255, 255, 255, .13) 100%);
}
/* Small controls look like glass without paying for a live blur on an always-on screen. */
.bead {
  background: linear-gradient(140deg, rgba(255, 255, 255, .62), rgba(255, 255, 255, .34));
  border: 1px solid var(--edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .78), 0 3px 10px var(--shade);
  transition: transform .18s ease;
}
.bead:active, .primary:active { transform: scale(.96); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: rgba(246, 237, 226, .9); }
}
@media (prefers-reduced-transparency: reduce) {
  .glass { background: rgba(246, 237, 226, .94); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

.shell {
  flex: 1 1 auto; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 10px 14px;
}

/* Top */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.clockwrap { display: flex; align-items: center; gap: 14px; min-width: 0; }
.clock { display: flex; align-items: baseline; font: 200 clamp(56px, 8.6vw, 104px)/.92 var(--display); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.clock small { font-size: .26em; font-weight: 300; margin-left: .22em; letter-spacing: .02em; color: var(--ink-2); }
.datewrap { display: grid; gap: 3px; min-width: 0; }
.date { font: 500 clamp(17px, 2.1vw, 25px)/1.12 var(--display); text-wrap: balance; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--ink-2); min-height: 22px; }
.lamp { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.lamp[data-state="live"] { background: #3F8A5E; }
.lamp[data-state="wait"] { background: var(--c-work); animation: breathe 2.4s ease-in-out infinite; }
.lamp[data-state="stale"] { background: var(--warn); }
.lamp[data-state="off"] { background: var(--now); }
@keyframes breathe { 50% { opacity: .35; } }
.upnext { flex: 1 1 320px; min-width: 0; display: grid; gap: 4px; padding: 10px 18px; border-radius: 24px; min-height: 58px; align-content: center; width: auto; }
.un { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.un b { font-weight: 700; overflow-wrap: anywhere; font-size: 1.1em; }
.un span { color: var(--ink-2); font-weight: 500; }
.un .tag { font: 600 11px/1 var(--text); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); min-width: 2.9em; }
.un .tag.now { color: var(--now); }
.round { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; flex: none; }
.round svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Toolbar */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.seg { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 4px; border-radius: 26px; width: min(232px, 100%); font-size: 15px; }
.seg button { position: relative; z-index: 1; text-align: center; font-weight: 600; height: 36px; border-radius: 20px; color: var(--ink-2); transition: color .25s ease; }
.seg button[aria-pressed="true"] { color: var(--accent-ink); }
.thumb { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 3); border-radius: 20px; background: var(--accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .26), 0 2px 8px var(--shade); transition: transform .42s cubic-bezier(.3, 1.35, .5, 1); }
.nav { display: flex; align-items: center; gap: 6px; }
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 16px; border-radius: 22px; font-size: 15px; font-weight: 600; white-space: nowrap; text-decoration: none; }
.period { font: 500 clamp(18px, 2.1vw, 26px)/1.1 var(--display); margin-right: auto; min-width: 0; padding-inline: 4px; }
.period small { font: 500 12px/1 var(--text); color: var(--ink-3); margin-left: 8px; }
.cals { display: flex; flex-wrap: wrap; gap: 6px; }
.cal { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 13px; border-radius: 22px; font-size: 15px; font-weight: 500; white-space: nowrap; }
.cal i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: inset 0 1px 1px rgba(255, 255, 255, .45); }
.cal[aria-pressed="false"] { color: var(--ink-3); background: rgba(255, 255, 255, .16); box-shadow: none; }
.cal[aria-pressed="false"] i { background: none; box-shadow: inset 0 0 0 1.5px var(--c); }
.cal .warn { color: var(--warn); font-weight: 700; }
.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 20px; border-radius: 22px; font-size: 15px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .26), 0 6px 16px var(--shade); transition: transform .18s ease;
}
.primary[disabled] { opacity: .6; cursor: default; }

/* Stage */
.stage { border-radius: 28px; overflow: hidden; min-height: 0; touch-action: pan-y; }
.stage[data-view="day"] { overflow-y: auto; }
.enter > * { animation: settle .32s ease-out; }
@keyframes settle { from { opacity: .35; transform: translateY(5px); } }

.chip {
  display: grid; gap: 1px; width: 100%; padding: 7px 9px; border-radius: 13px; min-width: 0; color: var(--ink);
  background: rgba(255, 255, 255, .62);
  background: color-mix(in oklab, var(--c) 34%, rgba(255, 255, 255, .66));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .66), 0 1px 3px rgba(74, 48, 28, .16);
}
.chip .ct { font-size: .86em; font-weight: 500; color: var(--ink-2); }
.chip .cn { font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.chip .cw { font-size: .86em; color: var(--ink-2); overflow-wrap: anywhere; }
.chip.allday { background: color-mix(in oklab, var(--c) 58%, rgba(255, 255, 255, .5)); padding-block: 5px; }
.chip.free { background: color-mix(in oklab, var(--c) 14%, rgba(255, 255, 255, .34)); box-shadow: inset 0 0 0 1px var(--c); }
.chip.routine { background: rgba(255, 255, 255, .28); box-shadow: none; padding: 3px 9px; }
.chip.routine .ct, .chip.routine .cn { font-size: .84em; font-weight: 500; }
.chip.past { opacity: .5; }
.chip.on { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .66), 0 0 0 2px var(--accent); }
.chip.declined .cn { text-decoration: line-through; }
.chip:active { filter: brightness(1.05); }

/* Week */
.wk { height: 100%; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.wkcol { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; border-left: 1px solid var(--rule); }
.wkcol:first-child { border-left: 0; }
.wkcol[data-today] { background: rgba(255, 255, 255, .26); }
.wkhead { display: flex; align-items: center; gap: 7px; width: 100%; padding: 10px 10px 8px; min-height: 56px; }
.dow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.num { font: 300 clamp(24px, 3vw, 36px)/1 var(--display); }
[data-today] > .wkhead .num { display: grid; place-items: center; width: 1.55em; height: 1.55em; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 500; font-size: clamp(18px, 2.1vw, 25px); }
.wkitems { display: flex; flex-direction: column; gap: 6px; padding: 2px 7px 12px; min-height: 0; overflow-y: auto; }

/* Month */
.mo { height: 100%; display: grid; grid-template-rows: auto repeat(var(--rows), minmax(0, 1fr)); }
.mohead, .mow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-height: 0; }
.mohead div { padding: 8px 8px 6px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.mow { border-top: 1px solid var(--rule); }
.mcell { display: flex; flex-direction: column; gap: 2px; padding: 4px 5px; width: 100%; min-width: 0; min-height: 0; overflow: hidden; border-left: 1px solid var(--rule); }
.mow .mcell:first-child { border-left: 0; }
.mcell.out { opacity: .5; }
.mcell[data-today] { background: rgba(255, 255, 255, .26); }
.mnum { font: 500 14px/1 var(--display); padding: 3px 2px; align-self: flex-start; }
.mcell[data-today] .mnum { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.mini { display: block; padding: 1px 5px; border-radius: 6px; font-size: 12px; font-weight: 500; line-height: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(255, 255, 255, .6); background: color-mix(in oklab, var(--c) 34%, rgba(255, 255, 255, .6)); }
.mini.more { background: none; color: var(--ink-3); }

/* Day */
.dayall { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 12px 8px 4.2rem; background: rgba(244, 234, 222, .96); border-bottom: 1px solid var(--rule); }
.dayall .chip { width: auto; }
.daygrid { display: grid; grid-template-columns: 3.6rem minmax(0, 1fr); }
.dgut { position: relative; }
.dgut span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 12px; font-weight: 500; color: var(--ink-3); }
.dgut span:first-child { transform: none; }
.dcol { position: relative; border-left: 1px solid var(--rule); background-image: repeating-linear-gradient(to bottom, var(--rule) 0 1px, transparent 1px 56px); }
.dcol .chip { position: absolute; align-content: start; overflow: hidden; }
.nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--now); z-index: 2; pointer-events: none; }
.nowline::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--now); }
.emptyday { padding: 18px; color: var(--ink-2); }

/* Sheets */
dialog.sheet {
  color: var(--ink); border: 1px solid var(--edge); border-radius: 28px; padding: 20px;
  width: min(480px, calc(100vw - 32px)); max-height: calc(100% - 32px); overflow: auto;
  background: linear-gradient(140deg, rgba(252, 246, 238, .9), rgba(240, 228, 214, .82));
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  backdrop-filter: blur(28px) saturate(150%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8), 0 24px 60px rgba(60, 38, 20, .32);
}
dialog.sheet::backdrop { background: rgba(60, 40, 24, .3); }
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-top h2 { font: 500 24px/1.12 var(--display); overflow-wrap: anywhere; min-width: 0; }
.sheet form { display: grid; gap: 11px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span, .kv dt, .sect { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
/* 16px stops iPadOS zooming the page when a field gets focus. */
input[type="text"], input[type="password"], input[type="date"], input[type="time"], textarea {
  width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border-radius: 13px; border: 1px solid rgba(90, 63, 44, .28);
  background: rgba(255, 255, 255, .72); color: var(--ink); font: 400 16px/1.25 var(--text); -webkit-appearance: none; appearance: none;
}
textarea { resize: vertical; }
.twoup { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 8px; }
.calpick { display: flex; flex-wrap: wrap; gap: 6px; }
.calpick label { position: relative; }
.calpick input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.calpick span { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 12px; border-radius: 20px; border: 1px solid rgba(90, 63, 44, .28); background: rgba(255, 255, 255, .5); font-weight: 500; }
.calpick span i { width: 11px; height: 11px; border-radius: 50%; background: var(--c); }
.calpick input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.calpick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-weight: 500; }
.switchrow small { display: block; font-weight: 400; font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }
input[role="switch"] { -webkit-appearance: none; appearance: none; flex: none; position: relative; width: 52px; height: 31px; margin: 0; border-radius: 16px; background: rgba(90, 63, 44, .26); transition: background .25s ease; cursor: pointer; }
input[role="switch"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(60, 38, 20, .3); transition: transform .3s cubic-bezier(.3, 1.35, .5, 1); }
input[role="switch"]:checked { background: var(--accent); }
input[role="switch"]:checked::after { transform: translateX(21px); }
.err { color: var(--now); font-weight: 600; }
.fine { font-size: 12.5px; color: var(--ink-2); line-height: 1.35; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 4px; }
.sheet-actions .danger { color: var(--now); margin-right: auto; }
.kv { display: grid; gap: 10px; margin: 0 0 14px; }
.kv dd { margin: 2px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.calline { display: flex; align-items: center; gap: 7px; font-weight: 500; color: var(--ink-2); margin-bottom: 8px; }
.calline i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.settings { display: grid; gap: 14px; }
.settings section { display: grid; gap: 6px; }
.settings .sect { margin-bottom: 2px; }
.stack { display: flex; flex-wrap: wrap; gap: 6px; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: max(18px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); padding: 11px 20px; border-radius: 24px; font-weight: 600; max-width: calc(100vw - 32px); }
.notice { margin: 10px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); padding: 12px 18px; border-radius: 22px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.notice h2 { font: 600 16px/1.2 var(--text); }
.notice p { color: var(--ink-2); max-width: 70ch; }
.notice > div { flex: 1 1 260px; min-width: 0; }

/* Password screen */
html[data-locked="on"] .shell { display: none; }
.lock { margin: auto; width: min(380px, calc(100vw - 32px)); padding: 24px; border-radius: 28px; display: grid; gap: 12px; }
.lock h1 { font: 500 26px/1.15 var(--display); }

/* Overnight: black screen, dim red type, nothing that moves. The iPad's backlight stays on, so its brightness setting matters too. */
.night { display: none; }
html[data-night="on"], html[data-night="on"] body { background: #000; }
html[data-night="on"] .scene, html[data-night="on"] .shell { display: none; }
html[data-night="on"] .night {
  flex: 1 1 auto; min-height: 0; display: grid; align-content: center; justify-items: center; gap: 2.4vmin; text-align: center; color: #8A3316; padding-inline: 16px;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
.ng-clock { display: flex; align-items: baseline; font: 200 min(30vw, 54vh)/.86 var(--display); color: #A83C19; font-variant-numeric: tabular-nums; }
.ng-clock small { font-size: .17em; font-weight: 300; margin-left: .2em; color: #8A3316; }
.ng-date { font: 500 3.6vmin/1.1 var(--display); }
.ng-lines { display: grid; gap: 1vmin; font-size: 3vmin; line-height: 1.25; overflow-wrap: anywhere; }
.ng-warn { font-size: 2vmin; }
html[data-night="on"] .notice { filter: brightness(.4) sepia(.7); }
html[data-peek="on"] .shell, html[data-peek="on"] .scene { filter: brightness(.6); }

@media (orientation: portrait), (max-width: 760px) {
  .wk { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(7, minmax(min-content, 1fr)); height: auto; min-height: 100%; }
  .wkcol { grid-template-columns: 5.4rem minmax(0, 1fr); grid-template-rows: auto; border-left: 0; border-top: 1px solid var(--rule); min-height: 70px; }
  .wkcol:first-child { border-top: 0; }
  .wkhead { flex-direction: column; align-items: flex-start; gap: 3px; }
  .wkitems { flex-direction: row; flex-wrap: wrap; padding: 8px 8px 8px 0; align-content: center; overflow: visible; }
  .wkitems .chip { width: auto; flex: 1 1 170px; }
  .stage[data-view="week"] { overflow-y: auto; }
  #addBtn { margin-left: auto; }
  .clockwrap { order: 1; }
  #settingsBtn { order: 2; margin-left: auto; }
  .upnext { order: 3; flex: 1 1 100%; }
}
@media (max-width: 560px) {
  .mini { font-size: 0; padding: 0; height: 6px; border-radius: 3px; background: var(--c); }
  .mini.more { display: none; }
  .mcell { padding: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  .lamp[data-state="wait"] { animation: none; }
  .thumb, .bead, .primary, input[role="switch"]::after { transition: none; }
  .enter > * { animation: none; }
}
