/* ============ study & relax ============ */

:root {
  --font-ui: "Quicksand", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --radius: 22px;
  --shadow: 0 14px 40px rgba(10, 6, 30, 0.28);
  --ease: cubic-bezier(0.33, 1, 0.68, 1);
}

/* ---------- accent themes (UI chrome only — the artwork stays untouched) ---------- */
:root[data-theme="twilight"] {
  --text: #f7eef2;
  --text-dim: rgba(247, 238, 242, 0.62);
  --accent: #ffb59e;
  --accent-2: #f28ea4;
  --btn-text: #3a2233;
  --glass: rgba(38, 28, 66, 0.44);
  --glass-border: rgba(255, 220, 210, 0.16);
  --input-bg: rgba(255, 255, 255, 0.08);
  --ring-track: rgba(255, 235, 225, 0.15);
  --scrim: rgba(14, 9, 28, 0.38);
}
:root[data-theme="night"] {
  --text: #eceefc;
  --text-dim: rgba(236, 238, 252, 0.60);
  --accent: #aab2f7;
  --accent-2: #8b93e8;
  --btn-text: #222442;
  --glass: rgba(15, 18, 48, 0.5);
  --glass-border: rgba(190, 200, 255, 0.15);
  --input-bg: rgba(255, 255, 255, 0.07);
  --ring-track: rgba(210, 218, 255, 0.14);
  --scrim: rgba(5, 7, 22, 0.42);
}
:root[data-theme="blush"] {
  --text: #fff6f1;
  --text-dim: rgba(255, 246, 241, 0.68);
  --accent: #ff9eb0;
  --accent-2: #e2798f;
  --btn-text: #4a2333;
  --glass: rgba(90, 45, 60, 0.42);
  --glass-border: rgba(255, 220, 225, 0.22);
  --input-bg: rgba(255, 255, 255, 0.10);
  --ring-track: rgba(255, 230, 235, 0.18);
  --scrim: rgba(60, 25, 38, 0.36);
}
:root[data-theme="forest"] {
  --text: #eef4ec;
  --text-dim: rgba(238, 244, 236, 0.60);
  --accent: #b9dcb9;
  --accent-2: #93c39c;
  --btn-text: #22321f;
  --glass: rgba(18, 32, 26, 0.5);
  --glass-border: rgba(210, 235, 210, 0.14);
  --input-bg: rgba(255, 255, 255, 0.07);
  --ring-track: rgba(220, 240, 220, 0.14);
  --scrim: rgba(7, 15, 11, 0.4);
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  color: var(--text);
  background: #241d33; /* behind the artwork while it loads */
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: color 0.6s;
}

button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font-family: inherit; color: inherit; }

svg { fill: none; stroke: currentColor; stroke-width: 1.6; }

/* ---------- background: her room behind rain-wet glass ---------- */
#bg {
  position: fixed; inset: 0; z-index: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
}
body.no-webgl #bg { display: none; }
body.no-webgl { background: url("assets/bg.png") center / cover no-repeat #241d33; }

#lightning {
  position: fixed; inset: 0; z-index: 5;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% -10%,
    rgba(244, 240, 255, 0.95) 0%,
    rgba(210, 200, 255, 0.35) 50%,
    rgba(210, 200, 255, 0) 78%);
  mix-blend-mode: screen;
  opacity: 0;
}
#lightning.flash { animation: bolt 0.8s ease-out; }
@keyframes bolt {
  0% { opacity: 0; } 8% { opacity: 0.75; } 18% { opacity: 0.12; }
  32% { opacity: 0.5; } 55% { opacity: 0.08; } 100% { opacity: 0; }
}

/* ---------- top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 22px 26px;
}

.brand { display: flex; flex-direction: column; gap: 8px; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 21px;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 12px rgba(10, 5, 20, 0.5);
}
.brand-name i { font-style: italic; color: var(--accent); }

.streak-chip {
  align-self: flex-start;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  padding: 5px 12px;
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.corner { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-dim);
  transition: color 0.25s, transform 0.25s var(--ease), background 0.25s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { color: var(--text); transform: translateY(-2px); }
.icon-btn.active { color: var(--accent); }

/* ---------- center / timer ---------- */
.center {
  position: relative; z-index: 10;
  height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px;
  padding-bottom: 4vh;
}

.mode-tabs {
  display: flex; gap: 6px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 5px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.mode-tab {
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  padding: 7px 16px;
  border-radius: 999px;
  transition: color 0.25s, background 0.25s;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active {
  color: var(--text);
  background: var(--input-bg);
  box-shadow: inset 0 0 0 1px var(--glass-border);
}

.timer-wrap { position: relative; width: min(320px, 78vw); aspect-ratio: 1; }
.timer-wrap::before {
  content: "";
  position: absolute; inset: -6%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--scrim) 0%, var(--scrim) 45%, transparent 72%);
}

.ring { width: 100%; height: 100%; transform: rotate(-90deg); position: relative; }
.ring circle { fill: none; }
.ring-track { stroke: var(--ring-track); stroke-width: 3; }
.ring-progress {
  stroke: var(--accent);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 867.08; /* 2πr, r=138 */
  stroke-dashoffset: 867.08;
  filter: drop-shadow(0 0 6px var(--accent));
  transition: stroke-dashoffset 0.5s linear, stroke 0.6s;
}

.timer-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
}

.time {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(58px, 19vw, 84px);
  line-height: 1;
  display: flex;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 18px rgba(10, 5, 20, 0.45);
}
.time span { width: 0.58em; text-align: center; }
.time span.colon { width: 0.3em; transform: translateY(-0.05em); }

.phase-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: var(--text-dim);
}

.intent {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16.5px;
  color: var(--text-dim);
  max-width: min(420px, 86vw);
  text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-shadow: 0 1px 10px rgba(10, 5, 20, 0.55);
}
.intent #intentText { color: var(--text); }

.controls { display: flex; align-items: center; gap: 18px; margin-top: 2px; }

.start-btn {
  min-width: 168px;
  padding: 15px 34px;
  border-radius: 999px;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--btn-text);
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px -8px var(--accent-2), inset 0 1px 0 rgba(255,255,255,0.45);
  transition: transform 0.25s var(--ease), box-shadow 0.25s, filter 0.25s;
}
.start-btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
.start-btn:active { transform: translateY(0); }
.start-btn.small { min-width: 0; padding: 11px 28px; font-size: 13.5px; }

.ghost-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text-dim);
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: color 0.25s, transform 0.25s var(--ease);
}
.ghost-btn svg { width: 18px; height: 18px; }
.ghost-btn:hover { color: var(--text); transform: translateY(-2px); }

/* ---------- panels ---------- */
.panel {
  position: fixed; z-index: 20;
  width: 316px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.25);
  -webkit-backdrop-filter: blur(22px) saturate(1.25);
  padding: 20px;
  animation: panel-in 0.35s var(--ease);
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.panel h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
}
.tasks-panel h2 { margin-bottom: 14px; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.amb-play {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--btn-text);
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px -4px var(--accent-2);
  transition: transform 0.2s var(--ease), filter 0.2s;
}
.amb-play:hover { transform: scale(1.08); }
.amb-play svg { width: 15px; height: 15px; stroke-width: 2.4; }
.amb-play .i-pause { display: none; }
.amb-play.playing .i-play { display: none; }
.amb-play.playing .i-pause { display: block; }

.sounds-panel {
  left: 26px; bottom: 26px;
  max-height: calc(100dvh - 120px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}
.tasks-panel  { right: 26px; bottom: 26px; max-height: min(430px, 62vh); display: flex; flex-direction: column; }

/* sound rows */
.sound-row { display: flex; align-items: center; gap: 12px; padding: 5px 0; }
.s-label {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; font-weight: 600;
  color: var(--text-dim);
  min-width: 118px;
}
.s-label svg { width: 19px; height: 19px; flex: none; }
.sound-row.active .s-label { color: var(--accent); }
.sound-row.active .s-label svg { filter: drop-shadow(0 0 5px var(--accent)); }
.sound-row.loading .s-label svg { animation: pulse-load 1s ease-in-out infinite alternate; }
@keyframes pulse-load { from { opacity: 0.4; } to { opacity: 1; } }
.sound-row.master { border-top: 1px solid var(--glass-border); margin-top: 6px; padding-top: 12px; }

.vol {
  flex: 1;
  appearance: none; -webkit-appearance: none;
  height: 4px;
  border-radius: 999px;
  background: var(--input-bg);
  outline: none;
}
.vol::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: 0 0 8px -1px var(--accent);
  cursor: pointer;
}
.vol::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

/* tasks */
.task-form input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.25s;
}
.task-form input::placeholder { color: var(--text-dim); }
.task-form input:focus { border-color: var(--accent); }

.task-list {
  list-style: none;
  margin-top: 10px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}
.task-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px;
  font-size: 14px;
  border-radius: 10px;
}
.task-check {
  flex: none;
  width: 19px; height: 19px;
  border-radius: 50%;
  border: 1.6px solid var(--text-dim);
  display: grid; place-items: center;
  transition: border-color 0.2s, background 0.2s;
}
.task-check svg { width: 11px; height: 11px; stroke-width: 2.6; opacity: 0; color: var(--btn-text); }
.task-item.done .task-check { background: var(--accent); border-color: var(--accent); }
.task-item.done .task-check svg { opacity: 1; }
.task-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: default; }
.task-item.done .task-text { text-decoration: line-through; color: var(--text-dim); }

.task-star, .task-del {
  flex: none; width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
}
.task-star svg, .task-del svg { width: 14px; height: 14px; }
.task-item:hover .task-star, .task-item:hover .task-del { opacity: 1; }
.task-item.focused .task-star { opacity: 1; color: var(--accent); }
.task-star:hover { color: var(--accent); }
.task-del:hover { color: #ff9d9d; }

.task-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
}
.linklike {
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}
.linklike:hover { color: var(--text); }
.linklike.danger:hover { color: #ff9d9d; }

.task-empty {
  padding: 14px 4px;
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
}

/* ---------- settings modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 6, 25, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center;
  animation: fade-in 0.25s;
}
@keyframes fade-in { from { opacity: 0; } }

.modal {
  width: min(400px, calc(100vw - 40px));
  max-height: calc(100dvh - 60px);
  overflow-y: auto;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(30px) saturate(1.3);
  -webkit-backdrop-filter: blur(30px) saturate(1.3);
  padding: 26px;
  display: flex; flex-direction: column; gap: 20px;
  animation: panel-in 0.3s var(--ease);
}
.modal h2 { font-family: var(--font-display); font-weight: 400; font-size: 20px; }
.set-group h3 {
  font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.set-grid label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12.5px; font-weight: 600; color: var(--text-dim);
}
.set-grid input {
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  width: 100%;
  outline: none;
}
.set-grid input:focus { border-color: var(--accent); }

.check {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px;
  padding: 5px 0;
  cursor: pointer;
}
.check input { accent-color: var(--accent-2); width: 16px; height: 16px; }

.theme-row { display: flex; gap: 12px; }
.theme-dot {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--d1) 50%, var(--d2) 50%);
  border: 2px solid transparent;
  transition: transform 0.2s var(--ease), border-color 0.2s;
}
.theme-dot:hover { transform: scale(1.12); }
.theme-dot.active { border-color: var(--text); }

.stats-line { font-size: 13.5px; color: var(--text-dim); margin-bottom: 8px; line-height: 1.5; }
.modal .start-btn { align-self: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 60;
  bottom: 34px; left: 50%;
  transform: translateX(-50%);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  animation: toast-in 0.4s var(--ease);
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- focus dimming: fade chrome while studying ---------- */
body.running .topbar,
body.running .panel,
body.running .mode-tabs,
body.running .intent,
body.running .controls .ghost-btn {
  opacity: 0.32;
  transition: opacity 1.2s;
}
body.running .topbar:hover,
body.running .panel:hover,
body.running .mode-tabs:hover,
body.running .controls .ghost-btn:hover { opacity: 1; transition: opacity 0.25s; }
body.running .start-btn { opacity: 0.85; }
body.running .start-btn:hover { opacity: 1; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .topbar { padding: 16px; }
  .brand-name { font-size: 18px; }
  .sounds-panel { left: 12px; right: 12px; bottom: 12px; width: auto; max-height: 66vh; }
  .tasks-panel { left: 12px; right: 12px; bottom: 12px; width: auto; max-height: 55vh; }
  .center { gap: 16px; }
  .chip-extra { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ring-progress { transition: none; }
}
