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

:root {
  --bg: #0a0a0f;
  --surface: #13131e;
  --surface2: #1c1c2e;
  --border: #2a2a40;
  --text: #e8e8f0;
  --muted: #7070a0;
  --accent: #a855f7;
  --accent-dim: #7c3aed;
  --accent-glow: rgba(168,85,247,0.15);
  --danger: #e54d4d;
  --radius: 10px;
  --sidebar-w: 210px;
  --mobile-header-h: 52px;
  --mobile-sp-h: 52px;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
}

body {
  height: 100%;
  overflow: hidden;
}

/* ── Layout ─────────────────────────────────────────── */
.layout { display: flex; height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  flex-shrink: 0;
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0 16px 20px;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.sidebar ul { list-style: none; }

.sidebar li {
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 6px;
  margin: 0 8px 2px;
  color: var(--muted);
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
}

.sidebar li:hover { background: var(--surface2); color: var(--text); }
.sidebar li.active { background: var(--accent-glow); color: var(--accent); font-weight: 500; }

.content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tab { display: none; flex: 1; flex-direction: column; padding: 28px 32px; overflow-y: auto; gap: 0; min-height: 0; }
.tab.active { display: flex; }

/* ── Typography ─────────────────────────────────────── */
h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 22px; }
h2 { font-size: 0.95rem; font-weight: 600; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* ── Buttons ─────────────────────────────────────────── */
button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: opacity 0.15s;
}

button:hover { opacity: 0.85; }
button.secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: var(--border); }
button.danger { background: var(--danger); color: #fff; }
button.small { padding: 5px 10px; font-size: 0.78rem; }
button.icon-btn { background: none; color: var(--muted); padding: 4px 6px; border-radius: 4px; font-size: 0.85rem; }
button.icon-btn:hover { color: var(--danger); background: rgba(229,77,77,0.1); }
button.full-btn { width: 100%; margin-bottom: 10px; }

/* ── Inputs ──────────────────────────────────────────── */
input, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }

/* ── Dashboard ───────────────────────────────────────── */
.dash-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.clock-widget { line-height: 1.2; }
.clock-time { font-size: 2rem; font-weight: 700; letter-spacing: -1px; }
.clock-date { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

.search-bar {
  position: relative;
  flex: 1;
}

.search-bar input {
  padding-right: 40px;
  font-size: 0.9rem;
}

.search-bar button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  color: var(--muted);
  padding: 4px 6px;
  font-size: 0.9rem;
}

.weather-widget {
  text-align: right;
  white-space: nowrap;
}

.weather-temp { font-size: 1.4rem; font-weight: 700; }
.weather-desc { font-size: 0.75rem; color: var(--muted); }

/* ── Quick Links ─────────────────────────────────────── */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: 24px;
}

.link-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}

.link-card:hover { border-color: var(--accent); background: var(--accent-glow); }
.link-card .icon { font-size: 1.5rem; }
.link-card .label { font-size: 0.75rem; font-weight: 500; word-break: break-word; }
.link-card .del { position: absolute; top: 4px; right: 4px; opacity: 0; transition: opacity 0.15s; background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.75rem; padding: 2px; }
.link-card:hover .del { opacity: 1; }

/* ── Recents ─────────────────────────────────────────── */
.recents-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}

.recent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.recent-card h3 { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }

.recent-item {
  font-size: 0.82rem;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  cursor: pointer;
}

.recent-item:last-child { border-bottom: none; }
.recent-item:hover { color: var(--accent); }
.recent-empty { font-size: 0.82rem; color: var(--muted); }

/* ── File Drop ───────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.drop-zone.dragover { border-color: var(--accent); background: var(--accent-glow); color: var(--text); }
.drop-zone label { color: var(--accent); cursor: pointer; }

.progress-bar { background: var(--surface2); border-radius: 4px; height: 5px; margin-bottom: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; width: 0%; transition: width 0.3s; }
.upload-progress { margin-bottom: 14px; font-size: 0.82rem; color: var(--muted); }

.file-list { display: flex; flex-direction: column; gap: 6px; }

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}

.file-icon { font-size: 1.2rem; flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 0.86rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 0.73rem; color: var(--muted); margin-top: 2px; }
.file-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Clipboard ───────────────────────────────────────── */
.clipboard-input { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.clipboard-input textarea { height: 76px; resize: none; }
.clipboard-input button { align-self: flex-end; }
.clip-list { display: flex; flex-direction: column; gap: 6px; }
.clip-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.clip-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.clip-text {
  flex: 1;
  font-size: 0.86rem;
  line-height: 1.5;
  word-break: break-all;
  white-space: pre-wrap;
  cursor: pointer;
  user-select: all;
}

.clip-text:hover { color: var(--accent); }
.clip-meta { font-size: 0.72rem; color: var(--muted); margin-top: 3px; }
.clip-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }

/* ── Notes ───────────────────────────────────────────── */
.notes-layout { display: flex; gap: 14px; flex: 1; min-height: 0; }

.notes-sidebar {
  width: 190px;
  flex-shrink: 0;
  overflow-y: auto;
}

.notes-sidebar ul { list-style: none; display: flex; flex-direction: column; gap: 3px; }

.notes-sidebar li {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s, color 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.notes-sidebar li:hover { background: var(--surface2); color: var(--text); }
.notes-sidebar li.active { background: var(--accent-glow); color: var(--accent); }
.notes-sidebar li .del { opacity: 0; flex-shrink: 0; }
.notes-sidebar li:hover .del { opacity: 1; }

.note-editor { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.note-empty { color: var(--muted); font-size: 0.9rem; padding-top: 40px; text-align: center; }

#note-title {
  font-size: 1.05rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 0;
}

#note-content { flex: 1; resize: none; font-size: 0.88rem; line-height: 1.6; min-height: 200px; }

/* ── Sidebar Spotify Player ──────────────────────────── */
.sidebar-player { padding: 12px; border-top: 1px solid var(--border); }
.sidebar-player.hidden { display: none; }

.sp-cover {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface2);
  margin-bottom: 8px;
  display: block;
}

.sp-cover-placeholder {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 8px;
}

.sp-track { font-size: 0.78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-artist { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 8px; }

.sp-progress { height: 3px; background: var(--border); border-radius: 2px; margin-bottom: 8px; cursor: pointer; }
.sp-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; }

.sp-controls { display: flex; align-items: center; justify-content: space-between; }

.sp-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
  line-height: 1;
}

.sp-btn:hover { color: var(--text); }
.sp-btn.play { font-size: 1.3rem; color: var(--accent); }
.sp-btn.play:hover { color: var(--accent-dim); }

.sp-volume { width: 100%; margin-top: 8px; accent-color: var(--accent); cursor: pointer; }
.sp-extra-row { display: flex; gap: 6px; margin-top: 8px; }
.sp-extra-btn { flex: 1; font-size: .72rem; padding: 5px 4px; background: var(--surface2); color: var(--muted); border: none; cursor: pointer; border-radius: 4px; }
.sp-extra-btn:hover { color: var(--text); background: var(--border); }

.spotify-connect {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Modal ───────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-box h3 { margin-bottom: 4px; }
.modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.modal-actions button { flex: 1; }

/* ── Toast ───────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 80px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 200;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.83rem;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Mobile Header ───────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--mobile-header-h) + env(safe-area-inset-top, 28px));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 16px calc(10px);
  padding-top: env(safe-area-inset-top, 28px);
  z-index: 200;
}
.mobile-header .logo { padding: 0; font-size: 1rem; }
.burger-btn { background: none; border: none; color: var(--text); font-size: 1.4rem; padding: 8px; cursor: pointer; line-height: 1; }
.burger-btn:hover { opacity: 0.7; }

/* ── Burger Drawer ───────────────────────────────────── */
.burger-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 299;
}
.burger-overlay.open { display: block; }

.burger-drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 80%;
  max-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 300;
  display: none;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 28px);
  padding-bottom: 16px;
  overflow-y: auto;
}
.burger-drawer.open { display: flex; }
.burger-drawer .logo { padding: 16px 16px 20px; font-size: 1.1rem; font-weight: 700; color: var(--accent); letter-spacing: -0.3px; }
.burger-drawer ul { list-style: none; }
.burger-drawer li {
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 6px;
  margin: 0 8px 2px;
  color: var(--muted);
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
}
.burger-drawer li:hover { background: var(--surface2); color: var(--text); }
.burger-drawer li.active { background: var(--accent-glow); color: var(--accent); font-weight: 500; }
.drawer-player { padding: 12px; border-top: 1px solid var(--border); margin-top: auto; }

/* ── Mobile Spotify Bar ──────────────────────────────── */
.mobile-sp-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--mobile-sp-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  z-index: 50;
}
.mobile-sp-art { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.mobile-sp-art img { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; }
.mobile-sp-info { flex: 1; min-width: 0; }
.mobile-sp-track { font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-sp-artist { font-size: 0.7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-sp-controls { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.mobile-sp-controls .sp-btn { font-size: 1.1rem; padding: 6px; }
.mobile-sp-controls .sp-btn.play { font-size: 1.3rem; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 700px) {
  html, body { height: auto; overflow: auto; }

  .layout { display: block; height: auto; min-height: 100vh; }
  .sidebar { display: none; }
  .content { display: block; height: auto; overflow: visible; }
  .mobile-header { display: flex; }
  .mobile-sp-bar { display: flex; }
  .toast-container { bottom: calc(var(--mobile-sp-h) + 8px); }

  .tab {
    display: none;
    flex-direction: unset;
    padding: calc(var(--mobile-header-h) + env(safe-area-inset-top, 28px) + 16px) 16px calc(var(--mobile-sp-h) + 20px);
    overflow-y: visible;
    min-height: 100vh;
  }
  .tab.active { display: block; }

  h1 { font-size: 1.2rem; margin-bottom: 16px; }

  .dash-top { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
  .search-bar { grid-column: 1 / -1; }
  .recents-grid { grid-template-columns: 1fr; }
  .links-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }

  .notes-layout { display: block; }
  .notes-sidebar { width: 100%; overflow-y: visible; margin-bottom: 12px; }
  .notes-sidebar ul { flex-direction: row; flex-wrap: wrap; }
  .notes-sidebar li { flex: none; }
  .note-editor { display: flex; flex-direction: column; }
  #note-content { min-height: 200px; }

  #tab-notes.active { display: flex; flex-direction: column; }
  .notes-layout { display: flex; flex-direction: column; flex: 1; }

  .todo-input-row { flex-wrap: wrap; }
  .todo-input-row input[type=text] { min-width: 0; }
  .todo-input-row input[type=date] { flex: 1; }
}

/* ── Image Preview ───────────────────────────────────── */
.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}
.preview-modal.hidden { display: none; }
.preview-modal img { max-width: 100%; max-height: 90vh; border-radius: 8px; object-fit: contain; }
.preview-modal .close { position: absolute; top: 16px; right: 16px; background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 1rem; }

/* ── QR Downloads ────────────────────────────────────── */
.qr-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.qr-actions button { font-size: 0.75rem; padding: 5px 12px; }

/* ── Password Strength ───────────────────────────────── */
.pw-strength-bar { height: 4px; border-radius: 2px; margin-top: 4px; background: var(--border); overflow: hidden; }
.pw-strength-fill { height: 100%; border-radius: 2px; transition: width 0.3s, background 0.3s; width: 0%; }
.pw-strength-label { font-size: 0.72rem; color: var(--muted); margin-top: 3px; }

/* ── File Search ─────────────────────────────────────── */
.file-search { margin-bottom: 12px; }

/* ── Note Pin ────────────────────────────────────────── */
.note-pin { font-size: 0.75rem; cursor: pointer; opacity: 0.4; padding: 2px; flex-shrink: 0; }
.note-pin.pinned { opacity: 1; }
.notes-sidebar li.pinned-note { border-left: 2px solid var(--accent); padding-left: 8px; }

/* ── Keyboard hint ───────────────────────────────────── */
.kbd { display: inline-block; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 0.72rem; color: var(--muted); font-family: monospace; }

/* ── Passwords ───────────────────────────────────────── */
.pw-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

.pw-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.pw-item:hover { border-color: var(--accent); }
.pw-icon { font-size: 1.4rem; flex-shrink: 0; width: 36px; height: 36px; background: var(--surface2); border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.pw-info { flex: 1; min-width: 0; }
.pw-label { font-size: 0.9rem; font-weight: 600; }
.pw-username { font-size: 0.78rem; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pw-actions { display: flex; gap: 6px; flex-shrink: 0; }

.pw-view-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.pw-view-row:last-of-type { border-bottom: none; }
.pw-view-key { font-size: 0.75rem; color: var(--muted); width: 70px; flex-shrink: 0; }
.pw-view-val { flex: 1; font-size: 0.88rem; word-break: break-all; }
.pw-view-val.link { color: var(--accent); text-decoration: none; }
.pw-view-val.link:hover { text-decoration: underline; }

.pw-empty { color: var(--muted); font-size: 0.88rem; padding: 24px 0; text-align: center; }

/* ── Todos ───────────────────────────────────────────── */
.todo-input-row { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; }
.todo-input-row input[type=text] { flex: 1; }
.todo-priority-btn { background: var(--surface2); border: 1px solid var(--border); color: var(--muted); padding: 9px 10px; border-radius: 6px; cursor: pointer; font-size: 0.8rem; flex-shrink: 0; }
.todo-list { display: flex; flex-direction: column; gap: 6px; }
.todo-item { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; transition: opacity 0.2s; }
.todo-item.done { opacity: 0.45; }
.todo-item.done .todo-text { text-decoration: line-through; }
.todo-check { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.todo-text { flex: 1; font-size: 0.88rem; cursor: pointer; }
.todo-due { font-size: 0.72rem; color: var(--muted); flex-shrink: 0; }
.todo-due.overdue { color: var(--danger); }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.priority-0 { background: var(--muted); }
.priority-1 { background: var(--accent); }
.priority-2 { background: #f97316; }
.todo-empty { color: var(--muted); font-size: 0.88rem; padding: 24px 0; text-align: center; }
.todo-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 0.8rem; color: var(--muted); }

/* ── Habit Tracker ────────────────────────────────────── */
.habit-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
}
.habit-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.habit-header h3 { font-size: 0.82rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.habit-progress { font-size: 0.8rem; font-weight: 700; color: var(--accent); }
.habit-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.habit-item { display: flex; align-items: center; gap: 10px; }
.habit-check { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.habit-label { flex: 1; font-size: 0.86rem; }
.habit-label.done { text-decoration: line-through; opacity: 0.5; }
.habit-del { background: none; border: none; color: var(--muted); font-size: 0.75rem; padding: 2px 4px; cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.habit-item:hover .habit-del { opacity: 1; }
.habit-add-row { display: flex; gap: 8px; }
.habit-add-row input { flex: 1; font-size: 0.84rem; padding: 6px 10px; }
.habit-add-row button { padding: 6px 12px; font-size: 0.82rem; }

/* ── Markdown Preview ────────────────────────────────── */
.note-preview { flex: 1; overflow-y: auto; padding: 8px 4px; font-size: 0.9rem; line-height: 1.7; min-height: 200px; }
.note-preview h1,.note-preview h2,.note-preview h3 { margin: 12px 0 6px; }
.note-preview h1 { font-size: 1.3rem; }
.note-preview h2 { font-size: 1.1rem; }
.note-preview h3 { font-size: 0.95rem; }
.note-preview ul,.note-preview ol { padding-left: 20px; }
.note-preview li { margin: 3px 0; }
.note-preview code { background: var(--surface2); padding: 1px 5px; border-radius: 4px; font-family: monospace; font-size: 0.85em; }
.note-preview pre { background: var(--surface2); padding: 10px; border-radius: 6px; overflow-x: auto; }
.note-preview blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--muted); margin: 8px 0; }
.note-preview a { color: var(--accent); }
.note-preview hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.note-toolbar { display: flex; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.note-toolbar button { padding: 4px 10px; font-size: 0.75rem; }

/* ── Media Player ────────────────────────────────────── */
.media-player { background: var(--surface2); border-radius: 8px; padding: 8px; margin-top: 6px; width: 100%; }

/* ── Anime ───────────────────────────────────────────── */
.anime-screen { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.anime-screen.hidden { display: none; }

.anime-topbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.anime-source-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.anime-source-bar select { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 6px 10px; border-radius: 6px; font-size: 0.82rem; flex: 1; max-width: 220px; }

.anime-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.anime-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; transition: border-color 0.15s, transform 0.15s; }
.anime-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.anime-card-img { width: 100%; aspect-ratio: 2/3; object-fit: cover; background: var(--surface2); display: block; }
.anime-card-img-placeholder { width: 100%; aspect-ratio: 2/3; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.anime-card-info { padding: 8px; }
.anime-card-title { font-size: 0.78rem; font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.anime-card-sub { font-size: 0.7rem; color: var(--muted); margin-top: 3px; }

.anime-detail-hero { display: flex; gap: 16px; margin-bottom: 20px; }
.anime-detail-cover { width: 120px; flex-shrink: 0; border-radius: 8px; object-fit: cover; background: var(--surface2); }
.anime-detail-cover-placeholder { width: 120px; min-height: 170px; flex-shrink: 0; border-radius: 8px; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.anime-detail-meta { flex: 1; min-width: 0; }
.anime-detail-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.anime-detail-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.anime-tag { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 2px 7px; font-size: 0.7rem; color: var(--muted); }
.anime-detail-desc { font-size: 0.82rem; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

.anime-eps-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.anime-eps-list { display: flex; flex-direction: column; gap: 4px; max-height: 400px; overflow-y: auto; }
.anime-ep-item { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; cursor: pointer; transition: border-color 0.15s; }
.anime-ep-item:hover { border-color: var(--accent); }
.anime-ep-item.watched { opacity: 0.5; }
.anime-ep-num { font-size: 0.8rem; color: var(--muted); width: 32px; flex-shrink: 0; }
.anime-ep-title { flex: 1; font-size: 0.85rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anime-ep-progress { width: 60px; height: 3px; background: var(--border); border-radius: 2px; flex-shrink: 0; }
.anime-ep-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.anime-ep-play { font-size: 1rem; flex-shrink: 0; }

.anime-continue-grid { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 20px; -webkit-overflow-scrolling: touch; }
.anime-continue-card { flex-shrink: 0; width: 140px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; }
.anime-continue-card img { width: 100%; height: 90px; object-fit: cover; }
.anime-continue-card-info { padding: 6px 8px; }
.anime-continue-card-title { font-size: 0.75rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.anime-continue-card-ep { font-size: 0.68rem; color: var(--accent); }
.anime-continue-card-bar { height: 2px; background: var(--border); }
.anime-continue-card-bar-fill { height: 100%; background: var(--accent); }

.anime-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 60px 0; color: var(--muted); font-size: 0.9rem; }

.repo-add-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.repo-add-row input { flex: 1; min-width: 180px; }
.anime-repo-item { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; }
.anime-repo-item-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.anime-repo-name { font-weight: 600; font-size: 0.9rem; flex: 1; }
.anime-provider-list { display: flex; flex-wrap: wrap; gap: 6px; }
.anime-provider-chip { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 0.75rem; }

/* ── Anime Video Player ──────────────────────────────── */
.anime-player-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 500;
  display: flex;
  flex-direction: column;
}
.anime-player-overlay.hidden { display: none; }
.anime-player-header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: rgba(0,0,0,0.8); flex-shrink: 0; }
.anime-player-header button { background: none; border: none; color: #fff; font-size: 1.2rem; padding: 4px 8px; cursor: pointer; opacity: 0.8; }
.anime-player-title { font-size: 0.9rem; font-weight: 600; color: #fff; }
.anime-player-ep { font-size: 0.75rem; color: rgba(255,255,255,0.6); }
.anime-player-body { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; background: #000; }
.anime-player-body video { width: 100%; height: 100%; max-height: 100%; object-fit: contain; }
.anime-player-footer { padding: 8px 16px; background: rgba(0,0,0,0.8); flex-shrink: 0; }
.anime-quality-row { display: flex; gap: 6px; flex-wrap: wrap; }
.anime-quality-btn { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #fff; padding: 4px 10px; border-radius: 4px; font-size: 0.72rem; cursor: pointer; }
.anime-quality-btn.active { background: var(--accent); border-color: var(--accent); }
.anime-loading { color: var(--muted); font-size: 0.85rem; padding: 20px 0; text-align: center; }

@media (max-width: 700px) {
  .anime-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  .anime-detail-hero { flex-direction: column; }
  .anime-detail-cover, .anime-detail-cover-placeholder { width: 100%; max-width: 200px; }
  .anime-eps-list { max-height: none; }
  .anime-player-header { padding-top: calc(12px + env(safe-area-inset-top, 28px)); }
}

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

.hidden { display: none !important; }
