:root {
  --bg: #050506; --bezel: #0e0e11; --dial: #0b0b0d;
  --tick: #f2f2f4; --tick-minor: #6b6b73; --numeral: #f2f2f4; --numeral-dim: #7d7d86;
  --hand: #f4f4f6; --accent: #ff6a2b; --label: #f2f2f4; --label-dim: #9a9aa3; --muted: #8b8b94;
  --panel: #16161a;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body {
  height: 100%; margin: 0; background: var(--bg); color: var(--label); font-family: var(--font-sans);
  overflow: hidden; overscroll-behavior: none; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#app {
  position: fixed; inset: 0;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
           max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
#stage { position: absolute; inset: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) calc(max(8px, env(safe-area-inset-bottom)) + 18px) max(8px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: center; }
#clock { display: block; font-family: var(--font-sans); }

/* Corner controls sit outside the circle */
.corner { position: absolute; z-index: 5; }
.tl { top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); }
.tr { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
.bl { bottom: max(8px, env(safe-area-inset-bottom)); left: max(8px, env(safe-area-inset-left)); }
.row { display: flex; align-items: center; gap: 6px; }
.minimal .secondary { display: none !important; }
.minimal #minimal { color: #3d3d44; }
#eye-slash { display: none; } body:not(.minimal) #eye-slash { display: inline; }
#navlabel { margin: 6px 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.not-today #navlabel { color: var(--accent); }
.not-today #today { color: var(--accent); border-color: #823718; }
/* Last updated: dim, centred at the very bottom, below the dial (the stage leaves room for it). */
#status { position: absolute; z-index: 5; left: 50%; transform: translateX(-50%); bottom: max(6px, env(safe-area-inset-bottom)); width: max-content; max-width: 60vw; text-align: center; font-size: 11px; line-height: 1.3; color: #55555c; pointer-events: none; }
#status .warn { color: #7d6620; }

.ctl {
  display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px;
  border-radius: 999px; padding: 0; color: var(--muted); background: #121215;
  border: 1px solid #1f1f23; cursor: pointer; font-size: 22px; line-height: 1;
  transition: background .2s, color .2s;
}
.ctl.wide { padding: 0 14px; font-size: 12px; font-weight: 500; letter-spacing: .04em; }
.ctl:hover { color: #fff; background: #222226; }
.ctl:focus-visible, .field:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ctl svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.loading #refresh svg { animation: spin .9s linear infinite; }

.field { background: #1a1a1e; border: 1px solid #2c2c31; border-radius: 8px; padding: 6px 10px; font-size: 14px; min-height: 36px; }
.field option { background: #1a1a1e; }

#allday { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: min(70vw, 22rem); }
#allday .chip { display: flex; align-items: center; gap: 8px; max-width: 100%; border-radius: 999px; border: 1px solid #26262b; background: #0b0b0d; padding: 6px 12px; font-size: 12px; color: var(--label); }
#allday .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
#allday .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#allday .more { padding-left: 12px; font-size: 11px; color: var(--muted); }

/* Popovers */
.sheet {
  position: fixed; z-index: 30; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); width: min(92vw, 380px);
  transform: translateX(-50%); padding: 18px 18px 20px; border-radius: 20px; background: var(--panel);
  border: 1px solid #2c2c31; animation: sheet-in .28s cubic-bezier(.2,.8,.2,1);
}
.settings { max-height: calc(100dvh - 32px); overflow: auto; font-size: 14px; }
.settings .label { display: block; margin-top: 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.settings .line { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 40px; }
.settings input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.settings input[type=color] { width: 36px; height: 28px; border: 0; padding: 0; background: none; cursor: pointer; }
.settings .btns { display: flex; gap: 8px; margin-top: 14px; }
.settings .btns .ctl { flex: 1; font-size: 12px; }
.settings input.field.bad { border-color: #ef4444; }
@media (min-width: 640px) {
  .settings { left: auto; right: 16px; bottom: auto; top: 16px; transform: none; animation-name: sheet-in-side; }
}
@keyframes sheet-in { from { transform: translate(-50%, 14px) scale(.98); } to { transform: translate(-50%, 0) scale(1); } }
@keyframes sheet-in-side { from { transform: translateY(-8px) scale(.98); } to { transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Events entering the dial: arcs sweep in, markers pop, labels glide in; each staggered by --i. */
.anim .arc-sweep { stroke-dasharray: 100; animation: arc-sweep .75s cubic-bezier(.3,.7,.2,1) backwards; animation-delay: calc(var(--i) * 60ms); }
.anim .mk { transform-box: fill-box; transform-origin: center; animation: ev-pop .5s cubic-bezier(.3,1.5,.5,1) backwards; animation-delay: calc(140ms + var(--i) * 60ms); }
.anim .lb { transform-box: fill-box; transform-origin: center; animation: ev-glide .55s cubic-bezier(.2,.8,.2,1) backwards; animation-delay: calc(260ms + var(--i) * 60ms); }
@keyframes arc-sweep { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes ev-pop { from { transform: scale(0); } }
@keyframes ev-glide { from { transform: scale(0); } }
@media (prefers-reduced-motion: reduce) { .anim *, .sheet, .loading #refresh svg { animation: none !important; } }
