:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --line: #d2d2d7;
  --line-soft: #e8e8ed;
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --link: #0066cc;
  --red: #e30000;
  --orange: #f56300;
  --nav-bg: rgba(251, 251, 253, 0.8);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1d1d1f;
    --surface-2: #161617;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #86868b;
    --line: #424245;
    --line-soft: #2c2c2e;
    --blue: #0a84ff;
    --blue-hover: #409cff;
    --link: #2997ff;
    --red: #ff453a;
    --orange: #ff9f0a;
    --nav-bg: rgba(22, 22, 23, 0.8);
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
svg { fill: currentColor; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Global nav ---------- */

.globalnav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line-soft);
  padding-top: env(safe-area-inset-top);
}

.globalnav-inner {
  max-width: 1024px;
  margin: 0 auto;
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
}
.brand svg { width: 18px; height: 18px; }

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

.whoami select {
  appearance: none;
  border: 0;
  background: var(--line-soft);
  border-radius: 980px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 500;
}

.icon-btn {
  border: 0;
  background: none;
  padding: 6px;
  color: var(--text-2);
  display: grid;
  place-items: center;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { color: var(--text); }

/* ---------- Hero ---------- */

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

.hero {
  text-align: center;
  padding: 64px 0 56px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--orange);
  font-size: 17px;
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: clamp(40px, 8vw, 80px);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.gradient-text {
  background: linear-gradient(90deg, #0071e3 0%, #a24bff 50%, #ff2d55 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  max-width: 560px;
  margin: 20px auto 0;
  color: var(--text-2);
  font-size: clamp(19px, 2.4vw, 24px);
  line-height: 1.33;
  font-weight: 500;
}

/* ---------- Mic ---------- */

.mic {
  position: relative;
  width: 112px;
  height: 112px;
  margin: 48px auto 0;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 30px rgba(0, 113, 227, 0.35);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.mic:hover { background: var(--blue-hover); transform: scale(1.03); }
.mic:active { transform: scale(0.97); }
.mic svg { width: 44px; height: 44px; }
.mic .stop-icon { display: none; width: 34px; height: 34px; }

.mic-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--blue);
  opacity: 0;
  pointer-events: none;
}

.mic.recording { background: var(--red); box-shadow: 0 10px 30px rgba(227, 0, 0, 0.35); }
.mic.recording .mic-icon { display: none; }
.mic.recording .stop-icon { display: block; }
.mic.recording .mic-ring { border-color: var(--red); animation: pulse 1.6s ease-out infinite; }
.mic.busy { opacity: 0.5; pointer-events: none; }

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

.mic-hint {
  margin: 16px 0 0;
  color: var(--text-3);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Typed input ---------- */

.type-form {
  max-width: 560px;
  margin: 32px auto 0;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 980px;
  padding: 4px 4px 4px 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.type-form:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15); }
.type-form input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font-size: 15px;
  padding: 8px 0;
}
.type-form input::placeholder { color: var(--text-3); }
.type-form button {
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
}
.type-form button svg { width: 18px; height: 18px; }

/* ---------- Status card ---------- */

.status {
  max-width: 560px;
  margin: 24px auto 0;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  text-align: left;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  animation: rise 0.35s ease;
}
.status-title { margin: 0; font-size: 15px; font-weight: 600; }
.status-text { margin: 2px 0 0; font-size: 15px; color: var(--text-2); }
.status-spinner {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}
.status.done .status-spinner { border: 0; background: #34c759; animation: none; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm-1.4 14.2-4-4 1.4-1.4 2.6 2.6 5.6-5.6 1.4 1.4-7 7Z'/%3E%3C/svg%3E") center / contain no-repeat; }
.status.error .status-spinner { border: 0; background: var(--red); animation: none; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm1 15h-2v-2h2v2Zm0-4h-2V7h2v6Z'/%3E%3C/svg%3E") center / contain no-repeat; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Board ---------- */

.board { padding: 8px 0 48px; }

.board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h2 {
  margin: 0;
  font-size: clamp(28px, 4.5vw, 48px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.003em;
}

.segmented {
  display: inline-flex;
  background: var(--line-soft);
  border-radius: 980px;
  padding: 3px;
}
.segmented button {
  border: 0;
  background: none;
  border-radius: 980px;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  transition: background 0.2s, color 0.2s;
}
.segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: none;
  border-radius: 980px;
  padding: 5px 14px;
  font-size: 14px;
  color: var(--text-2);
}
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 24px 12px;
  box-shadow: var(--shadow);
  animation: rise 0.35s ease;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-title { margin: 0; font-size: 21px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title .dot { width: 10px; height: 10px; border-radius: 50%; }
.card-count { color: var(--text-3); font-size: 14px; font-variant-numeric: tabular-nums; }

.list { list-style: none; margin: 0; padding: 0; }

.item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
}
.item:first-child { border-top: 0; }

.check {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: none;
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.check:hover { border-color: var(--blue); }
.check svg { width: 14px; height: 14px; color: #fff; opacity: 0; }
.item.done .check { background: var(--blue); border-color: var(--blue); }
.item.done .check svg { opacity: 1; }
.item.done .item-title { color: var(--text-3); text-decoration: line-through; }

.item-body { flex: 1; min-width: 0; cursor: pointer; }
.item-title { margin: 0; font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.item-notes { margin: 2px 0 0; color: var(--text-2); font-size: 14px; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--line-soft);
  color: var(--text-2);
}
.tag.due { color: var(--link); }
.tag.overdue { color: var(--red); }
.tag.urgent { color: var(--orange); }

/* ---------- Done + history ---------- */

.done-section { margin-top: 32px; background: var(--surface); border-radius: var(--radius); padding: 16px 24px; box-shadow: var(--shadow); }
.done-section summary { cursor: pointer; font-weight: 600; color: var(--text-2); list-style: none; }
.done-section summary::-webkit-details-marker { display: none; }
.done-section summary::after { content: " ›"; display: inline-block; transition: transform 0.2s; }
.done-section[open] summary::after { transform: rotate(90deg); }
.done-section .list { margin-top: 8px; }

.empty { text-align: center; color: var(--text-3); padding: 48px 0; }

.history { padding: 24px 0 64px; border-top: 1px solid var(--line); }
.history h2 { font-size: clamp(24px, 3.5vw, 32px); margin-bottom: 16px; }
.history ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.history li { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 14px; padding: 14px 18px; }
.history .quote { margin: 0; font-size: 15px; }
.history .meta { margin: 6px 0 0; font-size: 13px; color: var(--text-3); }

.footer { text-align: center; color: var(--text-3); font-size: 12px; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-soft); }

/* ---------- Sheets ---------- */

.sheet {
  width: min(520px, calc(100% - 32px));
  border: 0;
  border-radius: 20px;
  padding: 0 20px 20px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.sheet[open] { animation: rise 0.25s ease; }

.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; }
.sheet-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.link-btn { border: 0; background: none; color: var(--link); padding: 4px 0; font-size: 17px; }
.link-btn.strong { font-weight: 600; }

.sheet-label { margin: 16px 0 6px 16px; font-size: 13px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0; }

.field-group {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.field-group > * { display: flex; width: 100%; border: 0; border-top: 1px solid var(--line-soft); }
.field-group > :first-child { border-top: 0; }
.field-group input,
.field-group textarea { background: none; padding: 12px 16px; outline: 0; resize: vertical; }
.field-group label { align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; min-height: 44px; }
.field-group label select,
.field-group label input { border: 0; background: none; text-align: right; color: var(--text-2); outline: 0; padding: 4px 0; max-width: 60%; }

.danger-btn { width: 100%; border: 0; border-radius: 12px; background: var(--surface); color: var(--red); padding: 12px; font-size: 17px; }

@media (max-width: 640px) {
  .hero { padding: 40px 0 40px; }
  .mic { width: 96px; height: 96px; margin-top: 36px; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .card { padding: 20px 18px 8px; }
  .done-section { padding: 14px 18px; }
}
