/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Themes ── */
.theme-cafe {
  --bg:          #1c1410;
  --surface:     #2b1f16;
  --surface2:    #362820;
  --border:      #4a3728;
  --text:        #f0e6d8;
  --muted:       #9c8070;
  --accent:      #d4863a;
  --accent-soft: rgba(212,134,58,0.13);
  --accent-text: #1c1410;
}
.theme-forest {
  --bg:          #1a2318;
  --surface:     #243022;
  --surface2:    #2f3d2c;
  --border:      #3a4e37;
  --text:        #e8e0d0;
  --muted:       #7a9172;
  --accent:      #7ec87a;
  --accent-soft: rgba(126,200,122,0.12);
  --accent-text: #1a2318;
}
.theme-twilight {
  --bg:          #1e1a2e;
  --surface:     #2a2440;
  --surface2:    #352e52;
  --border:      #433a63;
  --text:        #ede8f5;
  --muted:       #8b80aa;
  --accent:      #a78bfa;
  --accent-soft: rgba(167,139,250,0.13);
  --accent-text: #1e1a2e;
}
.theme-ocean {
  --bg:          #0f1e24;
  --surface:     #162830;
  --surface2:    #1d3540;
  --border:      #264455;
  --text:        #ddeae8;
  --muted:       #6a9fa0;
  --accent:      #3bb8a8;
  --accent-soft: rgba(59,184,168,0.12);
  --accent-text: #0f1e24;
}
.theme-minimal {
  --bg:          #f5f5f4;
  --surface:     #ffffff;
  --surface2:    #eeece9;
  --border:      #dddbd8;
  --text:        #1c1917;
  --muted:       #78716c;
  --accent:      #6366f1;
  --accent-soft: rgba(99,102,241,0.10);
  --accent-text: #ffffff;
}

/* ── Sidebar ── */
.sidebar {
  width: 64px;
  min-width: 64px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  height: 100vh;
  overflow: hidden;
  transition: width 0.22s cubic-bezier(0.4,0,0.2,1);
  z-index: 20;
  flex-shrink: 0;
}
.sidebar:hover { width: 200px; }

.sidebar-top {
  padding: 16px 8px 14px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  height: 28px;
  margin-bottom: 10px;
}
/* show brand text on hover */
.sidebar-brand::after {
  content: 'StudySpace';
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-left: 10px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.18s;
}
.sidebar:hover .sidebar-brand::after { opacity: 1; }

.sidebar-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}
.clock-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.clock-date {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.18s;
}
.sidebar:hover .clock-date { opacity: 1; }

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-bottom {
  padding: 8px 8px 14px;
  border-top: 1px solid var(--border);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}
.nav-btn:hover { background: var(--accent-soft); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); }
.nav-icon { flex-shrink: 0; }
.nav-label {
  opacity: 0;
  transition: opacity 0.18s;
  overflow: hidden;
}
.sidebar:hover .nav-label { opacity: 1; }

/* ── Main ── */
.main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  height: 100vh;
  min-width: 0;
}
.main.has-player { padding-bottom: 168px; }

/* ── Panels ── */
.panel {
  padding: 40px 48px;
  max-width: 680px;
}
.panel.hidden { display: none; }

@media (max-width: 860px) {
  .panel { padding: 28px 24px; }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 12px;
}
.panel-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  padding: 9px 22px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary.btn-large { padding: 12px 40px; font-size: 14px; letter-spacing: 0.01em; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.link-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--accent); }

.text-input {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  min-width: 0;
}
.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.text-input::placeholder { color: var(--muted); }

.muted-text { color: var(--muted); font-size: 13px; }
.section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Pomodoro ── */
.pomo-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding-top: 8px;
}
.pomo-phases {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}
.phase-btn {
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 7px 20px;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.phase-btn.active { background: var(--accent); color: var(--accent-text); }
.phase-btn:not(.active):hover { color: var(--text); }

.pomo-ring-wrap {
  position: relative;
  width: 210px;
  height: 210px;
}
.pomo-svg { width: 100%; height: 100%; }
.ring-track { stroke: var(--surface2); stroke-width: 7; fill: none; }
.ring-progress {
  stroke: var(--accent);
  stroke-width: 7;
  fill: none;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
.pomo-display {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.pomo-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 44px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.pomo-phase-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.pomo-controls { display: flex; align-items: center; gap: 12px; }
.pomo-session-badge {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px;
}

/* ── Tasks ── */
.task-add-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: stretch;
}
.task-add-row .text-input { flex: 1; }

.filter-row { display: flex; gap: 4px; }
.filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 14px;
  font-family: inherit;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.filter-btn:not(.active):hover { color: var(--text); border-color: var(--text); }

.task-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background 0.15s;
}
.task-item:hover { background: var(--surface2); }
.task-item.done .task-text { text-decoration: line-through; color: var(--muted); }

.task-check {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.task-check:hover { border-color: var(--accent); }
.task-check.checked { background: var(--accent); border-color: var(--accent); }
.task-check.checked::after {
  content: '';
  width: 9px; height: 5px;
  border-left: 2px solid var(--accent-text);
  border-bottom: 2px solid var(--accent-text);
  transform: rotate(-45deg) translate(1px, -1px);
  display: block;
}
.task-text { flex: 1; color: var(--text); font-size: 13px; word-break: break-word; }
.task-del {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  display: flex;
  align-items: center;
}
.task-item:hover .task-del { opacity: 1; }
.task-del:hover { color: #e05555; }
.task-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Notes ── */
.notes-tabs-wrap { overflow-x: auto; scrollbar-width: none; margin-bottom: 20px; }
.notes-tabs-wrap::-webkit-scrollbar { display: none; }
.notes-tabs { display: flex; gap: 6px; min-width: max-content; }
.note-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 16px;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-tab.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.note-tab:not(.active):hover { color: var(--text); }

.note-editor-wrap { display: flex; flex-direction: column; }
.note-title-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: 'Lora', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  padding: 0 0 14px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}
.note-title-input:focus { border-color: var(--accent); }
.note-title-input::placeholder { color: var(--muted); }
.note-body {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: 'Lora', Georgia, serif;
  font-size: 15px;
  line-height: 1.75;
  padding: 20px 0;
  outline: none;
  resize: none;
  min-height: 420px;
  width: 100%;
}
.note-body::placeholder { color: var(--muted); }
.note-empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.note-empty.hidden { display: none; }
.note-empty p { margin-bottom: 20px; font-size: 15px; }

/* ── Sounds — Mixer Board ── */
.mixer-section { margin-bottom: 8px; }

.sound-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  transition: background 0.15s, border-color 0.15s;
}
.sound-row:last-child { margin-bottom: 0; }
.sound-row.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.sound-row-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.sound-row.active .sound-row-dot {
  opacity: 1;
  box-shadow: 0 0 6px currentColor;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.sound-row-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
  transition: color 0.15s;
}
.sound-row.active .sound-row-icon { color: var(--accent); }

.sound-row-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  min-width: 88px;
  flex-shrink: 0;
}

.sound-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.sound-play-btn:hover { border-color: var(--accent); color: var(--accent); }
.sound-row.active .sound-play-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.sound-vol-wrap { flex: 1; min-width: 80px; }
.sound-vol {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.sound-vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}
.sound-vol::-webkit-slider-thumb:hover { transform: scale(1.2); }
.sound-vol::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.sound-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.2s;
}
.sound-row.active .sound-live-dot { opacity: 1; }

/* Music presets */
.music-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.preset-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 16px;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.preset-btn:hover,
.preset-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ── Spotify ── */
.spotify-body { max-width: 620px; }
.spotify-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: stretch;
}
.spotify-input-row .text-input { flex: 1; }
.spotify-embed-wrap iframe {
  width: 100%;
  border: none;
  border-radius: 12px;
}

/* ── Settings ── */
.settings-body { max-width: 460px; display: flex; flex-direction: column; gap: 32px; }
.settings-section { display: flex; flex-direction: column; gap: 16px; }
.settings-heading {
  font-family: 'Lora', Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.settings-label { font-size: 13px; color: var(--text); }

.theme-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  transition: background 0.15s;
}
.theme-swatch:hover { background: var(--surface2); }
.theme-swatch.active { background: var(--accent-soft); }
.theme-swatch span { font-size: 11px; color: var(--muted); font-weight: 500; }
.theme-swatch.active span { color: var(--accent); }
.swatch-dot { width: 34px; height: 34px; border-radius: 50%; }

.dur-control { display: flex; align-items: center; gap: 10px; }
.dur-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
  line-height: 1;
}
.dur-btn:hover { border-color: var(--accent); color: var(--accent); }
.dur-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 24px;
  text-align: center;
}
.dur-unit { font-size: 12px; color: var(--muted); }

.toggle-switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(16px); }

/* ── Persistent Player Bar ── */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 64px; /* sidebar width */
  right: 0;
  height: 168px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px 8px 20px;
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}
.player-bar.hidden {
  transform: translateY(100%);
  pointer-events: none;
}

.player-bar-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-shrink: 0;
  width: 180px;
}
.player-cover {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface2);
  flex-shrink: 0;
}
.player-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}
.player-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}
.player-source {
  font-size: 11px;
  color: var(--muted);
}

.player-embed-wrap {
  flex: 1;
  min-width: 0;
  height: 152px;
  display: flex;
  align-items: center;
}
.player-embed-wrap iframe {
  width: 100%;
  height: 152px;
  border: none;
  border-radius: 12px;
}

.player-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.player-close:hover { color: var(--text); background: var(--surface2); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Mobile ── */
@media (max-width: 640px) {
  body { flex-direction: column-reverse; }
  .sidebar {
    width: 100% !important;
    height: 58px;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .sidebar-top { display: none; }
  .sidebar-nav {
    flex-direction: row;
    justify-content: center;
    padding: 6px 8px;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .sidebar-bottom {
    padding: 6px 8px;
    border-top: none;
    border-left: 1px solid var(--border);
  }
  .nav-btn {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px;
    width: 48px;
    height: 46px;
    gap: 0;
  }
  .nav-label { display: none; }
  .main { height: calc(100vh - 58px); }
  .panel { padding: 20px 16px; }
  .pomo-ring-wrap { width: 180px; height: 180px; }
  .pomo-time { font-size: 36px; }
  .player-bar { left: 0; }
  .sound-row-name { min-width: 64px; }
}
