:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #232630;
  --text: #eceef2;
  --text-dim: #9aa0ac;
  --accent: #6c8cff;
  --positive: #4caf7d;
  --neutral: #9aa0ac;
  --negative: #e0637a;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 20px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--surface-2);
}

header h1 {
  font-size: 20px;
  margin: 0;
}

.header-icons {
  display: flex;
  align-items: center;
  gap: 14px;
}

header a, header button.icon {
  color: var(--text);
  text-decoration: none;
  font-size: 22px;
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

main {
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
}

.fab {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 16px 28px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(108, 140, 255, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: block;
  color: inherit;
  text-decoration: none;
}

.card .meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 11px;
  color: var(--text-dim);
}

.card .summary {
  font-size: 15px;
  line-height: 1.4;
}

.card .tags {
  margin-top: 8px;
  font-size: 12px;
  color: var(--accent);
}

.empty {
  color: var(--text-dim);
  text-align: center;
  margin-top: 60px;
  font-size: 15px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  border-radius: var(--radius);
  background: var(--surface);
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
}

.tab.active {
  background: var(--accent);
  color: white;
}

.panel { display: none; }
.panel.active { display: block; }

.mic-button {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text);
  font-size: 48px;
  display: block;
  margin: 24px auto;
  cursor: pointer;
  transition: background 0.15s;
}

.mic-button.recording {
  background: var(--negative);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(224, 99, 122, 0.5); }
  70% { box-shadow: 0 0 0 22px rgba(224, 99, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 99, 122, 0); }
}

.hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 16px;
}

textarea, input[type="text"], input[type="search"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 14px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
}

textarea { min-height: 120px; }

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin: 16px 0 6px;
}

select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 15px;
}

button.primary {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 20px;
  cursor: pointer;
}

button.danger {
  width: 100%;
  background: transparent;
  color: var(--negative);
  border: 1px solid var(--negative);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  margin-top: 12px;
  cursor: pointer;
}

button:disabled { opacity: 0.5; cursor: default; }

.photo-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 4px;
}
.photo-buttons .secondary {
  flex: 1;
  padding: 12px 8px;
  font-size: 15px;
  background: var(--surface2, #1e2130);
  color: var(--text, #e2e8f0);
  border: 1px solid var(--border, #2a3347);
  border-radius: var(--radius, 10px);
  cursor: pointer;
  transition: background 0.15s;
}
.photo-buttons .secondary:active { background: var(--surface3, #2a3347); }

.photo-preview {
  width: 100%;
  border-radius: var(--radius);
  margin-top: 12px;
  max-height: 320px;
  object-fit: cover;
}

.field-row {
  display: flex;
  gap: 10px;
}
.field-row > div { flex: 1; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.checkbox-row input { width: 20px; height: 20px; }

.answer-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  font-size: 15px;
  line-height: 1.5;
}

.spinner-text {
  text-align: center;
  color: var(--text-dim);
  margin-top: 20px;
}

/* Onboarding overlay */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px;
  text-align: center;
}

.onboarding-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 16px;
}

.onboarding-text {
  font-size: 16px;
  color: var(--text-dim);
  line-height: 1.6;
  max-width: 380px;
  margin-bottom: 32px;
}

.onboarding button.primary {
  max-width: 280px;
  margin-top: 0;
}

/* Home hero */
.hero {
  text-align: center;
  padding: 28px 0 8px;
}

.hero-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.hero-sub {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
}

.hero-mic {
  width: 176px;
  height: 176px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(108, 140, 255, 0.35);
  transition: background 0.15s;
}

.hero-mic.recording {
  background: var(--negative);
  animation: pulse 1.4s infinite;
}

.hero-mic.processing {
  background: var(--surface-2);
  animation: none;
}

.hero-secondary {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 18px;
}

.hero-secondary a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
}

.cancel-link {
  display: block;
  text-align: center;
  color: var(--text-dim);
  margin-top: 14px;
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
}

.section-heading {
  font-size: 14px;
  color: var(--text-dim);
  margin: 28px 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.error-banner {
  background: rgba(224, 99, 122, 0.12);
  border: 1px solid var(--negative);
  color: var(--negative);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  margin-top: 16px;
  text-align: center;
}

.error-banner button {
  display: block;
  margin: 10px auto 0;
  background: none;
  border: 1px solid var(--negative);
  color: var(--negative);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  cursor: pointer;
}

/* AI Dashboard */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.dash-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.dash-heading {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.dash-priority-list, .dash-summary-list {
  margin: 0;
  padding-left: 18px;
  font-size: 15px;
  line-height: 1.6;
}

.dash-progress-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}

a.dash-progress-item {
  display: block;
  color: inherit;
  text-decoration: none;
}

.dash-progress-count {
  font-size: 22px;
  font-weight: 700;
}

.dash-progress-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Insights page */
.insight-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}

.insight-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.insight-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.insight-description {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
}

.insight-dismiss {
  display: block;
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

/* AI understood card */
.understood {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-top: 20px;
}

.understood-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 18px;
}

.understood-section {
  margin-bottom: 16px;
}

.understood-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.understood-summary, .understood-followup {
  font-size: 15px;
  line-height: 1.4;
}

.understood-tags {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  color: var(--accent);
}

.task-confirm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--surface-2);
}
.task-confirm-row:first-child { border-top: none; }

.task-confirm-name {
  flex: 1;
  font-size: 15px;
}

.task-confirm-row button {
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 14px;
  cursor: pointer;
}
.task-confirm-yes { background: var(--accent); color: white; }
.task-confirm-no { background: var(--surface-2); color: var(--text); }

.task-confirm-row.resolved {
  opacity: 0.5;
}
.task-confirm-row.resolved button { display: none; }
