@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("../fonts/manrope.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --ink: #f6efe4;
  --ink-soft: rgba(246, 239, 228, 0.72);
  --ink-faint: rgba(246, 239, 228, 0.45);
  --glass: rgba(20, 18, 24, 0.34);
  --glass-strong: rgba(18, 16, 22, 0.62);
  --line: rgba(255, 244, 228, 0.16);
  --warm: #f3c58a;
  --night: #0b0d14;
  --fade: 1.1s;
  --pad: max(16px, env(safe-area-inset-left));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--night);
  color: var(--ink);
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 15px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);   /* the room strip may scroll, never widen the page */
  height: 100dvh;
}
button { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ room */
.scene { position: fixed; inset: 0; z-index: 0; background: var(--night); }
.bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0;
  transition: opacity 1.6s ease;
}
.bg.on { opacity: 1; }
.fx { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 1.2s ease; display: block; }
.fx.on { opacity: 1; }
.toggle small { color: var(--ink-faint); font-size: 12px; }
.veil {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 50% 42%, rgba(6, 7, 12, 0.28), transparent 70%),
    linear-gradient(to bottom, rgba(5, 6, 10, 0.45), transparent 22%, transparent 70%, rgba(5, 6, 10, 0.55));
  transition: opacity var(--fade) ease;
}
body.calm .veil { opacity: 0.55; }

/* ------------------------------------------------------------------ chrome that fades */
.ui { transition: opacity var(--fade) ease, transform var(--fade) ease; }
body.calm .ui { opacity: 0; pointer-events: none; }
body.calm .top.ui { transform: translateY(-6px); }
body.calm .bottom.ui { transform: translateY(6px); }
body.calm { cursor: none; }

.top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) var(--pad) 0;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); }
.mark { width: 22px; height: 22px; color: var(--warm); }
.brand-name { font-family: "Fraunces", serif; font-variation-settings: "SOFT" 100, "opsz" 24; font-size: 16px; letter-spacing: 0.01em; }
.top-actions { display: flex; gap: 6px; }

.icon-btn, .round-btn {
  display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  cursor: pointer; transition: background 0.25s, transform 0.15s, border-color 0.25s;
}
.icon-btn { width: 40px; height: 40px; border-radius: 12px; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover, .round-btn:hover { background: var(--glass-strong); border-color: rgba(255, 244, 228, 0.3); }
.round-btn:active, .icon-btn:active { transform: scale(0.96); }
:focus-visible { outline: 2px solid var(--warm); outline-offset: 3px; }

/* ------------------------------------------------------------------ timer */
.center {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 0 var(--pad);
  margin-top: -2vh;
}
.modes {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.mode-btn {
  border: 0; background: transparent; padding: 6px 16px; border-radius: 999px;
  color: var(--ink-soft); letter-spacing: 0.08em; text-transform: uppercase; font-size: 11.5px; font-weight: 600;
  cursor: pointer; transition: background 0.3s, color 0.3s;
}
.mode-btn[aria-checked="true"] { background: rgba(246, 239, 228, 0.16); color: var(--ink); }
.mode-btn:disabled { cursor: default; }

.time {
  font-family: "Fraunces", serif;
  font-variation-settings: "SOFT" 100, "WONK" 0, "opsz" 144;
  font-weight: 280;
  font-size: clamp(84px, min(26vw, 22vh), 640px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums lining-nums;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.35), 0 0 2px rgba(0, 0, 0, 0.25);
  transition: opacity 0.6s, font-weight 1.2s;
}
body.running .time { font-weight: 300; }
body.paused .time { opacity: 0.8; }
.progress {
  width: min(260px, 52vw); height: 2px; border-radius: 2px; overflow: hidden;
  background: rgba(246, 239, 228, 0.16);
}
.progress span {
  display: block; height: 100%; width: 0%; background: var(--warm);
  box-shadow: 0 0 12px rgba(243, 197, 138, 0.7); transition: width 0.9s linear;
}
.status {
  margin: 4px 0 0; min-height: 1.4em; color: var(--ink-soft); font-size: 14px; letter-spacing: 0.02em;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5);
  transition: opacity var(--fade);
}
body.calm .status { opacity: 0; }
.controls { display: flex; align-items: center; gap: 18px; margin-top: 14px; }
.round-btn { width: 52px; height: 52px; border-radius: 50%; }
.round-btn svg { width: 22px; height: 22px; }
.round-btn.primary {
  width: 76px; height: 76px; background: rgba(246, 239, 228, 0.9); color: #1b1712; border-color: transparent;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.round-btn.primary:hover { background: #fff8ee; }
.round-btn.primary svg { width: 28px; height: 28px; }
.i-pause, .i-muted { display: none; }
body.running .i-play { display: none; }
body.running .i-pause { display: block; }
body.muted .i-sound { display: none; }
body.muted .i-muted { display: block; }

/* ------------------------------------------------------------------ bottom bar */
.bottom {
  position: relative; z-index: 2;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 0 var(--pad) max(16px, env(safe-area-inset-bottom));
}
.rooms { display: flex; gap: 10px; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 4px; margin: -4px; }
.rooms::-webkit-scrollbar { display: none; }
.room {
  position: relative; flex: 0 0 auto; width: 112px;
  border: 0; padding: 0; background: none; cursor: pointer; text-align: left;
}
.room-thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  transition: border-color 0.3s, transform 0.3s;
}
.room-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.room:hover .room-thumb { transform: translateY(-2px); }
.room[aria-checked="true"] .room-thumb { border-color: var(--warm); box-shadow: 0 0 0 1px var(--warm), 0 6px 22px rgba(0, 0, 0, 0.35); }
.room-name { display: block; margin-top: 6px; font-size: 12px; color: var(--ink-soft); white-space: nowrap; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.room[aria-checked="true"] .room-name { color: var(--ink); }
.lock {
  position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(10, 10, 14, 0.6); color: var(--ink);
}
.lock svg { width: 12px; height: 12px; }
.room.locked .room-thumb img { filter: saturate(0.6) brightness(0.75); }

.volume {
  display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  margin-bottom: 22px;
}
.volume svg { width: 16px; height: 16px; color: var(--ink-soft); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 120px; height: 20px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: rgba(246, 239, 228, 0.25); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; margin-top: -6.5px;
  background: var(--ink); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}
input[type="range"]::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(246, 239, 228, 0.25); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--ink); }

/* ------------------------------------------------------------------ sheets */
.sheet {
  border: 1px solid var(--line); border-radius: 22px; padding: 0; color: var(--ink);
  background: rgba(22, 20, 26, 0.82);
  -webkit-backdrop-filter: blur(24px) saturate(1.2); backdrop-filter: blur(24px) saturate(1.2);
  width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.sheet::backdrop { background: rgba(4, 5, 8, 0.45); }
.sheet[open] { animation: rise 0.35s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.sheet-inner { padding: 26px 26px 18px; display: flex; flex-direction: column; gap: 16px; }
.sheet h2 { margin: 0; font-family: "Fraunces", serif; font-weight: 400; font-variation-settings: "SOFT" 100, "opsz" 48; font-size: 26px; }
.sheet h3 { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
.sheet p { margin: 0; color: var(--ink-soft); line-height: 1.55; }
.fine { font-size: 12.5px; color: var(--ink-faint) !important; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 12px; border-radius: 14px; background: rgba(246, 239, 228, 0.06); }
.stat-num { font-family: "Fraunces", serif; font-variation-settings: "SOFT" 100, "opsz" 72; font-size: 32px; font-weight: 350; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--ink-faint); }
.week-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 96px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar i { display: block; width: 100%; max-width: 22px; border-radius: 6px 6px 3px 3px; background: rgba(246, 239, 228, 0.18); min-height: 3px; }
.bar.today i { background: var(--warm); }
.bar b { font-weight: 500; font-size: 11px; color: var(--ink-faint); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field span { display: flex; justify-content: space-between; color: var(--ink-soft); }
.field output { color: var(--ink); font-variant-numeric: tabular-nums; }
.field input { width: 100%; }
.toggle { display: flex; align-items: center; gap: 12px; color: var(--ink-soft); cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--warm); }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; margin: 0 2px 0 8px; border-radius: 6px;
  border: 1px solid var(--line); background: rgba(246, 239, 228, 0.08); font: 600 11.5px "Manrope", sans-serif; color: var(--ink);
  text-align: center;
}
kbd:first-child { margin-left: 0; }
.keylist { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.keylist span { white-space: nowrap; }
.keylist kbd { margin: 0 4px 0 0; }
.text-btn { align-self: flex-end; border: 0; background: transparent; color: var(--warm); font-weight: 600; padding: 8px 4px; cursor: pointer; }
.primary-wide {
  border: 0; border-radius: 14px; padding: 14px; font-weight: 600; background: rgba(246, 239, 228, 0.9); color: #1b1712; cursor: pointer;
}
.primary-wide:disabled { background: rgba(246, 239, 228, 0.18); color: var(--ink-soft); cursor: default; }

@media (hover: none) { .pointer-only { display: none; } }

/* ------------------------------------------------------------------ phones */
@media (max-width: 640px) {
  .brand-name { display: none; }
  .bottom { flex-direction: column; align-items: stretch; gap: 12px; }
  .volume { align-self: center; margin-bottom: 0; }
  .room { width: 96px; }
  .rooms { justify-content: flex-start; }
  .controls { gap: 22px; }
}
/* tall screens: the timer sits in the upper part so the heart of the room shows below the controls */
@media (orientation: portrait) {
  .center { justify-content: flex-start; padding-top: clamp(24px, 9vh, 120px); margin-top: 0; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .center { margin-top: 0; gap: 4px; }
  .time { font-size: clamp(64px, 30vh, 150px); }
  .controls { margin-top: 6px; }
  .round-btn { width: 44px; height: 44px; }
  .round-btn.primary { width: 60px; height: 60px; }
  .room { width: 84px; }
  .room-name { display: none; }
  .bottom { flex-direction: row; align-items: flex-end; }
  .volume { margin-bottom: 4px; }
  .status { display: none; }
}
@media (min-width: 1800px) and (min-height: 1000px) {
  .top, .bottom, .modes, .controls, .status, .progress, .sheet { zoom: 1.2; }
}
/* 4K monitors at 100% scaling: grow the chrome with the screen (the timer already scales with vw/vh) */
@media (min-width: 2400px) and (min-height: 1300px) {
  .top, .bottom, .modes, .controls, .status, .progress, .sheet { zoom: 1.75; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01s !important; animation: none !important; }
}
