:root {
  --bg: #FAFAF7;
  --ink: #1A1D1A;
  --ink-soft: #55594F;
  --label: #8A8A82;
  --line: #E7E7E0;
  --green: #1E4D36;
  --green-hover: #173D2B;
  --green-tint: #EEF3EF;
  --red: #B23A2F;
  --red-tint: #FBEAE8;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ---------- Header ---------- */
header {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 36px;
}

.wordmark {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 26px;
  letter-spacing: 0.2px;
  color: var(--green);
}

.wordmark span {
  color: var(--ink);
  font-weight: 500;
}

/* ---------- Sections ---------- */
.section { padding: 28px 0; border-bottom: 1px solid var(--line); }
.section:last-of-type { border-bottom: none; }

.label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--label);
  margin-bottom: 14px;
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Mode / category tabs ---------- */
.mode-tabs {
  display: flex;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
  width: max-content;
  margin-bottom: 16px;
}

.mode-tab {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.mode-tab.active { background: var(--green); color: #fff; }
.mode-tab:not(.active):hover { background: var(--green-tint); }

.mode-panel[hidden] { display: none; }

/* ---------- Textarea ---------- */
.text-input {
  display: block;
  width: 100%;
  max-width: 480px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  resize: vertical;
  transition: border-color .15s ease;
}

.text-input:hover { border-color: #CFCFC6; }
.text-input:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  font: inherit;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 10px 20px;
  transition: background .15s ease, color .15s ease, border-color .15s ease, opacity .15s ease;
}

.btn-primary {
  background: var(--green);
  color: #fff;
  border: 1px solid var(--green);
}
.btn-primary:hover { background: var(--green-hover); }

.btn-secondary {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.btn-secondary:hover { border-color: #CFCFC6; color: var(--ink); }

.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-small { padding: 6px 12px; font-size: 13px; }

button:focus-visible, select:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* Recording state */
.btn-recording {
  background: #fff;
  color: var(--red);
  border: 1px solid var(--red);
}

.rec-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  margin-right: 8px;
  vertical-align: 1px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.audio-status {
  font-size: 13px;
  color: var(--label);
}

.audio-status.ready { color: var(--green); }
.audio-status.error { color: var(--red); }

/* ---------- Processing stepper ---------- */
#processing { display: none; }
#processing.active { display: block; }

.step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  font-size: 14px;
  color: var(--label);
  transition: color .3s ease;
}

.step.current { color: var(--ink); }
.step.done { color: var(--ink-soft); }
.step.failed { color: var(--red); }

.step-marker {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  display: grid;
  place-items: center;
  transition: border-color .3s ease, background .3s ease;
}

.step.current .step-marker {
  border-color: var(--green);
  border-top-color: transparent;
  animation: spin 0.9s linear infinite;
}

.step.done .step-marker {
  background: var(--green);
  border-color: var(--green);
}

.step.done .step-marker::after {
  content: "";
  width: 5px;
  height: 9px;
  border-right: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(45deg) translate(-1px, -1px);
}

.step.failed .step-marker {
  border-color: var(--red);
}

.step.failed .step-marker::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

@keyframes spin { to { transform: rotate(360deg); } }

.done-note {
  display: none;
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--green-tint);
  border-radius: var(--radius);
  color: var(--green);
  font-size: 14px;
}

.done-note.show { display: block; }
.done-note.error { background: var(--red-tint); color: var(--red); }

#new-drop-btn { margin-top: 20px; }

/* ---------- Vault contents browser ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
  font-size: 13px;
}

.crumb {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  padding: 2px 4px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
}

.crumb:not(:disabled):hover { color: var(--green); }
.crumb.current { color: var(--ink); font-weight: 600; cursor: default; }
.crumb:disabled { cursor: default; }

.crumb-sep { color: var(--label); }

.muted { color: var(--label); font-size: 14px; padding: 8px 0; }

.hub-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.hub-name {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 19px;
}

.hub-subtitle {
  font-size: 13px;
  color: var(--label);
}

.hub-summary {
  margin-top: 10px;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
  max-width: 480px;
}

.hub-summary p, .hub-summary ul { margin: 0; }
.hub-summary p + p, .hub-summary ul + p, .hub-summary p + ul { margin-top: 8px; }
.hub-summary ul { padding-left: 18px; }

.node-list {
  display: flex;
  flex-direction: column;
  margin-top: 16px;
}

.node-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  font: inherit;
  border-radius: 0;
}

.node-list .node-row:last-child { border-bottom: none; }
.node-row:hover .node-title { color: var(--green); }

.node-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.node-kind { color: var(--label); font-size: 11px; }

.node-desc {
  flex-basis: 100%;
  font-size: 13px;
  color: var(--label);
}

.page-detail .hub-name { display: block; margin-bottom: 10px; }
.page-detail {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
  max-width: 480px;
}
.page-detail p, .page-detail ul { margin: 0; }
.page-detail p + p, .page-detail ul + p, .page-detail p + ul { margin-top: 8px; }
.page-detail ul { padding-left: 18px; }

/* ---------- Hot cache ---------- */
.hot-pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 14px;
  max-height: 50dvh;
  overflow-y: auto;
  color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
  .rec-dot, .step.current .step-marker { animation: none; }
  .step.current .step-marker { border-top-color: var(--green); }
}

@media (max-width: 480px) {
  .page { padding: 32px 20px 60px; }
  .actions button { width: 100%; }
  .text-input { max-width: none; }
}
