:root { --night: #0b1026; --night2: #1a1f4a; --sun: #ffb347; --sun2: #ff7a59; --text: #f3f0ff; --dim: #9aa0c8; --ok: #7ee2a8; --bad: #ff8f8f;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); color: var(--text); background: linear-gradient(180deg, var(--night) 0%, var(--night2) 100%) fixed; transition: background 1.5s; }
body.up { background: linear-gradient(180deg, #2b3a8c 0%, #ff9e6b 70%, #ffd58a 100%) fixed; }
main { min-height: 100dvh; display: grid; place-items: center; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); }
section { width: min(420px, 100%); text-align: center; }
section[hidden], ol[hidden], #steps[hidden] { display: none; }
h1 { font-size: 46px; line-height: 1.02; margin: 0 0 28px; font-weight: 900; letter-spacing: -.01em; }
h1 em { font-style: normal; color: var(--sun); }
h2 { font-size: 26px; margin: 26px 0 6px; font-weight: 800; min-height: 32px; }
.note { color: var(--dim); margin: 0; min-height: 22px; font-size: 15px; }
.note.bad { color: var(--bad); }
.small { color: var(--dim); font-size: 13px; margin: 0 0 18px; }
form { display: grid; gap: 10px; }
input { font: inherit; font-size: 17px; padding: 14px 16px; border-radius: 14px; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.07); color: var(--text); outline: none; }
input:focus { border-color: var(--sun); }
form button { font: inherit; font-weight: 800; font-size: 17px; padding: 14px; border-radius: 14px; border: 0; background: var(--sun); color: #2a1500; cursor: pointer; }
.link { background: none; border: 0; color: var(--dim); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; margin-top: 26px; }

#stage { position: relative; width: 240px; height: 240px; margin: 8px auto 0; display: grid; place-items: center; }
#wake { position: relative; width: 200px; height: 200px; border-radius: 50%; border: 0; cursor: pointer; font: inherit; font-weight: 900; font-size: 24px; line-height: 1.1; color: #2a1500;
  background: radial-gradient(circle at 35% 30%, #ffe0a3, var(--sun) 55%, var(--sun2)); box-shadow: 0 12px 50px rgba(255,150,70,.45), inset 0 -8px 18px rgba(160,60,0,.25); transition: transform .12s, filter .3s, box-shadow .3s; }
#wake:active:not(:disabled) { transform: scale(.95); }
#wake:disabled { cursor: default; filter: grayscale(.85) brightness(.6); box-shadow: none; }
body.busy #wake:disabled { filter: none; box-shadow: 0 12px 50px rgba(255,150,70,.45); }
body.ringing #wake { animation: shake .5s infinite; }
@keyframes shake { 0%,100% { transform: rotate(0); } 20% { transform: rotate(-7deg); } 40% { transform: rotate(6deg); } 60% { transform: rotate(-4deg); } 80% { transform: rotate(3deg); } }
.rings i { position: absolute; inset: 20px; border-radius: 50%; border: 3px solid var(--sun); opacity: 0; }
body.ringing .rings i { animation: ring 1.5s ease-out infinite; }
body.ringing .rings i:nth-child(2) { animation-delay: .5s; } body.ringing .rings i:nth-child(3) { animation-delay: 1s; }
body.waiting .rings i:first-child { animation: ring 2.4s ease-out infinite; border-color: var(--dim); }
@keyframes ring { 0% { transform: scale(.85); opacity: .9; } 100% { transform: scale(1.45); opacity: 0; } }

#steps { list-style: none; padding: 0; margin: 22px auto 0; width: max-content; text-align: left; display: grid; gap: 9px; }
#steps li { position: relative; padding-left: 30px; color: var(--dim); font-size: 16px; }
#steps li::before { content: ""; position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); }
#steps li.done { color: var(--text); } #steps li.done::before { background: var(--ok); border-color: var(--ok); }
#steps li.now { color: var(--sun); font-weight: 700; } #steps li.now::before { border-color: var(--sun); animation: pulse 1s infinite; }
#steps li.failed { color: var(--bad); } #steps li.failed::before { border-color: var(--bad); background: var(--bad); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255,179,71,.25); } }
#phoneline { margin-top: 26px; } #phoneline b.on { color: var(--ok); } #phoneline b.off { color: var(--bad); }

#ask { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
#ask[hidden] { display: none; }
#ask button { font: inherit; font-weight: 800; font-size: 17px; padding: 14px 20px; border-radius: 14px; border: 0; cursor: pointer; }
#giveyes { background: var(--ok); color: #06301a; } #giveno { background: var(--sun2); color: #2a0d00; }
body.asking #wake { animation: nod 2.4s ease-in-out infinite; }
@keyframes nod { 50% { transform: rotate(-10deg) translateY(4px); } }

#chat { margin-top: 26px; text-align: left; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 16px; padding: 10px; }
#msgs { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 2px 2px 8px; }
#msgs:empty::before { content: "No messages yet. Say good morning."; color: var(--dim); font-size: 13px; padding: 6px; }
.msg { max-width: 82%; padding: 7px 11px; border-radius: 14px; font-size: 15px; line-height: 1.3; word-break: break-word; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--sun); color: #2a1500; border-bottom-right-radius: 4px; }
.msg.him { align-self: flex-start; background: rgba(255,255,255,.14); border-bottom-left-radius: 4px; }
.msg small { display: block; font-size: 10px; opacity: .6; margin-top: 2px; }
#chatform { display: flex; gap: 8px; }
#chatform input { flex: 1; min-width: 0; font-size: 15px; padding: 10px 12px; border-radius: 12px; }
#chatform button { width: 46px; padding: 0; border-radius: 12px; font-size: 18px; }

#hoursbox { margin: 24px auto 0; padding: 12px 16px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); width: fit-content; max-width: 100%; }
#hoursmain { font-size: 17px; font-weight: 800; } #hoursmain b { color: var(--sun); font-variant-numeric: tabular-nums; }
#hourssub { font-size: 13px; color: var(--dim); margin-top: 3px; }
#hoursbox.open { border-color: rgba(126,226,168,.5); } #hoursbox.open #hourssub b { color: var(--ok); }
#hoursbox.closed #hourssub b { color: var(--bad); }
#phoneline { margin-top: 14px; }

#hoursyours { font-size: 16px; font-weight: 700; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.12); }
#hoursyours b { color: var(--ok); font-variant-numeric: tabular-nums; } #hoursyours small { display: block; font-weight: 400; font-size: 12px; color: var(--dim); margin-top: 2px; }
#tzrow .link { margin-top: 6px; font-size: 12px; }
#tzpick { font: inherit; font-size: 14px; margin-top: 8px; padding: 8px; border-radius: 10px; background: #1a1f4a; color: var(--text); border: 1px solid rgba(255,255,255,.2); max-width: 100%; }
#tzpick[hidden] { display: none; }

/* ================= layout v2 (2026-10-08): the two things a friend can DO, wake and message, share the first screen ===== */
main { padding: 14px 18px calc(18px + env(safe-area-inset-bottom)); }
#home { width: min(960px, 100%); }
#top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 13px; color: var(--dim); }
#top .link { margin: 0; } #hello { margin: 0; }
#cols { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: center; }
#left, #right { min-width: 0; }
#right { display: grid; gap: 12px; }

/* phone first: a smaller sun, so the chat input is on screen without scrolling */
#stage { width: 190px; height: 190px; margin: 0 auto; }
#wake { width: 158px; height: 158px; font-size: 20px; }
.rings i { inset: 14px; }
h2 { font-size: 22px; margin: 12px 0 4px; min-height: 0; }
.note { font-size: 14px; min-height: 0; }
#steps { margin-top: 12px; gap: 6px; } #steps li { font-size: 15px; }
#ask { margin-top: 12px; }

#hoursbox { margin: 0; width: 100%; padding: 10px 14px; }
#hoursmain { font-size: 15px; } #hourssub { font-size: 12px; }
#hoursyours { font-size: 15px; margin-top: 7px; padding-top: 7px; }
#tzrow .link { margin-top: 2px; }
#phoneline { margin-top: 6px; font-size: 12px; color: var(--dim); }

#chat { margin: 0; display: flex; flex-direction: column; }
#chathead { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); padding: 2px 4px 8px; }
#msgs { height: clamp(64px, 16dvh, 200px); max-height: none; }
#msgs:empty::before { content: "Say good morning. He gets it on his phone, quietly if it is outside his wake hours."; }
#chatform input { font-size: 16px; }      /* 16px: iOS does not zoom the page when the box is focused */

/* wide screens: side by side, everything visible at once */
@media (min-width: 860px) {
  #cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; }
  #stage { width: 250px; height: 250px; } #wake { width: 208px; height: 208px; font-size: 25px; } .rings i { inset: 20px; }
  h2 { font-size: 27px; margin-top: 22px; } .note { font-size: 15px; }
  #hoursbox { padding: 14px 18px; } #hoursmain { font-size: 17px; } #hoursyours { font-size: 16px; }
  #msgs { height: clamp(180px, 38dvh, 380px); }
  #top { margin-bottom: 18px; }
}
/* short phones: give the chat what is left */
@media (max-height: 700px) and (max-width: 859px) { #stage { width: 150px; height: 150px; } #wake { width: 126px; height: 126px; font-size: 17px; } .rings i { inset: 10px; } }

/* ================= layout v3 (2026-10-08, his notes): the circle is the hero; hours are in the FRIEND'S time; chat is a side note === */
#home { width: min(1040px, 100%); }
#left { text-align: center; }
#hoursbox { margin: 16px auto 0; width: fit-content; max-width: 100%; padding: 0; background: none; border: 0; }
#hoursbox.open, #hoursbox.closed { border: 0; }
#hoursmain { font-size: 16px; font-weight: 700; color: var(--text); }
#hoursmain b { color: var(--sun); }
#hourssub { font-size: 12px; color: var(--dim); margin-top: 2px; }
#hourssub .link { margin: 0; font-size: 12px; }
#phoneline { margin-top: 10px; font-size: 12px; }
#phoneline b::before { content: "● "; }
#chat { padding: 10px; }
#msgs { height: clamp(56px, 13dvh, 150px); }
#msgs .msg { font-size: 14px; } #msgs:empty::before { font-size: 12px; }
@media (min-width: 860px) {
  #cols { grid-template-columns: minmax(0, 1fr) 320px; gap: 56px; }
  #stage { width: 320px; height: 320px; } #wake { width: 264px; height: 264px; font-size: 31px; } .rings i { inset: 26px; }
  h2 { font-size: 30px; margin-top: 24px; }
  #hoursmain { font-size: 17px; }
  #msgs { height: clamp(140px, 30dvh, 260px); }
  #right { align-self: center; }
}

/* ================= the button says whether it can be pressed (2026-10-08) =================
   body.live    his phone is connected AND his hours are open  → glowing, breathing sun; green LIVE badge
   body.offline his phone is not connected                     → grey moon, no glow, not clickable
   body.closed  outside his hours, or wake-ups switched off    → dimmed sun, not clickable                */
#live { display: inline-flex; align-items: center; gap: 8px; margin: 0 auto 14px; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 800; letter-spacing: .04em;
  background: rgba(255,255,255,.07); color: var(--dim); border: 1px solid rgba(255,255,255,.12); }
#live i { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; }
body.live #live { color: var(--ok); border-color: rgba(126,226,168,.45); background: rgba(126,226,168,.10); }
body.live #live i { background: var(--ok); animation: livedot 1.6s ease-out infinite; }
body.offline #live { color: var(--bad); border-color: rgba(255,143,143,.4); } body.offline #live i { background: var(--bad); }
@keyframes livedot { 0% { box-shadow: 0 0 0 0 rgba(126,226,168,.7); } 100% { box-shadow: 0 0 0 10px rgba(126,226,168,0); } }

/* live: it breathes, and a halo keeps leaving it. Movement is what says "this is connected right now". */
body.live:not(.busy) #wake { cursor: pointer; animation: breathe 3.2s ease-in-out infinite; }
body.live:not(.busy) #wake:hover { animation-play-state: paused; transform: scale(1.05); box-shadow: 0 16px 70px rgba(255,160,70,.75), inset 0 -8px 18px rgba(160,60,0,.25); }
body.live:not(.busy) .rings i { animation: halo 3.2s ease-out infinite; border-color: rgba(255,179,71,.55); border-width: 2px; }
body.live:not(.busy) .rings i:nth-child(2) { animation-delay: 1.06s; } body.live:not(.busy) .rings i:nth-child(3) { animation-delay: 2.12s; }
@keyframes breathe { 0%, 100% { transform: scale(1); box-shadow: 0 12px 50px rgba(255,150,70,.45), inset 0 -8px 18px rgba(160,60,0,.25); }
  50% { transform: scale(1.035); box-shadow: 0 14px 80px rgba(255,170,80,.8), inset 0 -8px 18px rgba(160,60,0,.25); } }
@keyframes halo { 0% { transform: scale(.9); opacity: .0; } 15% { opacity: .75; } 100% { transform: scale(1.5); opacity: 0; } }
#wake small { display: block; font-size: 12px; font-weight: 700; opacity: .65; margin-top: 6px; letter-spacing: .06em; text-transform: uppercase; }

/* not live: obviously asleep. No glow, no motion, the cursor says no. */
body.offline #wake:disabled, body.closed #wake:disabled { cursor: not-allowed; box-shadow: none; }
body.offline #wake:disabled { filter: none; color: #c9cde6; background: radial-gradient(circle at 35% 30%, #5a6088, #3a3f66 60%, #2a2e52); }
body.closed #wake:disabled { filter: grayscale(.55) brightness(.5); }
body.offline .rings i, body.closed .rings i { animation: none; opacity: 0; }
