/* Second Brain -- premium, fast, no external requests: system fonts only,
   no icon fonts, no web fonts. Theme is CSS variables switched via
   [data-theme] on <html>, defaulting to the OS preference. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.08);
  --transition: 160ms cubic-bezier(.4,0,.2,1);
}

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --border: #e4e1da;
  --text: #1c1b19;
  --text-muted: #6b6862;
  --accent: #b5622e;
  --accent-contrast: #ffffff;
  --accent-soft: #f4e3d7;
  --success: #3f7d4f;
  --danger: #b8433a;
  --danger-soft: #f6e0dd;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #17161a;
    --surface: #201f24;
    --surface-2: #29282e;
    --border: #35333b;
    --text: #efece6;
    --text-muted: #9c98a3;
    --accent: #e08a52;
    --accent-contrast: #1a1310;
    --accent-soft: #3a2a20;
    --success: #6fbf83;
    --danger: #e58077;
    --danger-soft: #3a2422;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17161a;
  --surface: #201f24;
  --surface-2: #29282e;
  --border: #35333b;
  --text: #efece6;
  --text-muted: #9c98a3;
  --accent: #e08a52;
  --accent-contrast: #1a1310;
  --accent-soft: #3a2a20;
  --success: #6fbf83;
  --danger: #e58077;
  --danger-soft: #3a2422;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

.hidden { display: none !important; }

/* --- Topbar --- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 650;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 550;
  padding: 7px 12px;
  border-radius: 8px;
  transition: background var(--transition), color var(--transition);
}

.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.offline-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 10px;
  border-radius: 20px;
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.offline-badge svg { animation: spin 3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

/* --- Layout --- */

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.view-title {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.view-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 28px;
}

/* --- Cards / surfaces --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* --- Capture view --- */

.capture-textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  padding: 0;
}

.capture-textarea::placeholder { color: var(--text-muted); }

.capture-tags {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  padding: 0;
  margin-top: 8px;
}

.capture-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.capture-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.capture-actions { display: flex; gap: 8px; align-items: center; }

.mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}
.mic-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.mic-btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(184,67,58,.4); }
  50% { box-shadow: 0 0 0 8px rgba(184,67,58,0); }
}

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .5; cursor: default; }

.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(1.08); }

.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger-soft); }
.btn-danger:hover { background: var(--danger-soft); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* --- Forms --- */

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input, .field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.field input:focus, .field select:focus { border-color: var(--accent); }

/* --- Note list (inbox) --- */

.note-list { display: flex; flex-direction: column; gap: 12px; }

.note-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.note-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.note-title { font-size: 15.5px; font-weight: 600; margin: 0; }

.note-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 10px;
}

.note-body {
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  margin: 0 0 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 650;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-processing { background: var(--accent-soft); color: var(--accent); }
.badge-inbox { background: var(--surface-2); color: var(--text-muted); }

.tag-chip {
  display: inline-flex;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-muted);
  margin-right: 6px;
}

.note-actions { display: flex; gap: 8px; margin-top: 4px; }

/* --- Invites --- */

.invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.invite-row:last-child { border-bottom: none; }

.invite-label { font-weight: 600; font-size: 14px; }
.invite-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* --- Empty state --- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { opacity: .5; margin-bottom: 12px; }

/* --- Toast --- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition);
  z-index: 100;
  box-shadow: var(--shadow);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Login / join --- */

.centered-card {
  max-width: 380px;
  margin: 10vh auto 0;
}

.centered-card h1 {
  font-size: 19px;
  margin: 0 0 4px;
}
.centered-card p.lead {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0 0 24px;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin: 4px 0 0;
}

@media (max-width: 600px) {
  .nav { display: none; }
  .app { padding: 20px 14px 80px; }
}
