/* AssistantNotes web — glassmorphism theme system, mirrors the iOS app:
   deep-navy "space" dark mode + bright clean light mode, frosted-glass
   cards, gold (dark) / indigo (light) accents. Theme applied via
   [data-theme] on <html>; default (no attribute) = dark. */

/* DARK (default) */
:root {
  color-scheme: dark;
  --bg: #0D0D1F;
  --bg-secondary: #14142E;
  --bg-card: rgba(255,255,255,0.06);
  --bg-card-solid: #1A1A3E;
  --text: #ffffff;
  --text-subtle: rgba(255,255,255,0.6);
  --text-muted: rgba(255,255,255,0.35);
  --border: rgba(255,255,255,0.1);
  --accent: #FFD040;
  --accent-alt: #7B5CF6;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --glass-bg: rgba(255,255,255,0.06);
  --glass-border: rgba(255,255,255,0.12);

  /* Legacy aliases (existing rules below consume these) */
  --card: var(--glass-bg);
  --card2: var(--bg-card-solid);
  --label: var(--text);
  --secondary: var(--text-subtle);
  --tertiary: var(--text-muted);
  --separator: var(--border);
  --red: #ff453a;
  --orange: #ff9f0a;
  --green: #30d158;
  --purple: var(--accent-alt);
  --tabbar-bg: rgba(13, 13, 31, 0.85);
}

/* LIGHT */
[data-theme="light"] {
  color-scheme: light;
  --bg: #F5F7FF;
  --bg-secondary: #ECEEFF;
  --bg-card: #ffffff;
  --bg-card-solid: #ffffff;
  --text: #150D33;
  --text-subtle: rgba(21,13,51,0.6);
  --text-muted: rgba(21,13,51,0.35);
  --border: rgba(0,0,0,0.07);
  --accent: #5933E6;
  --accent-alt: #7B5CF6;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --glass-bg: rgba(255,255,255,0.8);
  --glass-border: rgba(255,255,255,0.9);

  --card: var(--bg-card);
  --card2: #E4E6F4;
  --red: #e0362c;
  --orange: #c93400;
  --green: #1e9e46;
  --tabbar-bg: rgba(245, 247, 255, 0.85);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* The hidden attribute only applies UA-level display:none — any authored
   display rule (e.g. .sheet{display:flex}) overrides it, which left the
   detail + sync sheets permanently open on top of the whole app. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: linear-gradient(180deg, var(--bg), var(--bg-secondary)) fixed;
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
  transition: background 0.25s ease, color 0.25s ease;
}

svg { fill: currentColor; }
.icon { width: 17px; height: 17px; color: var(--tertiary); flex: none; }

/* ── Tabs / layout ─────────────────────────────────────── */
.tab { display: none; min-height: 100dvh; padding-bottom: 84px; }
.tab.active { display: block; }

.navbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 72px 8px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.navbar h1 { font-size: 17px; font-weight: 600; }
.install-btn {
  border: 0; font: inherit; font-size: 13px; font-weight: 600; color: #fff;
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--purple));
}
.install-btn.pro { background: var(--orange); cursor: default; }

/* ── Record pane ───────────────────────────────────────── */
.record-pane { display: flex; flex-direction: column; align-items: center; padding: 10px 16px 0; }

.title-field {
  display: flex; align-items: center; gap: 8px;
  width: 100%; max-width: 640px;
  background: var(--card); border-radius: 12px;
  border: 1px solid var(--glass-border);
  padding: 11px 14px; box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.title-field input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 16px; color: var(--label);
}

.record-btn {
  position: relative; margin-top: 22px;
  width: 168px; height: 168px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 82%, white), var(--accent));
  box-shadow: 0 12px 26px color-mix(in srgb, var(--accent) 42%, transparent);
  display: grid; place-items: center; color: #fff;
  transition: transform 0.15s ease, background 0.3s ease, box-shadow 0.3s ease;
}
.record-btn:active { transform: scale(0.96); }
.record-btn.recording {
  background: linear-gradient(135deg, #ff6a5e, var(--red));
  box-shadow: 0 12px 26px color-mix(in srgb, var(--red) 42%, transparent);
}
.mic-icon { width: 64px; height: 64px; }
/* Idle state shows the app icon artwork, exactly like the iOS record button */
.btn-icon {
  position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px);
  border-radius: 50%; object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.record-btn.recording .btn-icon { display: none; }
.stop-square { display: none; width: 44px; height: 44px; border-radius: 10px; background: #fff; }
.record-btn.recording .stop-square { display: block; }

.pulse-ring {
  position: absolute; inset: -14px; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--red) 55%, transparent);
  opacity: 0; pointer-events: none;
}
.record-btn.recording .pulse-ring { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse {
  0%   { transform: scale(0.92); opacity: 0.9; }
  100% { transform: scale(1.18); opacity: 0; }
}

.timer {
  margin-top: 16px; font-size: 38px; font-weight: 300;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  color: var(--secondary);
}
.timer.on { color: var(--label); }
.record-status { margin-top: 2px; font-size: 15px; color: var(--secondary); }

.live-transcript {
  margin-top: 14px; width: 100%; max-width: 640px; max-height: 96px; overflow-y: auto;
  background: var(--card); border-radius: 12px; padding: 10px 14px;
  border: 1px solid var(--glass-border);
  font-size: 14px; color: var(--secondary); line-height: 1.45;
}

.divider { height: 1px; background: var(--separator); margin: 26px 20px 4px; }

/* ── Notes list ────────────────────────────────────────── */
.recent-pane { padding: 12px 16px 0; max-width: 720px; margin: 0 auto; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; padding: 6px 0; }
.section-head h2 { font-size: 20px; font-weight: 700; }

.search-field {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: 10px; padding: 9px 12px; margin: 6px 0 10px;
  border: 1px solid var(--glass-border);
}
.search-field input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 15px; color: var(--label);
}

.notes-list { display: flex; flex-direction: column; gap: 12px; padding-bottom: 24px; }

.note-card {
  background: var(--card); border-radius: 14px; padding: 12px 14px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.12s ease;
}
.note-card:active { transform: scale(0.985); }
.note-head { display: flex; justify-content: space-between; gap: 8px; }
.note-title { font-size: 16px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.note-time { font-size: 12px; color: var(--secondary); flex: none; }
.note-summary {
  margin-top: 4px; font-size: 14px; color: var(--secondary); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.note-progress { margin-top: 8px; }
.note-progress .bar { height: 3px; border-radius: 2px; background: var(--card2); overflow: hidden; }
.note-progress .fill { height: 100%; border-radius: 2px; background: var(--accent); }
.note-progress .fill.done { background: var(--green); }
.note-progress .label { margin-top: 3px; font-size: 11px; color: var(--secondary); }
.note-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11px; color: var(--secondary); overflow-x: auto; scrollbar-width: none; }
.note-meta::-webkit-scrollbar { display: none; }
.note-tag { color: var(--accent); white-space: nowrap; }

/* ── Welcome / no results ─────────────────────────────── */
.welcome { text-align: center; padding: 34px 24px; }
.welcome-mic {
  width: 110px; height: 110px; margin: 0 auto 14px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  display: grid; place-items: center; color: var(--accent);
  animation: breathe 2.8s ease-in-out infinite;
}
.welcome-mic svg { width: 46px; height: 46px; }
@keyframes breathe { 0%,100% { transform: scale(0.94); } 50% { transform: scale(1.08); } }
.welcome h2 { font-size: 17px; font-weight: 600; }
.welcome p { margin-top: 4px; font-size: 14px; color: var(--secondary); }

.no-results { text-align: center; padding: 26px 30px; }
.nr-title { font-size: 15px; font-weight: 600; }
.nr-sub { margin-top: 4px; font-size: 12px; color: var(--secondary); }

/* ── Detail sheet ─────────────────────────────────────── */
.sheet {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  background: var(--bg-secondary); width: 100%; max-width: 720px;
  max-height: 92dvh; border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  animation: sheetUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes sheetUp { from { transform: translateY(60%); } to { transform: translateY(0); } }
.sheet-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 8px;
}
.sheet-actions { display: flex; gap: 14px; }
.text-btn { border: 0; background: none; font: inherit; font-size: 16px; font-weight: 600; color: var(--accent); cursor: pointer; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--accent); }
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn.danger { color: var(--red); }
.sheet-body { overflow-y: auto; padding: 4px 16px calc(env(safe-area-inset-bottom) + 24px); }

.d-title { font-size: 24px; font-weight: 700; padding: 4px 2px 2px; }
.d-meta { font-size: 12px; color: var(--secondary); padding: 0 2px 10px; }

.card-block {
  background: var(--card); border-radius: 14px; padding: 14px; margin-bottom: 12px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}
.card-block h3 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.card-block h3 .dot { width: 8px; height: 8px; border-radius: 50%; }
.card-block p { font-size: 15px; line-height: 1.45; }
.card-block p.dim { color: var(--secondary); }

.action-row { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; cursor: pointer; }
.action-check {
  width: 21px; height: 21px; border-radius: 50%; flex: none; margin-top: 1px;
  border: 1.5px solid var(--tertiary); display: grid; place-items: center; color: #fff;
}
.action-row.done .action-check { background: var(--green); border-color: var(--green); }
.action-row.done .action-text { text-decoration: line-through; color: var(--secondary); }
.action-check svg { width: 13px; height: 13px; visibility: hidden; }
.action-row.done .action-check svg { visibility: visible; }
.action-text { font-size: 15px; line-height: 1.4; }

.play-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; font: inherit; cursor: pointer;
  background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px;
  border: 1px solid var(--glass-border);
  color: var(--label); font-size: 15px; font-weight: 600;
  box-shadow: var(--shadow);
}
.play-btn svg { width: 24px; height: 24px; color: var(--green); }
.play-btn.playing svg { color: var(--red); }

/* ── Tab bar ──────────────────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 0 calc(env(safe-area-inset-bottom) + 6px);
  background: var(--tabbar-bg);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--separator);
}
.tab-btn {
  border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--secondary); font: inherit; font-size: 10px; min-width: 84px;
}
.tab-btn svg { width: 24px; height: 24px; }
.tab-btn.active { color: var(--accent); }

/* ── Toast ────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--card2); color: var(--label);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25); z-index: 30;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ── Theme toggle (3D glass, fixed top-right) ─────────── */
.theme-toggle {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
[data-theme="light"] .theme-toggle {
  background: rgba(89,51,230,0.15);
  border: 1px solid rgba(89,51,230,0.3);
  box-shadow: 0 4px 12px rgba(89,51,230,0.2);
}
.theme-toggle:active { transform: scale(0.92); }
