: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; }

.file-label {
  display: inline-block;
}
.file-label:hover { background: var(--green-hover); }

/* ---------- Chat ---------- */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  margin-bottom: 14px;
}

.chat-messages:empty { display: none; }

.chat-msg {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--green);
  color: #fff;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.chat-msg.pending {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--label);
  font-style: italic;
}

.chat-msg.error {
  align-self: flex-start;
  background: var(--red-tint);
  color: var(--red);
}

.chat-form { display: flex; }

.chat-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
}

.chat-input {
  flex: 1;
  padding: 12px 46px 12px 16px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  transition: border-color .15s ease;
}

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

.chat-send-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: #fff;
  transition: background .15s ease, opacity .15s ease;
}

.chat-send-btn:hover { background: var(--green-hover); }

.chat-send-btn:disabled {
  background: var(--line);
  color: var(--label);
  cursor: not-allowed;
}

/* ---------- 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); }

/* ---------- Drop list ---------- */
#drops-section { display: none; }
#drops-section.active { display: block; }

.drop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drop-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
}

.drop-preview {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.drop-status { color: var(--label); white-space: nowrap; flex-shrink: 0; }
.drop-row.done .drop-status { color: var(--green); }
.drop-row.failed { border-color: var(--red); }
.drop-row.failed .drop-status { color: var(--red); }

/* ---------- 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; }

@media (prefers-reduced-motion: reduce) {
  .rec-dot { animation: none; }
}

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