/* ── Reset & base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface2:    #21262d;
  --border:      #30363d;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --accent:      #2188ff;
  --accent-h:    #58a6ff;
  --danger:      #f85149;
  --success:     #3fb950;
  --warn:        #d29922;
  --nav-h:       64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius:      12px;
  --radius-sm:   8px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overscroll-behavior: none;
}

input, textarea, select, button { font: inherit; color: inherit; }
img { display: block; }

/* ── Auth screen ─────────────────────────────────────────────────── */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.25rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem 1.75rem;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-logo { display: flex; justify-content: center; filter: invert(1); }
.auth-title { font-size: 1.75rem; font-weight: 700; text-align: center; letter-spacing: -0.02em; }
.auth-tagline { text-align: center; color: var(--text-muted); font-size: 0.9rem; }

.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.auth-tab {
  flex: 1;
  padding: 0.45rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.auth-tab.active { background: var(--surface2); color: var(--text); }

#auth-form, #forgot-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="search"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.7rem 0.9rem;
  width: 100%;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
input:focus { outline: none; border-color: var(--accent); }
input::placeholder { color: var(--text-muted); }

.btn-primary-full, #auth-submit {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  width: 100%;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-appearance: none;
}
.btn-primary-full:hover, #auth-submit:hover { opacity: 0.88; }
.btn-primary-full:disabled, #auth-submit:disabled { opacity: 0.5; cursor: default; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent-h);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-align: center;
  width: 100%;
}
.btn-link-back { text-align: left; width: auto; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: #fff;
  color: #111;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  cursor: pointer;
  font-weight: 500;
  width: 100%;
  transition: opacity 0.15s;
}
.btn-google:hover { opacity: 0.9; }

.forgot-title    { font-size: 1.3rem; font-weight: 700; }
.forgot-subtitle { color: var(--text-muted); font-size: 0.875rem; }

.error-msg   { color: var(--danger);  font-size: 0.85rem; }
.success-msg { color: var(--success); font-size: 0.85rem; }

/* ── App layout ──────────────────────────────────────────────────── */
#app-screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 0.5rem);
}

/* ── Banner ──────────────────────────────────────────────────────── */
.banner {
  background: color-mix(in srgb, var(--accent) 15%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.875rem;
}
.banner-text    { flex: 1 1 auto; }
.banner-actions { display: flex; gap: 0.5rem; }
.migration-status { flex: 1 1 100%; font-size: 0.8rem; color: var(--text-muted); }

/* ── Page header ─────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.5rem;
}
.page-title { font-size: 1.2rem; font-weight: 700; }

.btn-icon-header {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
}
.btn-icon-header:hover { color: var(--text); }

.header-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ── Tab panels ──────────────────────────────────────────────────── */
.tab-panel { padding: 0.75rem 1rem 1rem; }

/* ── Capture tab ─────────────────────────────────────────────────── */
.capture-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.quick-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  transition: border-color 0.15s;
}
.quick-input:focus { outline: none; border-color: var(--accent); }

.btn-accent {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.btn-accent:hover { opacity: 0.88; }

.btn-accent-sm {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-accent-sm:hover { opacity: 0.88; }

.btn-record-full {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn-record-full:hover { border-color: var(--accent); background: var(--surface2); }

/* ── Recording overlay ───────────────────────────────────────────── */
.recording-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.5rem 2rem;
}

.recording-ring-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0.5rem auto;
}

.recording-ring {
  width: 200px;
  height: 200px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--surface2);
  stroke-width: 12;
}

.ring-progress {
  fill: none;
  stroke: var(--danger);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 553;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

.ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
}
.ring-time { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.03em; }
.ring-sub  { font-size: 0.85rem; color: var(--text-muted); }

.live-preview {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  min-height: 1.2em;
  max-width: 280px;
}

.btn-stop {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem 2.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-appearance: none;
}
.btn-stop:hover { opacity: 0.88; }

/* ── Bottom nav ──────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0.5rem 0;
  transition: color 0.15s;
}
.nav-tab span { line-height: 1; }
.nav-tab:hover  { color: var(--text); }
.nav-tab.active { color: var(--accent-h); }
.nav-tab.active svg { stroke: var(--accent-h); }

/* ── Dumps list ──────────────────────────────────────────────────── */
.card-list { display: flex; flex-direction: column; gap: 0.6rem; }

.dump-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.dump-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.dump-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dump-date { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.dump-meta { font-size: 0.8rem; color: var(--text-muted); }
.dump-transcript {
  font-size: 0.875rem;
  border-left: 3px solid var(--border);
  padding-left: 0.6rem;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dump-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.25rem; }

.kind-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}
.kind-dump         { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-h); }
.kind-idea         { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.kind-meeting_note { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

.status-badge { font-size: 0.75rem; color: var(--text-muted); }
.status-badge.status-processing { color: var(--accent-h); }
.status-badge.status-failed     { color: var(--danger); }

.btn-sm {
  background: var(--surface2);
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-appearance: none;
}
.btn-sm:hover      { background: var(--border); color: var(--text); }
.btn-sm.btn-danger { color: var(--danger); }
.btn-sm.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm.btn-primary { background: var(--accent); color: #fff; }
.btn-sm.btn-ghost   { background: transparent; border: 1px solid var(--border); }

.btn-ghost-full {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 0.7rem;
  width: 100%;
  cursor: pointer;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}
.btn-ghost-full:hover { color: var(--text); border-color: var(--text-muted); }

.inline-edit {
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.15rem 0.4rem;
  font-weight: 600;
  width: 100%;
  max-width: 300px;
}

/* ── Items list ──────────────────────────────────────────────────── */
.items-list { display: flex; flex-direction: column; gap: 0.35rem; }

.items-group-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0.75rem 0 0.25rem;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  transition: opacity 0.15s;
}
.item-row.checked { opacity: 0.5; }
.item-row.checked .item-text { text-decoration: line-through; }
.item-check { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.item-text  { flex: 1; font-size: 0.9rem; }
.item-where { font-size: 0.75rem; color: var(--text-muted); }
.item-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.15rem 0.3rem;
  border-radius: var(--radius-sm);
  margin-left: auto;
  flex-shrink: 0;
}
.item-delete:hover { color: var(--danger); }

/* ── Search ──────────────────────────────────────────────────────── */
.search-bar {
  width: 100%;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.7rem 0.9rem;
  -webkit-appearance: none;
}
.search-bar:focus { outline: none; border-color: var(--accent); }

/* ── Sheets ──────────────────────────────────────────────────────── */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0.5rem 1.25rem calc(1.5rem + var(--safe-bottom));
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 90dvh;
  overflow-y: auto;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0.4rem auto 0.25rem;
}

.sheet-title { font-size: 1.1rem; font-weight: 700; }
.sheet-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.categorize-preview {
  font-size: 0.875rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-style: italic;
}

.toggle-row {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.toggle-btn {
  flex: 1;
  padding: 0.45rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.toggle-btn.active { background: var(--accent); color: #fff; }

.option-list { display: flex; flex-direction: column; gap: 0.4rem; }
.option-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s;
}
.option-btn:hover,
.option-btn.selected { background: color-mix(in srgb, var(--accent) 20%, var(--surface2)); border-color: var(--accent); }
.option-new { color: var(--accent-h); background: transparent; }

/* ── Toast ───────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 0.75rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}
#toast.toast-error  { border-color: var(--danger); color: var(--danger); }
#toast[hidden]      { display: none !important; }

/* ── Misc ────────────────────────────────────────────────────────── */
.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 2rem 0;
  text-align: center;
}

/* ── Hamburger menu ──────────────────────────────────────────────── */
.hamburger-btn {
  position: fixed;
  top: 0.85rem;
  right: 1rem;
  z-index: 30;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.hamburger-btn:hover { color: var(--text); }

.hamburger-dropdown {
  position: fixed;
  top: 3rem;
  right: 1rem;
  z-index: 31;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  overflow: hidden;
}

.hamburger-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.75rem 1rem;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.hamburger-item:hover { background: var(--surface2); }

/* ── Edit dump sheet extras ───────────────────────────────────────── */
.sheet-field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: -0.4rem;
}

.sheet-textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.7rem 0.9rem;
  width: 100%;
  resize: vertical;
  min-height: 120px;
  font-size: 0.9rem;
  line-height: 1.5;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.sheet-textarea:focus { outline: none; border-color: var(--accent); }
.sheet-textarea::placeholder { color: var(--text-muted); }

/* ── Lists grid ──────────────────────────────────────────────────── */
.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  padding: 0.25rem 0;
}

.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 0.9rem 0.9rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.list-card:hover { border-color: var(--accent); background: var(--surface2); }

.list-card-icon { font-size: 1.8rem; line-height: 1; }
.list-card-name { font-weight: 600; font-size: 0.9rem; word-break: break-word; }

.list-card-delete {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.2rem 0.35rem;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.list-card:hover .list-card-delete { opacity: 1; }
.list-card-delete:hover { color: var(--danger); }

/* ── Icon picker ─────────────────────────────────────────────────── */
.icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.icon-opt {
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 1.4rem;
  padding: 0.35rem 0.45rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.icon-opt:hover   { background: var(--border); }
.icon-opt.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, var(--surface2)); }

/* ── Tree items ──────────────────────────────────────────────────── */
.tree-container { display: flex; flex-direction: column; gap: 0.3rem; }

.tree-item-wrap { display: flex; flex-direction: column; gap: 0.25rem; }
.tree-item-wrap.dragging { opacity: 0.4; }
.tree-item-wrap.drag-over > .tree-item { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }

.tree-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
  cursor: default;
  user-select: none;
}
.tree-item.checked { opacity: 0.5; }
.tree-item.checked .item-text { text-decoration: line-through; }

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 1rem;
  flex-shrink: 0;
  padding: 0 0.1rem;
}
.drag-handle:active { cursor: grabbing; }

.tree-item-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  flex-shrink: 0;
}

.btn-icon-sm {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem 0.35rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.btn-icon-sm:hover { color: var(--text); background: var(--surface2); }
.del-btn:hover     { color: var(--danger) !important; }
.add-sub-btn:hover { color: var(--accent-h) !important; }

/* Sub-items indented */
.sub-items {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-left: 1.75rem;
}
.sub-items .tree-item {
  background: var(--surface2);
  font-size: 0.875rem;
}

/* contentEditable item text */
.item-text[contenteditable="true"] {
  outline: none;
  border-bottom: 1px solid var(--accent);
  min-width: 40px;
  cursor: text;
}
