/* ==========================================================================
   wctl — Apple-Inspired Design System
   SF-style typography, glass nav, precise spacing, zero emojis
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── 1. Tokens ─────────────────────────────────────────────────────────── */

:root,
[data-theme="light"] {
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-mono:   'SF Mono', 'Fira Code', 'Menlo', monospace;

  /* Accent — Apple blue */
  --accent:       #007AFF;
  --accent-h:     #0066E0;
  --accent-soft:  rgba(0, 122, 255, 0.12);

  /* Surface */
  --bg:           #F5F5F7;
  --bg-card:      #FFFFFF;
  --bg-raised:    #FAFAFA;
  --bg-hover:     rgba(0, 0, 0, 0.04);
  --bg-active:    rgba(0, 0, 0, 0.07);

  /* Text */
  --text:         #1D1D1F;
  --text-2:       #6E6E73;
  --text-3:       #AEAEB2;
  --text-on-accent: #FFFFFF;

  /* Border */
  --border:       rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);

  /* Status */
  --green:  #30D158;
  --orange: #FF9F0A;
  --red:    #FF453A;

  /* Nav */
  --nav-bg:       rgba(255, 255, 255, 0.78);

  /* Slider */
  --track-bg:   #E5E5EA;
  --track-fill: var(--accent);
  --thumb:      #FFFFFF;
  --thumb-shad: 0 2px 8px rgba(0,0,0,0.18);

  /* Shadows */
  --shad-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shad-md: 0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shad-lg: 0 12px 40px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  --shad-xl: 0 24px 64px rgba(0,0,0,0.16);

  /* Radius */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-full: 9999px;

  /* Spacing */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* Layout */
  --nav-h: 54px;
  --max-w: 1080px;
  --sidebar-w: 300px;

  /* Easing */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] {
  --accent:       #0A84FF;
  --accent-h:     #409CFF;
  --accent-soft:  rgba(10, 132, 255, 0.18);

  --bg:           #000000;
  --bg-card:      #1C1C1E;
  --bg-raised:    #2C2C2E;
  --bg-hover:     rgba(255,255,255,0.06);
  --bg-active:    rgba(255,255,255,0.10);

  --text:         #F5F5F7;
  --text-2:       #98989D;
  --text-3:       #505054;
  --text-on-accent: #FFFFFF;

  --border:       rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);

  --green:  #32D74B;
  --orange: #FF9F0A;
  --red:    #FF453A;

  --nav-bg: rgba(28, 28, 30, 0.82);

  --track-bg: #3A3A3C;
  --thumb: #FFFFFF;
  --thumb-shad: 0 2px 8px rgba(0,0,0,0.4);

  --shad-sm: 0 1px 4px rgba(0,0,0,0.3);
  --shad-md: 0 4px 16px rgba(0,0,0,0.4);
  --shad-lg: 0 12px 40px rgba(0,0,0,0.5);
  --shad-xl: 0 24px 64px rgba(0,0,0,0.6);
}

/* ─── 2. Reset ───────────────────────────────────────────────────────────── */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-weight: 400;
  letter-spacing: -0.015em;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

button {
  font-family: inherit; cursor: pointer; border: none;
  background: none; font-size: inherit; color: inherit; outline: none;
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }

input, textarea, select {
  font-family: inherit; font-size: 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

svg { display: block; }
img { display: block; max-width: 100%; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

::selection { background: var(--accent); color: var(--text-on-accent); }

/* ─── 3. Nav bar ─────────────────────────────────────────────────────────── */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-5);
  z-index: 200;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease);
}

.nav-left  { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.nav-right { display: flex; align-items: center; gap: var(--sp-1); flex-shrink: 0; }

.nav-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Icon button */
.btn-icon {
  width: 34px; height: 34px;
  border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent);
  transition: background 0.15s var(--ease);
  flex-shrink: 0;
}
.btn-icon:hover  { background: var(--bg-hover); }
.btn-icon:active { background: var(--bg-active); }
.btn-icon svg { width: 19px; height: 19px; }

/* Back button */
.btn-back {
  display: inline-flex; align-items: center;
  gap: var(--sp-1);
  padding: 6px 10px 6px 6px;
  border-radius: var(--r-full);
  color: var(--accent);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background 0.15s var(--ease);
}
.btn-back:hover  { background: var(--bg-hover); }
.btn-back:active { background: var(--bg-active); }
.btn-back svg { width: 20px; height: 20px; }
.btn-back span { white-space: nowrap; }

/* ─── 4. Page layout ─────────────────────────────────────────────────────── */

.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: calc(var(--nav-h) + var(--sp-6)) var(--sp-5) var(--sp-12);
  width: 100%;
}

.page-narrow {
  max-width: 580px;
  margin: 0 auto;
  padding: calc(var(--nav-h) + var(--sp-6)) var(--sp-5) var(--sp-12);
}

/* ─── 5. Cards ───────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shad-sm);
  overflow: hidden;
}

.card + .card { margin-top: var(--sp-3); }

.card-section {
  padding: var(--sp-4) var(--sp-5);
}

.card-section + .card-section {
  border-top: 1px solid var(--border);
}

/* Grouped list — Apple Settings style */
.group { overflow: hidden; border-radius: var(--r-lg); border: 1px solid var(--border); }
.group + .group { margin-top: var(--sp-8); }

.group-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: var(--sp-2);
  padding: 0 var(--sp-1);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 13px var(--sp-4);
  background: var(--bg-card);
  transition: background 0.12s;
  min-height: 52px;
}
.row + .row { border-top: 1px solid var(--border); }
.row.clickable { cursor: pointer; }
.row.clickable:hover  { background: var(--bg-hover); }
.row.clickable:active { background: var(--bg-active); }

.row-icon {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.row-icon svg { width: 18px; height: 18px; }
.row-icon.blue    { background: var(--accent); color: #fff; }
.row-icon.green   { background: var(--green);  color: #fff; }
.row-icon.orange  { background: var(--orange);  color: #fff; }
.row-icon.red     { background: var(--red);     color: #fff; }
.row-icon.surface { background: var(--bg-raised); color: var(--text-2); }

.row-label { flex: 1; min-width: 0; }
.row-label-main  { font-size: 15px; color: var(--text); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-label-sub   { font-size: 12px; color: var(--text-2); margin-top: 1px; }

.row-value {
  font-size: 14px;
  color: var(--text-2);
  flex-shrink: 0;
}

.row-chevron {
  color: var(--text-3);
  flex-shrink: 0;
}
.row-chevron svg { width: 16px; height: 16px; }

/* ─── 6. Dot indicators ──────────────────────────────────────────────────── */

.dot {
  width: 8px; height: 8px;
  border-radius: var(--r-full);
  display: inline-block;
  flex-shrink: 0;
}
.dot.online  { background: var(--green);  box-shadow: 0 0 0 2px rgba(48,209,88,0.25); }
.dot.offline { background: var(--text-3); }

/* ─── 7. Primary Button ──────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  padding: 9px 20px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: all 0.15s var(--ease);
  cursor: pointer;
  border: none;
  font-family: inherit;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
}
.btn-primary:hover  { background: var(--accent-h); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover  { background: var(--bg-hover); }
.btn-secondary:active { transform: scale(0.97); }

.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.1); }
.btn-danger:active { transform: scale(0.97); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-link { color: var(--accent); font-weight: 500; font-size: 14px; }
.btn-link:hover { color: var(--accent-h); }

/* ─── 8. Section header ──────────────────────────────────────────────────── */

.section-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}
.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.022em;
  color: var(--text);
}
.section-action {
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}
.section-action:hover { color: var(--accent-h); }

/* ─── 9. iOS-style slider ────────────────────────────────────────────────── */

.slider-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
}
.slider-row > svg { width: 18px; height: 18px; color: var(--text-2); flex-shrink: 0; }

.slider {
  flex: 1;
  position: relative;
  height: 34px;
  display: flex;
  align-items: center;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
.slider-track {
  position: absolute;
  left: 0; right: 0;
  height: 5px;
  border-radius: var(--r-full);
  background: var(--track-bg);
  overflow: hidden;
}
.slider-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--accent);
  width: 50%;
  transition: width 0.04s linear;
}
.slider-thumb {
  position: absolute;
  width: 22px; height: 22px;
  border-radius: var(--r-full);
  background: var(--thumb);
  box-shadow: var(--thumb-shad);
  left: 50%;
  transform: translateX(-50%);
  transition: left 0.04s linear, transform 0.15s var(--ease-spring);
  pointer-events: none;
}
.slider.dragging .slider-thumb { transform: translateX(-50%) scale(1.15); }
.slider-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  min-width: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Native range fallback for media page */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: var(--r-full);
  background: var(--track-bg);
  outline: none;
  cursor: pointer;
  border: none;
  box-shadow: none;
  padding: 0;
}
input[type="range"]:focus { box-shadow: none; border: none; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: var(--r-full);
  background: var(--thumb);
  box-shadow: var(--thumb-shad);
  cursor: pointer;
  transition: transform 0.15s var(--ease-spring);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: var(--r-full);
  background: var(--thumb);
  box-shadow: var(--thumb-shad);
  border: none;
}
input[type="range"]::-moz-range-track {
  height: 5px; border-radius: var(--r-full); background: var(--track-bg);
}

/* ─── 10. Stats grid ─────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
}
.stats-grid > * {
  background: var(--bg-card);
  padding: var(--sp-4) var(--sp-3);
  text-align: center;
}
@media (max-width: 520px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-val .unit { font-size: 13px; font-weight: 500; color: var(--text-2); }
.stat-lbl {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  margin-top: 2px;
}
.stat-bar {
  height: 3px;
  border-radius: var(--r-full);
  background: var(--track-bg);
  margin-top: var(--sp-2);
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--accent);
  transition: width 0.5s var(--ease);
}
.stat-bar-fill.ok   { background: var(--green); }
.stat-bar-fill.warn { background: var(--orange); }
.stat-bar-fill.crit { background: var(--red); }

/* ─── 11. Now Playing card ───────────────────────────────────────────────── */

.np-card {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shad-sm);
  cursor: pointer;
  transition: box-shadow 0.2s, background 0.15s;
  overflow: hidden;
  position: relative;
}
.np-card:hover { box-shadow: var(--shad-md); background: var(--bg-raised); }
.np-card:active { transform: scale(0.99); }

.np-art {
  width: 56px; height: 56px;
  border-radius: var(--r-sm);
  background: var(--bg-raised);
  flex-shrink: 0;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  box-shadow: var(--shad-sm);
}
.np-art img { width: 100%; height: 100%; object-fit: cover; }
.np-art svg { width: 24px; height: 24px; }

.np-info { flex: 1; min-width: 0; }
.np-title  { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.np-device { font-size: 12px; color: var(--text-3); margin-top: 3px; }

.np-play {
  width: 42px; height: 42px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0,122,255,0.35);
  transition: background 0.15s, transform 0.15s var(--ease-spring);
}
.np-play:hover  { background: var(--accent-h); transform: scale(1.06); }
.np-play:active { transform: scale(0.94); }
.np-play svg    { width: 18px; height: 18px; }

/* ─── 12. Media player ───────────────────────────────────────────────────── */

.player-art {
  width: clamp(200px, 45vw, 300px);
  height: clamp(200px, 45vw, 300px);
  border-radius: var(--r-xl);
  background: var(--bg-raised);
  overflow: hidden;
  box-shadow: var(--shad-xl);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  margin: 0 auto var(--sp-8);
  flex-shrink: 0;
}
.player-art img { width: 100%; height: 100%; object-fit: cover; }
.player-art svg { width: 72px; height: 72px; }

.player-info { text-align: center; margin-bottom: var(--sp-6); }
.player-title  { font-size: 22px; font-weight: 700; letter-spacing: -0.022em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { font-size: 16px; color: var(--text-2); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Seek */
.seek-row { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.seek-time { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; min-width: 36px; text-align: center; }

.seek-track {
  flex: 1; height: 34px;
  display: flex; align-items: center;
  position: relative; cursor: pointer;
  touch-action: none;
}
.seek-bg   { position: absolute; inset: 0; margin: auto; height: 4px; border-radius: var(--r-full); background: var(--track-bg); pointer-events: none; }
.seek-fill { position: absolute; left: 0; top: 50%; transform: translateY(-50%); height: 4px; border-radius: var(--r-full); background: var(--accent); pointer-events: none; }
.seek-thumb {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 18px; height: 18px;
  border-radius: var(--r-full);
  background: var(--thumb);
  box-shadow: var(--thumb-shad);
  pointer-events: none;
  transition: transform 0.15s var(--ease-spring);
}
.seek-track.dragging .seek-thumb { transform: translate(-50%, -50%) scale(1.2); }

/* Controls */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  margin-bottom: var(--sp-8);
}
.ctrl-btn {
  width: 44px; height: 44px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  transition: background 0.12s, transform 0.12s;
}
.ctrl-btn:hover  { background: var(--bg-hover); }
.ctrl-btn:active { transform: scale(0.9); }
.ctrl-btn svg    { width: 22px; height: 22px; }
.ctrl-btn.sm svg { width: 18px; height: 18px; }
.ctrl-btn.sm     { width: 36px; height: 36px; color: var(--text-2); }

.ctrl-play {
  width: 58px; height: 58px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,122,255,0.3);
  transition: background 0.12s, transform 0.15s var(--ease-spring);
}
.ctrl-play:hover  { background: var(--accent-h); transform: scale(1.06); }
.ctrl-play:active { transform: scale(0.94); }
.ctrl-play svg    { width: 26px; height: 26px; }

/* ─── 13. File list ──────────────────────────────────────────────────────── */

.file-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-4);
  cursor: pointer;
  transition: background 0.1s;
  border-radius: 0;
  position: relative;
}
.file-row + .file-row { border-top: 1px solid var(--border); }
.file-row:hover  { background: var(--bg-hover); }
.file-row:active { background: var(--bg-active); }

.file-icon {
  width: 34px; height: 34px;
  border-radius: var(--r-xs);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
  background: var(--accent-soft);
}
.file-icon.gray { background: var(--bg-raised); color: var(--text-2); }
.file-icon svg  { width: 18px; height: 18px; }

.file-name { flex: 1; min-width: 0; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 12px; color: var(--text-3); text-align: right; flex-shrink: 0; }

/* ─── 14. Notes list ─────────────────────────────────────────────────────── */

.note-row {
  display: block;
  padding: 12px var(--sp-4);
  cursor: pointer;
  transition: background 0.1s;
}
.note-row + .note-row { border-top: 1px solid var(--border); }
.note-row:hover { background: var(--bg-hover); }
.note-row.active { background: var(--accent); }
.note-row.active .note-row-title,
.note-row.active .note-row-preview,
.note-row.active .note-row-date { color: rgba(255,255,255,.9) !important; }

.note-row-title   { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-row-preview { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.note-row-date    { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* ─── 15. Breadcrumb ─────────────────────────────────────────────────────── */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-2);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
}
.breadcrumb a { color: var(--accent); }
.breadcrumb .sep { color: var(--text-3); }

/* ─── 16. Toolbar ────────────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ─── 17. Modal ──────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.48);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  animation: fade-in 0.15s var(--ease);
}

.modal {
  background: var(--bg-card);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shad-xl);
  width: 90%;
  max-width: 420px;
  animation: scale-in 0.18s var(--ease);
  overflow: hidden;
}
.modal-header {
  padding: var(--sp-5) var(--sp-5) 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.modal-body { padding: var(--sp-4) var(--sp-5); color: var(--text-2); font-size: 14px; line-height: 1.5; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5) var(--sp-5);
}

/* ─── 18. Auth modal ─────────────────────────────────────────────────────── */

.auth-modal { max-width: 380px; }
.auth-avatar {
  width: 56px; height: 56px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ─── 19. Device pill (horizontal scroll) ────────────────────────────────── */

.device-bar {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: var(--nav-h);
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.device-bar::-webkit-scrollbar { display: none; }

.device-pill {
  display: flex; align-items: center;
  gap: var(--sp-2);
  padding: 7px 14px 7px 10px;
  border-radius: var(--r-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.device-pill:hover { background: var(--bg-hover); }
.device-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.device-pill.active .dot { background: #fff; box-shadow: none; }
.device-pill svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ─── 20. Empty state ────────────────────────────────────────────────────── */

.empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--sp-12) var(--sp-5);
  text-align: center;
  color: var(--text-3);
}
.empty svg { width: 48px; height: 48px; margin-bottom: var(--sp-4); opacity: 0.35; }
.empty h3 { font-size: 18px; font-weight: 600; color: var(--text-2); margin-bottom: var(--sp-1); }
.empty p  { font-size: 14px; }

/* ─── 21. Toast ──────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shad-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s var(--ease);
  z-index: 800;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* ─── 22. Spinner ────────────────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: var(--r-full);
  animation: spin 0.7s linear infinite;
}
.loading {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-12) var(--sp-5);
  color: var(--text-2);
  font-size: 14px;
}

/* ─── 23. App grid (device apps) ─────────────────────────────────────────── */

.app-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-3);
}
@media (max-width: 480px) {
  .app-grid { grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); }
}

.app-btn {
  display: flex; flex-direction: column;
  align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-1);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  color: var(--text-2);
}
.app-btn:hover  { background: var(--bg-hover); color: var(--text); }
.app-btn:active { transform: scale(0.94); }
.app-btn svg    { width: 22px; height: 22px; }
.app-btn span   { font-size: 11px; font-weight: 500; letter-spacing: -0.01em; }

/* ─── 24. Context menu ───────────────────────────────────────────────────── */

.ctx-menu {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shad-lg);
  padding: var(--sp-1);
  z-index: 600;
  min-width: 190px;
  animation: scale-in 0.12s var(--ease);
}
.ctx-item {
  display: flex; align-items: center;
  gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--r-xs);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
  border: none; background: none;
  width: 100%; text-align: left; font-family: inherit;
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--red); }
.ctx-item svg { width: 16px; height: 16px; color: var(--text-2); flex-shrink: 0; }
.ctx-item.danger svg { color: var(--red); }
.ctx-sep { height: 1px; background: var(--border); margin: var(--sp-1) 0; }

/* ─── 25. Upload progress ────────────────────────────────────────────────── */

.upload-toast {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-5);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shad-lg);
  padding: var(--sp-4) var(--sp-4);
  min-width: 260px;
  max-width: 320px;
  z-index: 700;
  animation: slide-up 0.25s var(--ease);
}
.upload-name { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: var(--sp-2); }
.upload-bar { height: 4px; border-radius: var(--r-full); background: var(--track-bg); overflow: hidden; }
.upload-fill { height: 100%; border-radius: var(--r-full); background: var(--accent); transition: width 0.2s; }

/* ─── 26. Tag pills ──────────────────────────────────────────────────────── */

.tag {
  display: inline-flex; align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
}
.tag-x { cursor: pointer; opacity: 0.6; }
.tag-x:hover { opacity: 1; color: var(--red); }

/* ─── 27. Storage bar ────────────────────────────────────────────────────── */

.storage-row {
  display: flex; align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  flex-wrap: wrap;
}
.storage-track {
  flex: 1; min-width: 120px;
  height: 5px; border-radius: var(--r-full);
  background: var(--track-bg);
  overflow: hidden;
}
.storage-fill {
  height: 100%; border-radius: var(--r-full);
  background: var(--accent); transition: width 0.4s var(--ease);
}
.storage-info { font-size: 12px; color: var(--text-2); display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.storage-info span { white-space: nowrap; }

/* ─── 28. Animations ─────────────────────────────────────────────────────── */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-in { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── 29. Device type badge ──────────────────────────────────────────────── */

.badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: var(--r-full);
}

/* ─── 30. Select override ────────────────────────────────────────────────── */

.select-wrap {
  position: relative;
  display: flex; align-items: center;
}
.select-wrap select {
  -webkit-appearance: none; appearance: none;
  padding-right: 32px;
}
.select-wrap::after {
  content: '';
  position: absolute; right: 12px;
  width: 10px; height: 6px;
  pointer-events: none;
  background: var(--text-2);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

/* ─── 31. Editor wysiwyg ─────────────────────────────────────────────────── */

.editor-body {
  flex: 1; overflow-y: auto;
  padding: 0 var(--sp-6) var(--sp-10);
}
.editor-content {
  min-height: 240px;
  outline: none;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
}
.editor-content:empty::before { content: attr(data-placeholder); color: var(--text-3); pointer-events: none; }
.editor-content h1 { font-size: 28px; font-weight: 700; margin: 0.6em 0 0.3em; letter-spacing: -0.02em; }
.editor-content h2 { font-size: 22px; font-weight: 650; margin: 0.5em 0 0.25em; }
.editor-content h3 { font-size: 18px; font-weight: 600; margin: 0.4em 0 0.2em; }
.editor-content p  { margin: 0.25em 0; }
.editor-content pre { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px 16px; font-family: var(--font-mono); font-size: 13px; overflow-x: auto; margin: 0.4em 0; }
.editor-content code { background: var(--bg-raised); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.9em; }
.editor-content pre code { padding: 0; background: none; }
.editor-content ul, .editor-content ol { padding-left: 24px; margin: 0.25em 0; }
.editor-content li { margin: 0.1em 0; }
.editor-content blockquote { border-left: 3px solid var(--accent); padding: 4px 14px; margin: 0.4em 0; color: var(--text-2); font-style: italic; }
.editor-content hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.editor-content a { color: var(--accent); text-decoration: underline; }
.editor-content strong, .editor-content b { font-weight: 700; }
.editor-content s { text-decoration: line-through; }
.editor-content u { text-decoration: underline; }

/* ─── Toolbar buttons ────────────────────────────────────────────────────── */

.tb-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-xs);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  color: var(--text-2);
  transition: background 0.1s, color 0.1s;
}
.tb-btn:hover  { background: var(--bg-raised); color: var(--text); }
.tb-btn.active { background: var(--accent); color: #fff; }
.tb-btn svg    { width: 15px; height: 15px; }

.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 var(--sp-1); flex-shrink: 0; }
.tb-select {
  -webkit-appearance: none; appearance: none;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 4px 8px;
  cursor: pointer;
  width: auto;
}

/* ─── 32. Notes layout ───────────────────────────────────────────────────── */

.notes-layout {
  display: flex;
  height: calc(100dvh - var(--nav-h));
  overflow: hidden;
}

.notes-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-card);
  transition: transform 0.25s var(--ease);
}

.notes-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

@media (max-width: 680px) {
  .notes-sidebar { position: fixed; top: var(--nav-h); left: 0; bottom: 0; z-index: 50; transform: translateX(0); width: 88vw; max-width: 340px; }
  .notes-sidebar.hidden { transform: translateX(-100%); }
  .notes-editor { width: 100%; }
}

/* ─── 33. Photos placeholder ─────────────────────────────────────────────── */

.photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 2px; }
.photos-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 60vh; text-align: center;
}
.photos-placeholder svg { width: 64px; height: 64px; margin-bottom: var(--sp-5); opacity: 0.25; color: var(--text-2); }
.photos-placeholder h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.022em; color: var(--text); margin-bottom: var(--sp-2); }
.photos-placeholder p  { font-size: 15px; color: var(--text-2); }

/* ─── 34. Responsive helpers ─────────────────────────────────────────────── */

@media (max-width: 480px) {
  .page { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .player-controls { gap: var(--sp-4); }
  .ctrl-play { width: 52px; height: 52px; }
  .ctrl-play svg { width: 22px; height: 22px; }
}

/* ─── 35. Misc ───────────────────────────────────────────────────────────── */

.nowrap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono   { font-family: var(--font-mono); font-size: 13px; }
.mt-3   { margin-top: var(--sp-3); }
.mt-5   { margin-top: var(--sp-5); }
.gap-2  { gap: var(--sp-2); }
