/* ============================================================
   My Day Clock — kid-friendly daily schedule clock
   ============================================================ */

:root {
  --font: 'Baloo 2', 'Fredoka', 'Nunito', system-ui, -apple-system,
          'Segoe UI Rounded', 'SF Pro Rounded', 'Comic Sans MS', sans-serif;

  /* Default (day) palette — overridden by [data-tod] */
  --sky-1: #bfe3ff;
  --sky-2: #e9f6ff;
  --ink: #243a52;
  --ink-soft: #5b7088;
  --card: #ffffff;
  --card-2: #f3f8ff;
  --line: #dce7f3;
  --accent: #1f6feb;
  --good: #2bb673;
  --warn: #ff8a3d;
  --danger: #ef5350;
  --face: #fffdf7;
  --face-rim: #ffd977;
  /* Clock-face text is ALWAYS on a light face, so these stay dark in every theme (incl. night). */
  --face-ink: #22384f;
  --face-ink-soft: #4a607a;
  --hand: #2b4a6f;
  --shadow: 0 14px 40px rgba(31, 60, 92, 0.18);
  --shadow-soft: 0 6px 18px rgba(31, 60, 92, 0.12);
  --radius: 22px;
  /* Safe-area insets: default to CSS env() (web/iOS); the Android app overrides these
     with the real system-bar insets (env() on Android only covers a display cutout). */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* Time-of-day backgrounds */
.app[data-tod="dawn"]    { --sky-1:#ffd9a8; --sky-2:#ffeede; --ink:#5a3d2b; --face-rim:#ffb877; }
.app[data-tod="morning"] { --sky-1:#bfe3ff; --sky-2:#fff6e6; --ink:#243a52; --face-rim:#ffd977; }
.app[data-tod="day"]     { --sky-1:#9fd4ff; --sky-2:#e9f6ff; --ink:#22384f; --face-rim:#ffd45e; }
.app[data-tod="afternoon"]{ --sky-1:#ffd58a; --sky-2:#d8efff; --ink:#3a2f23; --face-rim:#ffc94d; }
.app[data-tod="evening"] { --sky-1:#caa6ff; --sky-2:#ffd9c2; --ink:#3a2a52; --face-rim:#ff9e7a; }
.app[data-tod="night"]   { --sky-1:#3a4a7a; --sky-2:#1c2440; --ink:#eaf0ff; --ink-soft:#aab8e0;
                           --card:#26305a; --card-2:#2e3a68; --line:#3c4a82; --face:#f3f0ff;
                           --hand:#2b3566; --shadow:0 14px 40px rgba(0,0,0,.4); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%;
  font-family: var(--font);
  color: var(--ink);
  overscroll-behavior: none;
}

body { overflow: hidden; }

.app {
  height: 100dvh; width: 100vw;
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--sky-2) 0%, var(--sky-1) 70%, var(--sky-1) 100%);
  transition: background 1.2s ease, color 1.2s ease;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
  position: relative;
  user-select: none;
}

/* ===================== Top bar ===================== */
.topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: clamp(10px, 2.2vmin, 22px) clamp(14px, 3vmin, 34px);
  gap: 12px;
}

.kid-title {
  font-size: clamp(15px, 3vmin, 30px);
  font-weight: 800; line-height: 1.05; letter-spacing: .3px;
  color: var(--ink); margin-bottom: 3px;
}
.day-name {
  font-size: clamp(28px, 6vmin, 64px);
  font-weight: 800; line-height: 1; letter-spacing: .5px;
  color: var(--ink);
}
.date-line {
  font-size: clamp(13px, 2.2vmin, 22px);
  font-weight: 600; color: var(--ink-soft); margin-top: 4px;
}

.weather {
  display: flex; align-items: center; gap: clamp(6px, 1.4vmin, 14px);
  background: var(--card);
  border: none; border-radius: 999px;
  padding: clamp(6px, 1.2vmin, 12px) clamp(12px, 2vmin, 20px);
  box-shadow: var(--shadow-soft);
  cursor: pointer; color: var(--ink);
  font-family: inherit;
}
.weather:active { transform: scale(.97); }
.wx-sky { width: clamp(34px, 6vmin, 64px); height: clamp(34px, 6vmin, 64px); display:inline-flex; }
.wx-sky svg, .wx-thermo svg { width: 100%; height: 100%; overflow: visible; }
.wx-thermo { width: clamp(16px, 2.6vmin, 26px); height: clamp(34px, 6vmin, 64px); display:inline-flex; }
.wx-readout { display: flex; flex-direction: column; line-height: 1.05; text-align: left; }
.wx-temp { font-size: clamp(20px, 3.6vmin, 38px); font-weight: 800; }
.wx-desc { font-size: clamp(11px, 1.7vmin, 16px); font-weight: 600; color: var(--ink-soft); }

/* ===================== Stage / clock ===================== */
.stage {
  flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 0; padding: 0 2vmin 1vmin;
  position: relative;
}
.clock-wrap {
  width: min(92vw, 78vh, 880px);
  aspect-ratio: 1 / 1;
  max-height: 78vh;
  filter: drop-shadow(var(--shadow));
  position: relative;
}
#clock { width: 100%; height: 100%; display: block; }

/* live digital time, lower-center of the clock face */
.digital-time {
  position: absolute; left: 50%; top: 63.5%; transform: translate(-50%, -50%);
  font-weight: 800; font-size: clamp(18px, 3.8vmin, 40px);
  color: var(--face-ink); letter-spacing: .5px; white-space: nowrap;
  background: rgba(255, 253, 247, .78); padding: 1px 16px; border-radius: 999px;
  pointer-events: none;
}

/* Clock element styling (SVG built in JS) */
.tick-hour { stroke: var(--face-ink); stroke-width: 6; stroke-linecap: round; opacity: .5; }
.tick-quarter { stroke: var(--face-ink-soft); stroke-width: 3; stroke-linecap: round; opacity: .4; }
.num-hour { fill: var(--face-ink); font-weight: 800; font-family: var(--font); }
.num-quarter { fill: var(--face-ink-soft); font-weight: 700; font-family: var(--font); }
.face-bg { fill: var(--face); }
.face-rim { fill: none; stroke: var(--face-rim); }
.hand-hour { fill: var(--hand); transition: transform .25s cubic-bezier(.34,1.56,.64,1); transform-origin: 500px 500px; }
.hand-hub { fill: var(--hand); }
.hand-hub-dot { fill: var(--face); }

.token-ring { fill: var(--card); stroke-width: 8; }
.token-emoji { text-anchor: middle; dominant-baseline: central; }
.event-spoke { stroke-width: 5; stroke-linecap: round; opacity: .42; }
.event-spoke.is-now { stroke-width: 8; opacity: .8; }
.token.is-now .token-ring { stroke-width: 12; animation: pulse 1.6s ease-in-out infinite; }
.token.is-now { animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 6px 14px rgba(31,60,92,.35)); }
.wedge-now { fill: var(--accent); opacity: .12; }

@keyframes pulse {
  0%,100% { stroke-opacity: .9; }
  50% { stroke-opacity: .35; }
}
@keyframes bob {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Now + Next banners */
.status-row {
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: center;
  margin-top: clamp(8px, 2vmin, 20px); max-width: 96vw;
}
.now-banner {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 10px 22px 10px 12px;
  box-shadow: var(--shadow-soft);
  max-width: 90vw;
}
.next-banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-2); color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 20px 8px 10px;
}
.next-banner .now-pic { width: clamp(34px, 5.5vmin, 52px); height: clamp(34px, 5.5vmin, 52px); font-size: clamp(20px, 4vmin, 32px); }
.next-banner .now-title { font-size: clamp(18px, 3vmin, 30px); }
.next-time { font-size: clamp(12px, 1.9vmin, 17px); font-weight: 700; color: var(--ink-soft); }
.now-pic { width: clamp(40px, 7vmin, 64px); height: clamp(40px, 7vmin, 64px);
  border-radius: 50%; overflow: hidden; flex: 0 0 auto; display:flex; align-items:center; justify-content:center;
  font-size: clamp(26px, 5vmin, 40px); background: var(--card-2); }
.now-pic img { width: 100%; height: 100%; object-fit: cover; }
.now-text { display: flex; flex-direction: column; line-height: 1.1; }
.now-label { font-size: clamp(11px, 1.7vmin, 15px); font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .6px; }
.now-title { font-size: clamp(22px, 4vmin, 40px); font-weight: 800; }

/* ===================== Child-proof settings entry ===================== */
.gear {
  position: absolute;
  bottom: calc(var(--sab) + 16px);
  right: calc(var(--sar) + 16px);
  width: 56px; height: 56px; border-radius: 50%;
  border: none; background: var(--card); color: var(--ink-soft);
  font-size: 26px; box-shadow: var(--shadow); z-index: 21; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.gear:active { transform: scale(.94); }

/* PIN pad */
.pin-scrim { z-index: 112; }
.pin-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 113; background: var(--card-2); color: var(--ink);
  border-radius: 26px; padding: 22px; width: min(320px, 92vw);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .4); text-align: center;
  animation: pop .2s cubic-bezier(.2, .9, .3, 1.2);
}
.pin-title { font-weight: 800; font-size: 20px; margin-bottom: 14px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin-bottom: 18px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink-soft); }
.pin-dots span.on { background: var(--accent); border-color: var(--accent); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-pad button { font-family: inherit; font-size: 24px; font-weight: 700; padding: 15px 0; border-radius: 16px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.pin-pad button:active { background: var(--accent); color: #fff; }
.pin-pad .pin-back { font-size: 20px; }
.pin-cancel { margin-top: 14px; background: none; border: none; color: var(--ink-soft); font-weight: 700; font-size: 15px; font-family: inherit; cursor: pointer; }

/* ===================== Settings panel ===================== */
.scrim, .modal-scrim {
  position: fixed; inset: 0; background: rgba(20,30,45,.45);
  z-index: 30; backdrop-filter: blur(2px);
}
.panel {
  position: fixed; top: 0; right: 0; height: 100dvh;
  width: min(440px, 100vw);
  background: var(--card-2); color: var(--ink);
  z-index: 31; box-shadow: -10px 0 40px rgba(0,0,0,.25);
  display: flex; flex-direction: column;
  animation: slideIn .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.panel-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
/* the settings drawer touches the top edge -> push its header below the status bar */
.panel > .panel-head { padding-top: calc(18px + var(--sat)); }
.panel-head h2 { margin: 0; font-size: 22px; font-weight: 800; }
.panel-body { flex: 1 1 auto; overflow-y: auto; padding: 16px; padding-bottom: calc(16px + var(--sab)); display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.card-title { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-soft); margin-bottom: 10px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-title-row .card-title { margin-bottom: 0; }
.hint { font-size: 13px; color: var(--ink-soft); margin: 8px 0 0; line-height: 1.4; }
.hint.inline { margin: 0; font-weight: 600; text-transform: none; letter-spacing: 0; }

/* day pills */
.day-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.day-pill {
  flex: 1 1 auto; min-width: 40px; padding: 10px 6px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--ink);
  font-weight: 700; font-size: 13px; cursor: pointer; font-family: inherit;
  display:flex; flex-direction:column; align-items:center; gap:2px;
}
.day-pill .dp-num { font-size: 16px; font-weight: 800; }
.day-pill.is-sel { background: var(--accent); color: #fff; border-color: var(--accent); }
.day-pill.is-today { outline: 2px solid var(--good); outline-offset: 1px; }

/* event list */
.event-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.event-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-2); border-radius: 14px; padding: 8px 10px; cursor: pointer;
  border: 1px solid var(--line);
}
.event-row:active { transform: scale(.99); }
.ev-pic { width: 44px; height: 44px; border-radius: 12px; overflow: hidden; flex: 0 0 auto;
  display:flex; align-items:center; justify-content:center; font-size: 26px; background: var(--card); }
.ev-pic img { width:100%; height:100%; object-fit: cover; }
.ev-meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.ev-name { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-time { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.ev-rep { font-size: 11px; color: var(--ink-soft); }
.empty { color: var(--ink-soft); font-size: 14px; text-align: center; padding: 14px; }

/* templates */
.template-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.tpl {
  flex: 0 0 auto; width: 76px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.tpl-pic { width: 60px; height: 60px; border-radius: 16px; overflow: hidden; display:flex; align-items:center; justify-content:center; font-size: 32px; background: var(--card-2); border: 2px solid var(--line); }
.tpl-pic img { width:100%; height:100%; object-fit: cover; }
.tpl-name { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 76px; }
.tpl-del { font-size: 11px; color: var(--danger); }

/* forms */
.loc-current { font-weight: 700; margin-bottom: 8px; }
.loc-controls { display: flex; gap: 8px; }
.loc-controls input { flex: 1 1 auto; }
input[type=text], input[type=time], select {
  font-family: inherit; font-size: 16px; padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); color: var(--ink);
}
input[type=time] { width: 100%; }
#kidName { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-weight: 700; font-size: 15px; padding: 8px 0; }
.switch-row + .switch-row { border-top: 1px solid var(--line); }
.switch-row select, .switch-row input[type=time] { width: auto; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }

.btn {
  font-family: inherit; font-weight: 800; font-size: 15px;
  border: none; border-radius: 14px; padding: 11px 18px;
  background: var(--accent); color: #fff; cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.btn:active { transform: scale(.97); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.ghost { background: var(--card-2); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.full { width: 100%; margin-top: 8px; }
.btn.danger { background: var(--danger); }
.btn.danger.ghost { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.danger.ghost.armed { background: var(--danger); color: #fff; }
.icon-btn { background: transparent; border: none; font-size: 22px; cursor: pointer; color: var(--ink-soft); }
.ver { text-align: center; font-size: 11px; color: var(--ink-soft); margin: 4px 0 20px; }

/* ===================== Event editor ===================== */
.editor {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(460px, 94vw); max-height: calc(92dvh - var(--sat) - var(--sab)); overflow: hidden;
  background: var(--card-2); color: var(--ink); border-radius: 26px; z-index: 41;
  box-shadow: 0 30px 80px rgba(0,0,0,.4); display: flex; flex-direction: column;
  animation: pop .26s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { transform: translate(-50%,-46%) scale(.94); opacity: 0; } to { transform: translate(-50%,-50%) scale(1); opacity: 1; } }
.editor-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 14px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; }
.field input[type=text], .field input[type=time] { text-transform: none; font-weight: 600; color: var(--ink); }
.field .opt { font-weight: 600; text-transform: none; opacity: .7; }
.time-row { display: flex; gap: 12px; }
.time-row .field { flex: 1; }

.pic-picker { display: flex; align-items: center; gap: 14px; }
.pic-preview { width: 72px; height: 72px; border-radius: 18px; background: var(--card); border: 2px dashed var(--line);
  display:flex; align-items:center; justify-content:center; font-size: 38px; overflow: hidden; flex: 0 0 auto; }
.pic-preview img { width:100%; height:100%; object-fit: cover; }
.pic-actions { display: flex; flex-direction: column; gap: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-top: 6px; }
.emoji-grid button { font-size: 22px; padding: 6px 0; border: none; background: var(--card); border-radius: 10px; cursor: pointer; }
.emoji-grid button.is-on { background: var(--accent); }

.color-grid { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.color-grid button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.color-grid button.is-on { border-color: var(--ink); transform: scale(1.1); }
.color-custom {
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer;
  position: relative; overflow: hidden; display: inline-block;
  background: conic-gradient(red, orange, yellow, lime, cyan, blue, magenta, red);
}
.color-custom.is-on { border-color: var(--ink); transform: scale(1.1); }
.color-custom input { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); opacity: 0; border: none; cursor: pointer; }

/* Colors settings card */
.color-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; font-weight: 700; font-size: 15px; }
.color-row + .color-row { border-top: 1px solid var(--line); }
.color-controls { display: flex; align-items: center; gap: 8px; }
.color-controls input[type=color] { width: 46px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: var(--card-2); cursor: pointer; padding: 2px; }
.color-controls .btn.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Header text stays legible over a custom background */
.app.custom-bg .day-name, .app.custom-bg .kid-title { color: #22384f; }
.app.custom-bg .date-line { color: #4a607a; }
.app.custom-bg.bg-dark .day-name, .app.custom-bg.bg-dark .kid-title { color: #f4f7ff; }
.app.custom-bg.bg-dark .date-line { color: #c7d3e8; }

.repeat-pills { display: flex; gap: 6px; }
.rep { flex: 1; padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 700; font-size: 13px; cursor: pointer; font-family: inherit; text-transform: none; letter-spacing: 0; }
.rep.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }
.dow-pills { display: flex; gap: 5px; margin-top: 8px; }
.dow { flex: 1; aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 800; font-size: 13px; cursor: pointer; font-family: inherit; }
.dow.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }
.save-tpl { text-transform: none; letter-spacing: 0; }

.editor-foot { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line); }
.editor-foot .spacer { flex: 1; }

/* toast */
.toast {
  position: fixed; bottom: calc(28px + var(--sab)); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--card);
  padding: 12px 22px; border-radius: 999px; font-weight: 700; z-index: 60;
  box-shadow: var(--shadow); animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===================== Timer ===================== */
.timer-btn {
  position: absolute; bottom: calc(var(--sab) + 16px); left: calc(var(--sal) + 16px);
  border: none; border-radius: 999px; padding: 12px 18px;
  background: var(--card); color: var(--ink); font-family: inherit; font-weight: 800; font-size: 16px;
  box-shadow: var(--shadow); z-index: 21; cursor: pointer;
}
.timer-btn:active { transform: scale(.96); }
.timer-btn.active { background: var(--accent); color: #fff; }

.timer-screen {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--sat) + 10px) calc(var(--sar) + 16px) calc(var(--sab) + 16px) calc(var(--sal) + 16px);
  background: radial-gradient(120% 90% at 50% -10%, var(--sky-2) 0%, var(--sky-1) 72%);
}
.timer-head { width: 100%; max-width: 600px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.timer-head h2 { margin: 0; font-size: 24px; font-weight: 800; color: var(--ink); }
.timer-head-spacer { width: 120px; }

.timer-picker { width: 100%; max-width: 440px; margin: auto; display: flex; flex-direction: column; gap: 16px; }
.timer-hint { text-align: center; font-size: 22px; font-weight: 800; color: var(--ink); margin: 0; }
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.preset { font-family: inherit; font-weight: 800; font-size: 16px; padding: 16px 0; border-radius: 16px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.preset:active { background: var(--accent); color: #fff; }
.custom-time { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; color: var(--ink-soft); }
.custom-time input { width: 84px; text-align: center; font-size: 22px; font-weight: 800; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.btn.big { padding: 16px; font-size: 19px; }
.timer-sound { justify-content: center; gap: 12px; color: var(--ink); border: 0 !important; }

.timer-running { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; min-height: 0; }
.timer-clock-wrap { width: min(86vw, 68vh, 720px); aspect-ratio: 1 / 1; filter: drop-shadow(var(--shadow)); }
#timerClock { width: 100%; height: 100%; display: block; }
.t-face { fill: var(--face); }
.t-wedge { fill: #ef4444; }
.t-tick { stroke: var(--face-ink); stroke-width: 6; stroke-linecap: round; opacity: .5; }
.t-hand { stroke: var(--hand); stroke-width: 16; stroke-linecap: round; }
.t-hub { fill: var(--face); }
.t-digital { fill: var(--face-ink); font-weight: 800; font-family: var(--font); }
.t-sub { fill: var(--ink-soft); font-size: 42px; font-weight: 800; font-family: var(--font); text-transform: uppercase; letter-spacing: 3px; }
.timer-controls { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* All-done flashing alarm */
.alarm-overlay {
  position: fixed; inset: 0; z-index: 130;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px;
  background: #000; animation: flashbg .9s infinite;
}
@keyframes flashbg { 0%, 49.99% { background: #000; } 50%, 99.99% { background: #fff; } }
.alarm-text {
  font-family: var(--font); font-weight: 800; font-size: clamp(48px, 16vw, 170px); line-height: 1;
  color: #ffd400; animation: flashtext .9s infinite;
}
@keyframes flashtext { 0%, 49.99% { color: #ffd400; } 50%, 99.99% { color: #ff3b3b; } }
.alarm-stop {
  font-family: inherit; font-weight: 800; font-size: 26px; padding: 16px 48px; border-radius: 999px;
  border: 4px solid #fff; background: #1f6feb; color: #fff; cursor: pointer; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}

/* ===================== Image cropper ===================== */
.crop-scrim { z-index: 44; }
.cropper {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(360px, 94vw); background: var(--card-2); color: var(--ink);
  border-radius: 26px; z-index: 45; box-shadow: 0 30px 80px rgba(0, 0, 0, .4);
  display: flex; flex-direction: column;
  animation: pop .22s cubic-bezier(.2, .9, .3, 1.2);
}
.crop-stage {
  position: relative; width: min(300px, 78vw); height: min(300px, 78vw);
  margin: 6px auto; border-radius: 18px; overflow: hidden; background: #111;
  touch-action: none; cursor: grab; align-self: center;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage img { position: absolute; left: 0; top: 0; max-width: none; user-select: none; -webkit-user-drag: none; }
.crop-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .38); pointer-events: none; }
.crop-controls { display: flex; align-items: center; gap: 12px; padding: 6px 22px 2px; }
.crop-controls input[type=range] { flex: 1; accent-color: var(--accent); }
.crop-zoom-ico { font-size: 18px; font-weight: 800; color: var(--ink-soft); }

/* ===================== Auth screen ===================== */
.auth-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(120% 90% at 50% -10%, #e9f6ff 0%, #9fd4ff 72%);
}
.auth-card {
  width: min(420px, 94vw); background: #fff; border-radius: 28px;
  box-shadow: 0 24px 70px rgba(31, 60, 92, .28); padding: 32px 26px; text-align: center;
}
.auth-logo { font-size: 56px; line-height: 1; }
.auth-title { font-size: 30px; font-weight: 800; color: #22384f; margin: 8px 0 4px; }
.auth-sub { color: #5b7088; font-weight: 600; margin: 0 0 20px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input { font-family: inherit; font-size: 17px; padding: 13px 16px; border-radius: 14px; border: 1px solid #dce7f3; background: #f3f8ff; color: #22384f; }
.auth-error { color: #ef5350; font-weight: 700; font-size: 14px; }
.auth-parent { display: flex; align-items: center; gap: 10px; text-align: left; font-size: 14px; font-weight: 600; color: #5b7088; }
.auth-parent input { width: 22px; height: 22px; accent-color: #1f6feb; flex: 0 0 auto; }
.auth-legal { font-size: 13px; color: #5b7088; margin: 12px 0 0; }
.auth-toggle { margin-top: 16px; background: none; border: none; color: #1f6feb; font-weight: 700; font-size: 15px; font-family: inherit; cursor: pointer; }

/* ===================== Account + Kids ===================== */
.acct-row { margin-bottom: 10px; }
.acct-user { font-weight: 800; }
.changepw { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.changepw input { width: 100%; }
.kid-switch { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.kid-pill { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card-2); color: var(--ink); font-weight: 800; font-size: 15px; cursor: pointer; font-family: inherit; }
.kid-pill.is-sel { background: var(--accent); color: #fff; border-color: var(--accent); }
.field2 { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; color: var(--ink-soft); }
.field2 input { color: var(--ink); font-weight: 600; }
#deleteKidBtn { margin-top: 12px; }

[hidden] { display: none !important; }

/* Landscape tablets: header smaller, clock dominant */
@media (orientation: landscape) and (max-height: 560px) {
  .day-name { font-size: clamp(22px, 7vmin, 40px); }
  .clock-wrap { width: min(70vh, 92vw); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition: none !important; }
}
