:root {
  --paper: #f5f2ea;
  --paper-deep: #e9e3d5;
  --ink: #182018;
  --muted: #687067;
  --line: #d6d0c2;
  --leaf: #315c44;
  --leaf-dark: #214331;
  --signal: #d6603f;
  --danger: #a64032;
  --white: #fffdf8;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(49, 92, 68, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 32px;
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: max(12px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left));
}
.wordmark {
  color: var(--ink);
  font: 700 19px/1 var(--serif);
  letter-spacing: -.04em;
  text-decoration: none;
}
.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { background: rgba(24, 32, 24, .06); }
.icon-button svg, .search-field svg {
  width: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

main { overflow: hidden; }
.capture {
  position: relative;
  display: flex;
  min-height: min(690px, calc(100dvh - 72px));
  padding: 9vh 24px 80px;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.capture::before {
  content: "";
  position: absolute;
  top: 7%;
  left: 50%;
  width: min(72vw, 660px);
  aspect-ratio: 1;
  border: 1px solid rgba(49, 92, 68, .11);
  border-radius: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}
.eyebrow {
  color: var(--leaf);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .2em;
  text-transform: uppercase;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; }
h1 {
  max-width: 760px;
  margin: 20px 0 14px;
  font-size: clamp(42px, 7.2vw, 84px);
  line-height: .96;
  letter-spacing: -.055em;
}
.capture-copy {
  max-width: 460px;
  min-height: 48px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}
.meter {
  display: flex;
  height: 42px;
  margin-top: 52px;
  align-items: center;
  gap: 4px;
}
.meter i {
  width: 3px;
  height: 4px;
  border-radius: 99px;
  background: var(--leaf);
  opacity: .25;
  transition: height 80ms linear, opacity 80ms linear;
}
.timer {
  min-height: 23px;
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .12em;
}
.capture-controls {
  display: grid;
  grid-template-columns: 48px 104px 48px;
  align-items: center;
  gap: 18px;
}
.discard-button {
  display: grid;
  width: 48px;
  height: 48px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 248, .55);
  cursor: pointer;
}
.discard-button svg {
  fill: none;
  stroke: var(--danger);
  stroke-width: 1.8;
  stroke-linecap: round;
}
.record-button {
  position: relative;
  display: grid;
  width: 104px;
  height: 104px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--leaf);
  color: var(--white);
  box-shadow: 0 16px 36px rgba(33, 67, 49, .2);
  cursor: pointer;
  transition: background 180ms ease, transform 150ms ease;
}
.record-button:hover { background: var(--leaf-dark); transform: translateY(-2px); }
.record-button:active { transform: scale(.97); }
.record-button:disabled { cursor: wait; opacity: .65; transform: none; }
.record-button svg {
  width: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.record-ring {
  position: absolute;
  inset: -10px;
  border: 1px solid var(--leaf);
  border-radius: 50%;
  opacity: .25;
}
.stop-icon { display: none; width: 24px; height: 24px; border-radius: 5px; background: var(--white); }
.capture[data-state="recording"] .record-button { background: var(--signal); }
.capture[data-state="recording"] .record-ring { border-color: var(--signal); animation: breathe 1.8s ease-out infinite; }
.capture[data-state="recording"] .mic-icon { display: none; }
.capture[data-state="recording"] .stop-icon { display: block; }
.capture-status { min-height: 20px; margin-top: 20px; font-size: 13px; font-weight: 650; }
.capture-error { min-height: 22px; margin-top: 8px; color: var(--danger); font-size: 13px; }

.library {
  position: relative;
  min-height: 520px;
  padding: 86px max(24px, calc((100vw - 1120px) / 2)) 120px;
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, .65);
}
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.section-heading h2 { margin: 10px 0 0; font-size: clamp(32px, 4vw, 50px); letter-spacing: -.04em; }
.search-field {
  display: flex;
  width: min(320px, 40vw);
  height: 44px;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.search-field svg { width: 18px; flex: 0 0 auto; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.library-tools { display: flex; margin-top: 34px; align-items: center; justify-content: space-between; gap: 24px; }
.library-filters, .create-tools { display: flex; align-items: center; gap: 8px; }
.filter-button, .secondary-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .05em;
  cursor: pointer;
}
.filter-button span { margin-left: 5px; font-variant-numeric: tabular-nums; opacity: .65; }
.filter-button:hover, .secondary-button:hover { border-color: var(--leaf); color: var(--leaf); }
.filter-button.active { border-color: var(--leaf); background: var(--leaf); color: var(--white); }
.secondary-button { border-radius: 4px; color: var(--leaf); }
.notes { display: grid; margin-top: 46px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.note-card {
  position: relative;
  min-width: 0;
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 2px 18px 2px 2px;
  background: var(--white);
  box-shadow: 0 8px 28px rgba(51, 47, 37, .05);
}
.note-card::before { content: ""; position: absolute; top: 0; left: 0; width: 42px; border-top: 3px solid var(--leaf); }
.note-card[data-status="failed"]::before { border-color: var(--danger); }
.note-card[data-status="processing"]::before { animation: processing 1.2s ease-in-out infinite alternate; }
.note-topline { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.note-state { color: var(--leaf); }
.note-card[data-status="failed"] .note-state { color: var(--danger); }
.note-title {
  width: 100%;
  margin: 20px 0 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 500 25px/1.15 var(--serif);
  letter-spacing: -.025em;
}
.note-transcript {
  display: block;
  width: 100%;
  min-height: 108px;
  padding: 0;
  resize: vertical;
  border: 0;
  background: transparent;
  color: #40483f;
  font-size: 14px;
  line-height: 1.65;
}
.note-title:focus, .note-transcript:focus { outline: 0; box-shadow: inset 0 -1px var(--signal); }
.note-transcript::placeholder { color: #9b9a90; }
.note-message { min-height: 18px; margin-top: 8px; color: var(--danger); font-size: 12px; }
.note-audio { display: block; width: 100%; height: 42px; margin-top: 14px; }
.tag-field { display: flex; margin-top: 14px; align-items: center; gap: 10px; }
.tag-field span { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.note-tags { min-width: 0; flex: 1; padding: 7px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--leaf); font-size: 12px; }
.note-actions { display: flex; margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); align-items: center; gap: 15px; flex-wrap: wrap; }
.note-action { min-height: 32px; padding: 0; border: 0; background: transparent; color: var(--leaf); font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.note-action:hover { color: var(--signal); }
.note-action[aria-pressed="true"] { color: var(--signal); }
.note-action:disabled { color: var(--line); cursor: default; }
.note-action.danger { margin-left: auto; color: var(--muted); }
.note-action.danger:hover { color: var(--danger); }
.empty-state { max-width: 470px; margin: 100px auto 0; text-align: center; }
.no-results { margin: 72px 0 0; color: var(--muted); text-align: center; }
.no-results h3 { margin: 0 0 8px; color: var(--ink); font-size: 26px; }
.no-results p { margin: 0; font-size: 13px; }
.empty-state > span { display: inline-grid; width: 46px; height: 46px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--leaf); font: 16px var(--serif); }
.empty-state h3 { margin: 24px 0 12px; font-size: 30px; letter-spacing: -.03em; }
.empty-state p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }

.toast {
  position: fixed;
  z-index: 20;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  padding: 11px 17px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--white);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: 180ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.dialog-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; padding: 20px; place-items: center; background: rgba(24, 32, 24, .42); backdrop-filter: blur(5px); }
.dialog { width: min(480px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 2px 22px 2px 2px; background: var(--paper); box-shadow: 0 24px 70px rgba(24, 32, 24, .24); }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; }
.dialog-heading h2 { margin: 8px 0 28px; font-size: 38px; letter-spacing: -.04em; }
.field { display: block; margin-bottom: 22px; }
.field > span { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; }
.field input, .field select { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--white); color: var(--ink); }
.field small { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.field a { color: var(--leaf); }
.dialog-actions { display: flex; margin-top: 30px; justify-content: flex-end; gap: 12px; }
.text-button, .primary-button { min-height: 44px; padding: 0 17px; border-radius: 4px; font-weight: 700; cursor: pointer; }
.text-button { border: 0; background: transparent; }
.primary-button { border: 1px solid var(--leaf); background: var(--leaf); color: var(--white); }

@keyframes breathe { from { opacity: .45; transform: scale(1); } to { opacity: 0; transform: scale(1.22); } }
@keyframes processing { from { width: 42px; opacity: .5; } to { width: calc(100% - 40px); opacity: 1; } }
@media (max-width: 720px) {
  .capture { min-height: calc(100dvh - 72px); padding-top: 8vh; padding-bottom: 56px; }
  .capture::before { top: 15%; width: 120vw; }
  h1 { max-width: 480px; }
  .meter { margin-top: auto; padding-top: 42px; }
  .library { padding-top: 62px; padding-bottom: 80px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .library-tools { align-items: stretch; flex-direction: column; }
  .library-filters, .create-tools { overflow-x: auto; padding-bottom: 3px; }
  .filter-button, .secondary-button { white-space: nowrap; }
  .notes { grid-template-columns: 1fr; margin-top: 30px; }
  .note-card { padding: 21px; }
  .note-actions { column-gap: 8px; }
  .note-action { min-height: 44px; padding: 0 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
