/* Open Nova — Dark meditation app theme */
@font-face {
  font-family: 'Comfortaa';
  src: url('fonts/comfortaa.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'Comfortaa';
  src: url('fonts/comfortaalight.ttf') format('truetype');
  font-weight: 300;
}
@font-face {
  font-family: 'Comfortaa';
  src: url('fonts/comfortaabold.ttf') format('truetype');
  font-weight: 700;
}

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

:root {
  --bg: #0a0a14;
  --surface: #12121f;
  --surface2: #1a1a2e;
  --accent: #667eea;
  --accent2: #764ba2;
  --text: #e0e0e8;
  --text-dim: #8888a0;
  --green: #6bcb77;
  --red: #ff6b6b;
  --yellow: #ffd93d;
  --radius: 14px;
}

body {
  font-family: 'Comfortaa', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-user-select: none;
  user-select: none;
}

/* === Top Bar === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid #ffffff10;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar h1 {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.topbar .battery {
  font-size: 13px;
  color: var(--text-dim);
}

#connect-btn {
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  transition: transform 0.1s, opacity 0.15s;
}
#connect-btn:active { transform: scale(0.95); }
#connect-btn:disabled { opacity: 0.5; }
#connect-btn.connected {
  background: var(--green);
  font-size: 12px;
}

/* === Status Banner === */
#status-bar {
  text-align: center;
  padding: 6px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface);
  border-bottom: 1px solid #ffffff08;
}
#status-bar.error { color: var(--red); }
#status-bar.ok { color: var(--green); }

/* === Tab Nav === */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid #ffffff10;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  flex: 1;
  min-width: 0;
  padding: 12px 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
  white-space: nowrap;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* === Page Container === */
.page { display: none; padding: 16px; }
.page.active { display: block; }

/* === Quick Modes (home page) === */
.quick-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.mode-card {
  padding: 24px 12px;
  text-align: center;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
.mode-card:active { transform: scale(0.96); }
.mode-card:disabled { opacity: 0.3; }
.mode-card.active { border-color: white; }

.mode-card .name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.mode-card .info {
  font-size: 12px;
  opacity: 0.7;
}

/* Mode colors */
.mode-card.relax    { background: linear-gradient(135deg, #2d5aa0, #1a3a6a); }
.mode-card.explore  { background: linear-gradient(135deg, #7b2d8e, #4a1a5e); }
.mode-card.deep     { background: linear-gradient(135deg, #1a6b5a, #0d4a3a); }
.mode-card.focus    { background: linear-gradient(135deg, #8b6914, #5a440d); }
.mode-card.sleep    { background: linear-gradient(135deg, #2d3a8e, #1a2460); }
.mode-card.dream    { background: linear-gradient(135deg, #6b2d6b, #4a1a4a); }

/* === Session List (browse page) === */
.category-header {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  padding: 16px 0 8px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  margin-bottom: 6px;
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.session-item:active { background: var(--surface2); }

.session-item .title {
  font-size: 15px;
  font-weight: 600;
}
.session-item .meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.session-item .duration-pills {
  display: flex;
  gap: 6px;
}
.duration-pill {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text-dim);
  border: none;
  cursor: pointer;
}
.duration-pill:active { background: var(--accent); color: white; }
.duration-pill.active { background: var(--accent); color: white; }

/* === Player (bottom sheet) === */
.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid #ffffff15;
  padding: 0;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.player.visible { transform: translateY(0); }

.player-mini {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}

.player-mini .now-playing {
  flex: 1;
  min-width: 0;
}
.player-mini .track-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-mini .track-info {
  font-size: 11px;
  color: var(--text-dim);
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  color: var(--text);
  transition: background 0.15s;
}
.player-btn:active { background: var(--accent); }
.player-btn.play {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 3px;
  background: #ffffff15;
  position: relative;
  cursor: pointer;
}
.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.5s linear;
}

/* Player expanded view */
.player-expanded {
  display: none;
  padding: 24px 16px 32px;
  text-align: center;
}
.player.expanded .player-mini { display: none; }
.player.expanded .player-expanded { display: block; }

.player-expanded .viz {
  width: 200px;
  height: 200px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: 0.5;
  transition: opacity 0.3s, transform 0.3s;
}
.player-expanded .viz.active {
  opacity: 1;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { transform: scale(0.9); opacity: 0.6; }
  to { transform: scale(1.1); opacity: 1; }
}

.player-expanded .exp-name {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.player-expanded .exp-info {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.player-expanded .time-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  padding: 0 4px;
  margin-top: 8px;
}

.player-expanded .exp-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 20px;
}

.player-expanded .exp-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 22px;
  background: var(--surface2);
  color: var(--text);
}
.player-expanded .exp-btn.play {
  width: 72px;
  height: 72px;
  font-size: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}

.collapse-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  margin-bottom: 8px;
}

/* === LED Visualizer === */
.led-viz {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #333;
  transition: background 0.1s;
  flex-shrink: 0;
}
.led-viz.on {
  background: #ffd700;
  box-shadow: 0 0 8px #ffd700;
}

/* === Settings / Debug === */
.settings-group {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.settings-group h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
}
.settings-row .label { color: var(--text-dim); }

.debug-btn {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid #ffffff20;
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  margin: 4px;
}
.debug-btn:active { background: var(--accent); }

#log {
  margin-top: 12px;
  background: #000;
  border-radius: 10px;
  padding: 12px;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 11px;
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.6;
}
.log-ok { color: var(--green); }
.log-err { color: var(--red); }
.log-info { color: var(--yellow); }

/* Spacing for player */
body.player-active { padding-bottom: 80px; }
