:root {
  --text: #fff;
  --text-2: rgba(255, 255, 255, .76);
  --muted: rgba(255, 255, 255, .54);
  --glass: rgba(20, 22, 40, .26);
  --sheen: linear-gradient(165deg, rgba(255, 255, 255, .16) 0%, rgba(255, 255, 255, .04) 40%, rgba(255, 255, 255, 0) 65%);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  font-family: -apple-system, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* still image under the live scene (and if scripts are off). On html, not body: a body
   background would paint over the z-index:-2 canvas. */
html { background: #0b0d1e url("bg.jpg") center 70% / cover no-repeat fixed; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh; min-height: 100dvh; color: var(--text); -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; align-items: center; overflow-x: hidden;
  padding: calc(9vh + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
.bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -2; opacity: 0; transition: opacity .9s ease; }
.bg.on { opacity: 1; }
/* soft shade top and bottom so text stays readable on any sky or photo */
.shade { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(5, 6, 16, .42) 0%, rgba(5, 6, 16, .06) 42%, rgba(5, 6, 16, .08) 70%, rgba(5, 6, 16, .42) 100%); }
[data-phase="day"] .shade { background: linear-gradient(180deg, rgba(10, 30, 60, .36) 0%, rgba(10, 30, 60, .04) 45%, rgba(10, 20, 30, .1) 70%, rgba(5, 10, 16, .45) 100%); }

/* ---------- greeting, title, clock ---------- */
.hello { text-align: center; position: relative; will-change: transform;
  --shadow: 0 2px 22px rgba(0, 0, 0, .32); text-shadow: var(--shadow); }
.greet { font-size: clamp(17px, 2.2vw, 22px); font-weight: 600; color: var(--text-2); letter-spacing: .01em; min-height: 1.3em; }
h1 { margin: 6px 0 0; font-size: clamp(40px, 7vw, 78px); font-weight: 700; letter-spacing: -.035em; line-height: 1.04; cursor: default; }
.ch { display: inline-block; white-space: pre;
  translate: 0 calc(var(--lift, 0) * -1px);
  text-shadow: 0 0 calc(var(--glow, 0) * 26px) rgba(255, 255, 255, calc(var(--glow, 0) * .55)), var(--shadow);
  animation: rise 1.1s var(--ease-out) backwards; animation-delay: calc(var(--i) * 38ms + var(--base, 0ms)); }
@keyframes rise {
  from { opacity: 0; transform: translateY(.45em) rotateX(-40deg); filter: blur(10px); }
}

.time { margin-top: 24px; font-size: clamp(64px, 12vw, 136px); font-weight: 600; letter-spacing: -.05em; line-height: 1;
  font-variant-numeric: tabular-nums; display: inline-flex; align-items: flex-start; justify-content: center;
  animation: fadeUp 1.2s var(--ease-out) .45s backwards; }
.time small { font-size: .32em; font-weight: 500; color: var(--text-2); letter-spacing: -.01em; margin-left: .14em; margin-top: .13em; display: inline-flex; }
/* digits clip their rolling strip, so they can't carry a text-shadow (it'd be cut into boxes);
   the whole clock gets one drop-shadow instead */
.time { text-shadow: none; filter: drop-shadow(0 2px 18px rgba(0, 0, 0, .3)); }
[data-phase="day"] .time { filter: drop-shadow(0 2px 16px rgba(10, 30, 60, .5)) drop-shadow(0 1px 2px rgba(10, 30, 60, .3)); }
.d { display: inline-block; height: 1em; overflow: hidden; line-height: 1; }
.d .strip { display: flex; flex-direction: column; transition: transform .75s cubic-bezier(.2, 1.15, .35, 1); }
.d .strip b { font-weight: inherit; height: 1em; line-height: 1; display: block; }
.d.snap .strip { transition: none; }
.colon { display: inline-block; width: .3em; text-align: center; transition: opacity .5s ease; margin-top: -.06em; }
.colon.dim { opacity: .35; }
.date { margin-top: 12px; font-size: clamp(16px, 2vw, 20px); font-weight: 500; color: var(--text-2);
  animation: fadeUp 1.2s var(--ease-out) .6s backwards; }
.date b { color: var(--text); font-weight: 600; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); filter: blur(6px); } }

/* ---------- app buttons ---------- */
.apps-wrap { position: relative; margin-top: auto; padding-top: 56px; width: 100%; display: flex; justify-content: center; }
.apps { display: grid; grid-template-columns: repeat(2, minmax(0, 300px)); gap: 18px; width: 100%; justify-content: center; }
.app {
  --rx: 0deg; --ry: 0deg; --tx: 0px; --ty: 0px; --s: 1; --px: 50%; --py: 50%; --hover: 0; --ix: 0px; --iy: 0px;
  position: relative; isolation: isolate; display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; border-radius: 28px; text-decoration: none; color: var(--text);
  background: var(--sheen), var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(170%); backdrop-filter: blur(20px) saturate(170%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25),
              0 calc(30px + var(--hover) * 16px) calc(60px + var(--hover) * 20px) -30px rgba(0, 0, 0, .75),
              0 2px 8px -2px rgba(0, 0, 0, .3);
  transform: perspective(900px) translate3d(var(--tx), var(--ty), 0) rotateX(var(--rx)) rotateY(var(--ry)) scale(var(--s));
  will-change: transform;
  animation: cardIn 1.1s var(--ease-out) backwards; animation-delay: calc(.75s + var(--n) * .12s);
  transition: filter .6s ease, opacity .6s ease;
}
@keyframes cardIn { from { opacity: 0; transform: perspective(900px) translateY(36px) rotateX(18deg) scale(.94); filter: blur(8px); } }
/* rim light: brightest where the pointer is */
.app::before, .lock::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background:
    radial-gradient(160px circle at var(--px) var(--py), rgba(255, 255, 255, calc(.25 + var(--hover) * .7)), transparent 70%),
    linear-gradient(150deg, rgba(255, 255, 255, .55) 0%, rgba(255, 255, 255, .12) 25%, rgba(255, 255, 255, .04) 60%, rgba(255, 255, 255, .26) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
/* specular highlight that slides across the glass under the pointer */
.spec { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
  background: radial-gradient(240px circle at var(--px) var(--py), rgba(255, 255, 255, .16), transparent 65%);
  opacity: var(--hover); transition: opacity .35s ease; }
.app img { width: 58px; height: 58px; border-radius: 15px; flex: none; box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .7);
  transform: translate(var(--ix), var(--iy)) scale(calc(1 + var(--hover) * .06)); transition: box-shadow .3s; }
.app .txt { transform: translate(calc(var(--ix) * .45), calc(var(--iy) * .45)); }
.app b { display: block; font-size: 19px; font-weight: 650; letter-spacing: -.015em; }
.app .txt span { display: block; font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.chev { margin-left: auto; width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
  transform: translateX(calc(var(--hover) * 4px)); transition: stroke .3s; }
.app:hover .chev { stroke: var(--text); }
.app:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
.app.launch { transition: transform .45s var(--ease-out), opacity .45s; --s: 1.06; }

.locked .apps .app { filter: grayscale(1) brightness(.7); opacity: .55; pointer-events: none; }
.app.pop { animation: pop .8s var(--spring) backwards; animation-delay: calc(var(--n) * .09s + .15s); }
@keyframes pop { from { transform: perspective(900px) translateY(10px) scale(.92); filter: grayscale(1) brightness(.7) blur(2px); opacity: .55; } }

/* ---------- lock panel ---------- */
.lock {
  --px: 50%; --py: 50%; --hover: 0; --rx: 0deg; --ry: 0deg;
  position: absolute; left: 50%; top: 40px; bottom: -16px; width: min(660px, 100%);
  display: grid; place-items: center; border-radius: 34px; z-index: 2; isolation: isolate;
  background: rgba(40, 42, 52, .42);
  -webkit-backdrop-filter: blur(14px) grayscale(1); backdrop-filter: blur(14px) grayscale(1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 30px 60px -30px rgba(0, 0, 0, .6);
  transform: translateX(-50%) perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: opacity .7s ease, visibility .7s, -webkit-backdrop-filter .7s, backdrop-filter .7s, scale .7s var(--ease-out);
  animation: lockIn 1.1s var(--ease-out) .9s backwards;
}
@keyframes lockIn { from { opacity: 0; transform: translateX(-50%) translateY(16px); filter: blur(6px); } }
body:not(.locked) .lock { opacity: 0; visibility: hidden; scale: 1.05;
  -webkit-backdrop-filter: blur(0) grayscale(0); backdrop-filter: blur(0) grayscale(0); }
.unlock-btn, .pw button {
  --mx: 0px; --my: 0px;
  font: inherit; color: #fff; border: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 9px; position: relative; overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, .26), rgba(255, 255, 255, .10));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), inset 0 0 0 1px rgba(255, 255, 255, .14), 0 10px 24px -10px rgba(0, 0, 0, .6);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.unlock-btn { padding: 13px 26px; border-radius: 99px; font-size: 16px; font-weight: 600;
  transform: translate(var(--mx), var(--my)); transition: transform .5s var(--spring), background .3s; }
.unlock-btn:hover { background: linear-gradient(180deg, rgba(255, 255, 255, .34), rgba(255, 255, 255, .14)); }
.unlock-btn:active { transform: translate(var(--mx), var(--my)) scale(.96); transition-duration: .1s; }
/* light sweep across the button now and then */
.unlock-btn::after { content: ""; position: absolute; inset: -2px; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .35) 50%, transparent 65%);
  transform: translateX(-120%); }
.unlock-btn.sweep::after { animation: sweep 1.1s var(--ease-out); }
@keyframes sweep { to { transform: translateX(120%); } }
.unlock-btn svg, .pw button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.shackle { transform-origin: 16px 11px; transition: transform .45s var(--spring); }
.lock.opening .shackle { transform: translateY(-2.5px) rotate(28deg); }
.lock.opening .unlock-btn, .lock.opening .pw button { background: linear-gradient(180deg, rgba(52, 199, 89, .75), rgba(36, 160, 70, .6)); }
.pw { display: flex; flex-direction: column; align-items: center; gap: 10px; animation: fadeUp .5s var(--ease-out) backwards; }
.pw-row { display: flex; gap: 8px; }
.pw input {
  width: min(260px, 60vw); font: inherit; font-size: 16px; color: #fff; padding: 12px 18px; border-radius: 99px; outline: none;
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(0, 0, 0, .28); transition: border-color .2s, box-shadow .2s;
}
.pw input::placeholder { color: rgba(255, 255, 255, .5); }
.pw input:focus { border-color: rgba(255, 255, 255, .6); box-shadow: 0 0 0 4px rgba(255, 255, 255, .12); }
.pw button { width: 46px; height: 46px; border-radius: 50%; justify-content: center; flex: none; transition: transform .2s var(--spring), background .3s; }
.pw button:active { transform: scale(.92); }
.pw .err { font-size: 13px; color: #ffb4ab; min-height: 18px; text-align: center; max-width: 320px; }
.shake { animation: shake .45s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake { 15%, 55% { transform: translateX(-8px); } 35%, 75% { transform: translateX(8px); } 90% { transform: translateX(-2px); } }

footer { margin-top: 22px; font-size: 12px; color: var(--muted); animation: fadeUp 1s ease 1.2s backwards; }

/* ---------- bottom-left: LOCK + THEMES ---------- */
.corner { position: fixed; left: calc(16px + env(safe-area-inset-left)); bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; z-index: 10; animation: fadeUp 1s var(--ease-out) 1.3s backwards; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 13px 0 11px; border-radius: 99px; border: 0; cursor: pointer;
  font: inherit; font-size: 11px; font-weight: 700; letter-spacing: .09em; color: var(--text-2);
  background: var(--sheen), rgba(20, 22, 40, .32);
  -webkit-backdrop-filter: blur(18px) saturate(170%); backdrop-filter: blur(18px) saturate(170%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 0 0 1px rgba(255, 255, 255, .08), 0 8px 20px -10px rgba(0, 0, 0, .6);
  transition: color .2s, transform .35s var(--spring), background .2s;
}
.chip:hover { color: #fff; transform: translateY(-2px); background: var(--sheen), rgba(40, 42, 70, .4); }
.chip:active { transform: scale(.95); }
.chip svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chip[aria-expanded="true"] { color: #fff; background: var(--sheen), rgba(60, 64, 100, .45); }
body.locked #lockChip { display: none; }

.themes {
  position: fixed; left: calc(16px + env(safe-area-inset-left)); bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 11;
  width: 300px; padding: 12px; border-radius: 22px;
  background: var(--sheen), rgba(18, 20, 34, .55);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), inset 0 0 0 1px rgba(255, 255, 255, .08), 0 30px 60px -20px rgba(0, 0, 0, .7);
  transform-origin: 20px calc(100% + 30px);
  transition: opacity .25s ease, transform .4s var(--spring), visibility .25s;
}
.themes:not(.open) { opacity: 0; visibility: hidden; transform: translateY(8px) scale(.94); }
.themes h4 { margin: 2px 6px 10px; font-size: 11px; font-weight: 700; letter-spacing: .09em; color: var(--muted); }
.theme-opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 0; border-radius: 14px; cursor: pointer;
  font: inherit; color: var(--text); text-align: left; background: transparent; transition: background .2s; }
.theme-opt:hover { background: rgba(255, 255, 255, .07); }
.theme-opt[aria-checked="true"] { background: rgba(255, 255, 255, .11); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); }
.theme-opt .thumb { width: 74px; height: 46px; border-radius: 10px; flex: none; background-size: cover; background-position: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 4px 10px -4px rgba(0, 0, 0, .6); }
.theme-opt b { display: block; font-size: 14px; font-weight: 650; }
.theme-opt span { display: block; font-size: 12px; color: var(--text-2); margin-top: 1px; }
.theme-opt .tick { margin-left: auto; width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity .2s; }
.theme-opt[aria-checked="true"] .tick { opacity: 1; }
.theme-opt:disabled { opacity: .45; cursor: default; }

/* leaving for an app: the scene dims as the card swells */
.curtain { position: fixed; inset: 0; background: #07080f; opacity: 0; pointer-events: none; z-index: 20; transition: opacity .42s ease; }
body.leaving .curtain { opacity: 1; }

@media (max-width: 600px) {
  body { padding-top: calc(7vh + env(safe-area-inset-top)); }
  .apps-wrap { padding-top: 40px; }
  .apps { grid-template-columns: 1fr; max-width: 420px; gap: 12px; }
  .app { padding: 14px 16px; border-radius: 24px; }
  .app img { width: 50px; height: 50px; border-radius: 13px; }
  .lock { top: 28px; bottom: -12px; border-radius: 28px; }
  footer { align-self: flex-end; margin-right: 4px; }      /* clear of LOCK / THEMES on the left */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}

/* bright daytime sky: a firmer shadow keeps white text crisp */
[data-phase="day"] .hello { --shadow: 0 2px 18px rgba(10, 30, 60, .5), 0 1px 2px rgba(10, 30, 60, .35); }
