/* ============================================================
   Pomodoro — thin liquid-glass theme v3
   Airy, semi-transparent, compact. True iOS liquid glass:
   thin gradient, specular rim, ambient tint. Nothing dominates.
   ============================================================ */
:root {
  --glass-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.28),
                  inset 0 1px 0 rgba(255, 255, 255, 0.28),
                  inset 0 -1px 0 rgba(255, 255, 255, 0.05);
  --ambient: transparent; /* set from video frame sampling */
  --text: #f5f7fa;
  --text-dim: rgba(245, 247, 250, 0.62);
  --accent: #7dd3fc;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

body {
  font-family: var(--font);
  color: var(--text);
  overflow: hidden;
  background: #0b0e14;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Thin liquid glass primitive ---------- */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(12px) saturate(180%) contrast(105%);
  backdrop-filter: blur(12px) saturate(180%) contrast(105%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow), inset 0 0 32px var(--ambient);
}

.glass-btn {
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  -webkit-backdrop-filter: blur(12px) saturate(180%) contrast(105%);
  backdrop-filter: blur(12px) saturate(180%) contrast(105%);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  cursor: pointer;
  padding: 7px 11px;
  font-size: 13px;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.glass-btn:hover { background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.06)); transform: translateY(-1px); }
.glass-btn:active { transform: translateY(1px) scale(.97); }
.glass-btn.small { padding: 5px 10px; font-size: 12px; border-radius: 11px; }
.glass-btn.wide { width: 100%; margin-top: 6px; }
.glass-btn.danger { border-color: rgba(255, 120, 120, 0.45); color: #ffc9c9; }
.glass-btn.active { background: rgba(125, 211, 252, 0.20); border-color: rgba(125, 211, 252, 0.45); }

.icon { width: 18px; height: 18px; fill: currentColor; }
.hidden { display: none !important; }

/* ---------- Background (double-buffered) ---------- */
.bg-layer { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: #0b0e14; }
.bg-gradient {
  position: absolute; inset: 0;
  background: linear-gradient(120deg, #1b2a4a, #3b1f4e 45%, #0e3a3a 80%, #1b2a4a);
  background-size: 300% 300%;
  animation: bgdrift 24s ease-in-out infinite alternate;
}
@keyframes bgdrift {
  from { background-position: 0% 20%; }
  to   { background-position: 100% 80%; }
}
.bg-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .8s ease;
}
.bg-video.on { opacity: 1; }
/* YouTube background engine: zoomed iframe, chrome cropped away */
.bg-yt {
  position: absolute; top: 50%; left: 50%;
  width: 100%; height: 100%;
  border: 0;
  transform: translate(-50%, -50%) scale(1.35);
  transform-origin: center;
  opacity: 0;
  transition: opacity .8s ease;
  pointer-events: none;
}
.bg-yt.on { opacity: 1; }
.bg-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.38) 100%);
  pointer-events: none;
}

/* ---------- Floating clock (NO box) ---------- */
.clock-float {
  position: fixed;
  z-index: 20;
  padding: 14px 18px;
  text-align: center;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.clock-float.centered { left: 50%; top: 42%; transform: translate(-50%, -50%); }
.clock-float.dragging { cursor: grabbing; scale: 1.03; filter: brightness(1.12); transition: scale .35s cubic-bezier(.2, 1.6, .4, 1), filter .2s ease; }

.clock-face { display: block; }

/* ---------- 12 clock styles (Google Fonts, boxless) ---------- */
.time-display {
  font-variant-numeric: tabular-nums;
  transition: color 1.2s ease, text-shadow 1.2s ease;
}
/* 1 — Tipis Udara */
.clock-float[data-clock-style="air"] .time-display {
  font-family: "Plus Jakarta Sans", -apple-system, "SF Pro Display", system-ui, sans-serif;
  font-weight: 200; letter-spacing: -0.04em;
}
/* 2 — Editorial Klasik */
.clock-float[data-clock-style="vogue"] .time-display {
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-weight: 300; font-style: italic; letter-spacing: -0.02em;
}
/* 3 — Sinema Jepang */
.clock-float[data-clock-style="kyoto"] .time-display {
  font-family: "Shippori Mincho", "Hiragino Mincho ProN", Georgia, serif;
  font-weight: 400; letter-spacing: 0.02em;
}
/* 4 — Swiss Arsitek */
.clock-float[data-clock-style="bauhaus"] .time-display {
  font-family: "Space Grotesk", -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-weight: 300; letter-spacing: -0.05em;
}
/* 5 — Kapsul Tinggi */
.clock-float[data-clock-style="kapsul"] .time-display {
  font-family: "Antonio", "Arial Narrow", sans-serif;
  font-weight: 200; letter-spacing: 0.04em;
}
/* 6 — Mesin Ketik Senja */
.clock-float[data-clock-style="ketik"] .time-display {
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-weight: 100; letter-spacing: -0.06em;
}
/* 7 — Kaca Organik */
.clock-float[data-clock-style="organik"] .time-display {
  font-family: "Quicksand", "Comfortaa", -apple-system, sans-serif;
  font-weight: 300; letter-spacing: -0.03em;
}
/* 8 — Galeri Seni */
.clock-float[data-clock-style="galeri"] .time-display {
  font-family: "Bodoni Moda", "Didot", Georgia, serif;
  font-weight: 400; letter-spacing: -0.03em;
}
/* 9 — Garis Ganda */
.clock-float[data-clock-style="kawat"] .time-display {
  font-family: "Bungee Hairline", "Arial Narrow", sans-serif;
  font-weight: 400; letter-spacing: 0.02em;
}
/* 10 — Nordik Minimal */
.clock-float[data-clock-style="nordik"] .time-display {
  font-family: "Outfit", -apple-system, "Helvetica Neue", sans-serif;
  font-weight: 100; letter-spacing: -0.03em;
}
/* 11 — Sastra Romantis */
.clock-float[data-clock-style="puisi"] .time-display {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400; font-style: italic; letter-spacing: -0.01em;
}
/* 12 — Vertikal Zen: stacked, no colon */
.clock-float[data-clock-style="zen"] .time-display {
  font-family: "DM Sans", -apple-system, sans-serif;
  font-weight: 200;
  font-size: clamp(4rem, 17vw, 7rem);
  line-height: 0.88;
  display: flex; flex-direction: column; align-items: center;
}
.clock-float[data-clock-style="zen"] .time-display .colon { display: none; }
.clock-float[data-clock-style="zen"] .time-display .mm,
.clock-float[data-clock-style="zen"] .time-display .ss { display: block; }

.mode-label {
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.65;
  margin-bottom: 2px;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
}
.time-display {
  font-size: clamp(3rem, 13vw, 5.5rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35), 0 12px 48px rgba(0, 0, 0, 0.45);
}
/* Mode Mengalir: warm champagne glow */
.clock-float.overtime .time-display {
  color: rgba(255, 230, 180, 0.95);
  text-shadow: 0 0 18px rgba(255, 200, 120, 0.45), 0 2px 12px rgba(0, 0, 0, 0.35), 0 12px 48px rgba(0, 0, 0, 0.45);
}

/* colon breathe */
.time-display .colon { animation: colonBreathe 2s ease-in-out infinite; }
.clock-float:not(.running) .time-display .colon { animation-play-state: paused; opacity: .95; }
@keyframes colonBreathe { 0%, 100% { opacity: .95; } 50% { opacity: .3; } }

.session-dots { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }
.session-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  transition: background .3s ease;
}
.session-dots i.done { background: var(--accent); }

/* breathing transition (4-7-8-ish over 15s) */
.clock-inner.breathing { animation: breathe15 15s ease-in-out; }
@keyframes breathe15 {
  0%   { transform: scale(1); }
  27%  { transform: scale(1.06); }
  73%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* Satu Hal — one intention line */
.one-thing {
  margin-top: 10px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: filter .6s ease, opacity .6s ease;
}
.one-thing input {
  background: transparent; border: none; outline: none;
  color: var(--text); opacity: 0.55;
  font-size: 12px; letter-spacing: 0.04em; text-align: center;
  width: 190px; max-width: 60vw;
  border-bottom: 1px solid transparent;
  transition: opacity .2s ease, border-color .2s ease;
  font-family: var(--font);
}
.one-thing input::placeholder { color: rgba(245, 247, 250, 0.35); }
.one-thing input:focus { opacity: 0.95; border-bottom-color: rgba(255, 255, 255, 0.3); }
.one-done {
  background: none; border: none; color: var(--accent);
  font-size: 14px; cursor: pointer; opacity: 0.8; padding: 2px 6px;
}
.one-done:hover { opacity: 1; }
.one-thing.dissolve { filter: blur(6px); opacity: 0; }

/* clock controls: 3 small circular buttons */
.clock-controls { margin-top: 12px; }
.btn-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; }
.ctl-btn {
  width: 40px; height: 40px; border-radius: 9999px;
  padding: 0;
}
.ctl-btn .icon { width: 16px; height: 16px; }
.progress-track {
  height: 3px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
  max-width: 190px; margin: 0 auto;
}
.progress-fill {
  height: 100%; width: 0%;
  border-radius: 99px;
  background: var(--accent);
  transition: width .3s linear;
}
.status-line {
  margin-top: 8px; font-size: 11px; color: var(--text); opacity: 0.6;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5);
}

/* Mode Mengalir capsule button (stays clickable in Mode Hening at 60%) */
.overtime-btn {
  margin-top: 10px;
  border-radius: 9999px;
  font-size: 12px;
  letter-spacing: 0.06em;
  border-color: rgba(255, 214, 150, 0.4);
  transition: opacity .8s ease, transform .15s ease, background .15s ease;
}
body.hening .overtime-btn { opacity: 0.6; }

/* Vibe preview capsule */
.vibe-capsule {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 45;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px 7px 14px; border-radius: 9999px;
  font-size: 12px; white-space: nowrap;
  transition: opacity .3s ease, transform .3s ease;
}
.vibe-capsule.hidden { display: block !important; opacity: 0; transform: translateX(-50%) translateY(-8px); pointer-events: none; }
.vibe-capsule .glass-btn.small { padding: 4px 10px; font-size: 11px; }

/* ---------- Mode Hening: fade all chrome ---------- */
.chrome-fade { transition: opacity .8s ease; }
body.hening .chrome-fade { opacity: 0; pointer-events: none; }

/* ---------- Hamburger (top-right, 40px) ---------- */
.icon-btn {
  position: fixed; top: 14px; right: 14px; z-index: 40;
  width: 40px; height: 40px; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; padding: 0;
}
.icon-btn span {
  display: block; width: 16px; height: 2px; border-radius: 2px;
  background: var(--text);
  transition: transform .25s ease, opacity .25s ease;
}
.icon-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.icon-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.icon-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------- Settings panel (compact) ---------- */
.panel { position: fixed; z-index: 30; padding: 14px 16px; }

#settingsPanel {
  top: 62px; right: 14px;
  width: min(92vw, 300px);
  max-height: calc(100vh - 90px);
  max-height: calc(100dvh - 90px);
  overflow-y: auto;
  transition: opacity .25s ease, transform .25s ease;
}
#settingsPanel.hidden { display: block !important; opacity: 0; transform: translateY(-10px); pointer-events: none; }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2 { font-size: 14px; font-weight: 600; letter-spacing: 0.04em; }

.set-group { margin-bottom: 14px; }
.set-group:last-child { margin-bottom: 2px; }
.set-group h3 { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 8px; font-weight: 600; }

.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }

.field-label { display: block; font-size: 11px; color: var(--text-dim); margin: 6px 0 5px; }
.row { display: flex; gap: 6px; }
.row input { flex: 1; min-width: 0; }

input[type="text"], input[type="url"], input[type="number"] {
  font-family: var(--font);
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border);
  border-radius: 11px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  width: 100%;
}
input:focus { border-color: var(--accent); background: rgba(255, 255, 255, 0.12); }
input::placeholder { color: rgba(245, 247, 250, 0.38); }
input[type="number"] { padding: 7px 6px 7px 10px; }

.hint { font-size: 11px; color: var(--text-dim); margin-top: 6px; line-height: 1.5; }

.style-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 2px; }
.style-picker .glass-btn.small { font-size: 11px; padding: 6px 4px; }

.dur-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.dur-grid label { font-size: 11px; color: var(--text-dim); display: flex; flex-direction: column; gap: 5px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 7px 0; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }

/* soundscape mini sliders */
.slider-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12px; color: var(--text-dim); margin: 6px 0;
}
.slider-row input[type="range"] {
  width: 130px; accent-color: var(--accent); cursor: pointer;
}

/* ---------- Playlist FAB (bottom-left, 44px) ---------- */
.pl-fab {
  position: fixed; left: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 40;
  width: 44px; height: 44px; border-radius: 50%;
  font-size: 18px; color: var(--text);
  cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, background .15s ease;
}
.pl-fab:hover { background: rgba(255, 255, 255, 0.14); transform: translateY(-1px); }

#playlistPanel {
  left: 14px; bottom: calc(68px + env(safe-area-inset-bottom));
  width: 250px; max-width: calc(100vw - 28px);
  max-height: min(46vh, 340px);
  overflow-y: auto;
  padding: 12px;
}
#playlistPanel .panel-head h2 { font-size: 13px; }

.pl-controls { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.pl-controls .glass-btn.small { padding: 4px 8px; font-size: 11px; border-radius: 9px; }
.pl-now { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }

.pl-list { list-style: none; max-height: 132px; overflow-y: auto; margin-bottom: 8px; display: flex; flex-direction: column; gap: 5px; }
.pl-list li {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  padding: 5px 8px; font-size: 12px; cursor: pointer;
  transition: background .15s ease;
}
.pl-list li:hover { background: rgba(255, 255, 255, 0.12); }
.pl-list li.playing { border-color: rgba(125, 211, 252, 0.5); background: rgba(125, 211, 252, 0.12); }
.pl-list li .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-list li .rm { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 12px; padding: 1px 5px; border-radius: 6px; }
.pl-list li .rm:hover { color: #ffb4b4; background: rgba(255, 255, 255, 0.1); }
.pl-empty-list { font-size: 11px; color: var(--text-dim); text-align: center; padding: 5px; }

.pl-add input { margin-bottom: 6px; font-size: 12px; padding: 6px 9px; }

/* hidden media engines — never visible */
#plVideo, #plAudio { display: none; }
#ytHidden { position: fixed; width: 1px; height: 1px; left: -2px; top: -2px; opacity: 0.01; pointer-events: none; overflow: hidden; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; padding: 8px 16px; border-radius: 9999px;
  font-size: 12px; white-space: nowrap; max-width: 92vw;
  overflow: hidden; text-overflow: ellipsis;
  transition: opacity .3s ease, transform .3s ease;
}
.toast.hidden { display: block !important; opacity: 0; transform: translateX(-50%) translateY(10px); pointer-events: none; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); border-radius: 99px; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .clock-float.centered { top: 40%; }
  .clock-float { padding: 10px 12px; }
  #settingsPanel { top: 60px; right: 10px; left: 10px; width: auto; }
  #playlistPanel { left: 10px; bottom: calc(64px + env(safe-area-inset-bottom)); }
  .icon-btn { top: 10px; right: 10px; }
  .pl-fab { left: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); }
}
