/* Karamos web widget — light theme is the default token set; dark theme
   overrides the same tokens under prefers-color-scheme. Everything else
   reads the tokens, never a hardcoded color, so the two themes stay in
   lockstep. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/InterVariable.woff2") format("woff2");
}

:root {
  /* Natasha — Gold identity (natasha-os-build/docs/experience/VISUAL_IDENTITY.md):
     warm bone ground, deep charcoal ink, soft sage and aged copper. Nothing
     pure white, nothing pure black, no blue. */
  --bg: #f4f6f2;
  --bg-elevated: #fbfcfa;
  --bg-sunken: #e9ede6;
  --sidebar-bg: #eef1ec;
  --text: #0d1b1e;
  --text-muted: #5b6b66;
  --border: #dbe2da;

  --accent: #c7987a;
  --accent-hover: #b5866a;
  --accent-contrast: #1a1206;
  --accent-soft: rgba(199, 152, 122, 0.16);
  --sage: #5b7d6b;

  --bubble-user-bg: #e9ede6;
  --bubble-user-text: #0d1b1e;

  --error-bg: #f6e9e4;
  --error-text: #8a3a2a;
  --error-border: #e2bfb2;

  --warning-bg: #f6efe0;
  --warning-text: #6e5520;
  --warning-border: #e3d3a8;

  --chip-bg: #eaeee8;
  --chip-text: #45524d;

  --code-bg: #eef1ec;
  --code-head-bg: #e3e8e0;

  --focus-ring: #c7987a;
  --shadow: 0 1px 2px rgba(13, 27, 30, 0.06), 0 1px 3px rgba(13, 27, 30, 0.08);
  --shadow-md: 0 8px 24px rgba(13, 27, 30, 0.1), 0 2px 6px rgba(13, 27, 30, 0.06);

  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji";
  --font-serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1b1e;
    --bg-elevated: #12343a;
    --bg-sunken: #0a1517;
    --sidebar-bg: #0f2327;
    --text: #f4f6f2;
    --text-muted: #a9b6b1;
    --border: #1f3e44;

    --accent: #c7987a;
    --accent-hover: #d8ad90;
    --accent-contrast: #1a1206;
    --accent-soft: rgba(199, 152, 122, 0.18);
    --sage: #5b7d6b;

    --bubble-user-bg: #163f46;
    --bubble-user-text: #f4f6f2;

    --error-bg: #3a2420;
    --error-text: #e9b8ab;
    --error-border: #5a3a33;

    --warning-bg: #35301f;
    --warning-text: #e6d4a3;
    --warning-border: #5a5033;

    --chip-bg: #163f46;
    --chip-text: #c9d3cf;

    --code-bg: #0f2327;
    --code-head-bg: #163f46;

    --focus-ring: #c7987a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
}

/* Author display rules (e.g. .login-screen { display: flex }) override the
   UA's [hidden] { display: none }, so restate it with !important — app.js
   drives all view switching through the hidden attribute. */
[hidden] {
  display: none !important;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------ brand mark */

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 6px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-contrast);
}

.login-brand-mark {
  width: 46px;
  height: 46px;
  padding: 10px;
  border-radius: 14px;
  margin: 0 auto 6px;
}

.message-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 6px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  margin-top: 2px;
}

/* ------------------------------------------------------------ login screen */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 320px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.login-card h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.login-sub {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* The sign-in buttons, one per method this appliance offers, stacked and
   all the same weight: outlined rather than filled, so none of them reads
   as the "right" way in, which depends on who is looking. Hidden until
   /auth/providers says there is single sign-on (widget/app.js). */
.login-methods,
.login-token-fields {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.login-method {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.login-method:hover {
  background: var(--accent-soft);
}

/* The access token, once there are buttons: a small text link that opens
   the token form beneath it. The form stays fully working; it is the way in
   when the identity provider is not. */
.login-token-toggle {
  border: none;
  background: none;
  padding: 2px 4px;
  color: var(--text-muted);
  font-size: 0.83rem;
  text-decoration: underline;
  cursor: pointer;
}

.login-token-toggle:hover {
  color: var(--text);
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-card input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-card button[type="submit"] {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  transition: background-color 0.15s ease;
}

.login-card button[type="submit"]:hover {
  background: var(--accent-hover);
}

.login-error {
  margin: 0;
  color: var(--error-text);
  font-size: 0.85rem;
}

/* --------------------------------------------------------------- app shell */

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.app-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.status-indicator {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

/* Who is signed in, beside the connection state and the Log out control.
   The name is plain text; the role is the same pill shape as the status
   indicator, because it is the same kind of standing fact about the
   session. Both sit after .status-indicator, whose margin-left: auto has
   already pushed this whole run to the header's right edge. */
.identity-name {
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.identity-role {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.status-indicator.streaming {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.icon-button,
.text-button {
  background: none;
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text);
  transition: background-color 0.15s ease;
}

.icon-button:hover,
.text-button:hover {
  background: var(--bg-sunken);
}

.icon-button {
  display: none; /* shown only below the sidebar-collapse breakpoint */
  font-size: 1.1rem;
}

.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ------------------------------------------------------------------ sidebar */

.sidebar {
  width: 272px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 4px;
  overflow-y: auto;
}

.new-chat-button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  text-align: left;
  transition: background-color 0.15s ease;
}

.new-chat-button .icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.new-chat-button:hover {
  background: var(--bg-sunken);
}

.thread-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  overflow-y: auto;
}

.thread-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  transition: background-color 0.15s ease;
}

.thread-item:hover {
  background: var(--bg-sunken);
}

.thread-item.active {
  background: var(--accent-soft);
}

.thread-item-title {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The "Call" tag on a phone call. Inline with the title, so the title's
   single-line ellipsis still applies to the row as a whole. */
.thread-item-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.5;
  vertical-align: 1px;
}

.thread-item-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.thread-list-empty {
  padding: 10px 10px 4px;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
}

/* -------------------------------------------------------- sidebar search */

.sidebar-search {
  position: relative;
  margin: 6px 0 2px;
}

.sidebar-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.sidebar-search input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sidebar-search input::placeholder {
  color: var(--text-muted);
}

.sidebar-search input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.sidebar-scrim {
  display: none;
}

/* -------------------------------------------------------------- chat pane */

.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative; /* anchors the drop overlay */
}

.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message-row {
  display: flex;
  gap: 14px;
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: 0 24px;
}

.message-row-user {
  justify-content: flex-end;
}

.message-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-row-user .message-content {
  flex: 0 1 auto;
  align-items: flex-end;
}

/* Generic bubble: used for the right-aligned user message and for inline
   error rows. Plain text, so newlines matter — pre-wrap stays here. */
.bubble {
  padding: 10px 16px;
  border-radius: 18px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.bubble-user {
  background: var(--bubble-user-bg);
  color: var(--bubble-user-text);
  max-width: 75%;
  border-bottom-right-radius: 6px;
}

.bubble-error {
  align-self: flex-start;
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
  border-radius: 12px;
}

/* Assistant message body: no bubble background, full row width, generous
   line-height. NOT pre-wrap — the renderer emits real block elements
   (p/h/ul/pre/table), and pre-wrap on top of those would double the
   spacing. */
.message-body {
  color: var(--text);
  line-height: 1.6;
  overflow-wrap: break-word;
}

.message-body > :first-child {
  margin-top: 0;
}

.message-body > :last-child {
  margin-bottom: 0;
}

.message-body p {
  margin: 0.5em 0;
}

.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4 {
  font-weight: 650;
  line-height: 1.3;
  margin: 0.9em 0 0.4em;
}

.message-body h1 {
  font-size: 1.35em;
}

.message-body h2 {
  font-size: 1.2em;
}

.message-body h3 {
  font-size: 1.08em;
}

.message-body h4 {
  font-size: 1em;
}

.message-body ul,
.message-body ol {
  margin: 0.5em 0;
  padding-left: 1.4em;
}

.message-body li {
  margin: 0.2em 0;
}

.message-body li ul,
.message-body li ol {
  margin: 0.2em 0;
}

.message-body blockquote {
  margin: 0.6em 0;
  padding: 0.1em 0 0.1em 0.9em;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
}

.message-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1em 0;
}

.message-body a {
  color: var(--accent);
  text-decoration: none;
}

.message-body a:hover {
  text-decoration: underline;
}

.message-body code {
  background: rgba(127, 127, 127, 0.16);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* Blinking-caret streaming indicator. The classic "steps(2)" trick: a
   single-keyframe animation that jumps the caret straight from visible to
   hidden halfway through, instead of fading — a sharp blink, not a pulse.
   Reduced motion is already handled globally (see the reduced-motion query
   at the end of this file, which forces animation-duration to ~0 on every
   element), so under that preference this just renders as a steady caret. */
@keyframes blink {
  to {
    visibility: hidden;
  }
}

.message-body.streaming::after {
  content: "";
  display: inline-block;
  width: 3px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--accent);
  border-radius: 1px;
  animation: blink 1s steps(2) infinite;
}

/* Code block: div.md-codeblock > div.md-codeblock-head (lang + copy) + pre > code */
.message-body .md-codeblock {
  margin: 0.75em 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--code-bg);
}

.message-body .md-codeblock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: var(--code-head-bg);
  border-bottom: 1px solid var(--border);
}

.message-body .md-codeblock-lang {
  font-family: var(--font-mono);
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.message-body .md-codeblock-copy {
  background: none;
  border: none;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.78em;
  color: var(--text-muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.message-body .md-codeblock-copy:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.message-body .md-codeblock pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
}

.message-body .md-codeblock code {
  background: none;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 0.875em;
}

/* Table: div.md-table-wrap > table.md-table */
.message-body .md-table-wrap {
  overflow-x: auto;
  margin: 0.75em 0;
}

.message-body .md-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9em;
}

.message-body .md-table th,
.message-body .md-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.message-body .md-table th {
  background: var(--bg-sunken);
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--chip-bg);
  color: var(--chip-text);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.76rem;
  font-family: var(--font-mono);
  transition: border-color 0.15s ease;
}

.chip:hover {
  border-color: var(--accent);
}

.chip-details {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--chip-text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  max-width: 60ch;
  overflow-x: auto;
}

.sources {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
}

.sources-heading {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.sources ul {
  margin: 0;
  padding-left: 1.1em;
}

.sources-truncated {
  margin-top: 3px;
  font-style: italic;
}

/* ------------------------------------------------------------- proposals */

/* One card per proposed send / booking, under the assistant message that
   proposed it. Same surface as .sources; the state pill is the only thing
   that changes colour, in place, as the decision and its outcome land. */
.proposals {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.proposal {
  font-size: 0.86rem;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.proposal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.proposal-kind {
  font-weight: 600;
  color: var(--text);
}

.proposal-state {
  font-size: 0.74rem;
  border-radius: 999px;
  padding: 2px 9px;
  background: var(--chip-bg);
  color: var(--chip-text);
  white-space: nowrap;
}

.proposal-state-approved,
.proposal-state-executing {
  background: var(--accent-soft);
  color: var(--accent);
}

.proposal-state-executed {
  background: var(--accent);
  color: var(--accent-contrast);
}

.proposal-state-failed {
  background: var(--error-bg);
  color: var(--error-text);
}

.proposal-state-rejected,
.proposal-state-expired {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.proposal-details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 3px 10px;
  margin: 0;
}

.proposal-details dt {
  color: var(--text-muted);
}

.proposal-details dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.proposal-body {
  white-space: pre-wrap;
}

.proposal-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.proposal-actions button {
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.proposal-actions button:disabled {
  opacity: 0.6;
}

.proposal-approve {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.proposal-approve:not(:disabled):hover {
  background: var(--accent-hover);
}

.proposal-reject:not(:disabled):hover {
  background: var(--bg-sunken);
}

.proposal-note {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* D26 confirmation: the phrase (and code) the person must type back. */
.proposal-confirm {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.proposal-confirm-prompt {
  font-size: 0.8rem;
  color: var(--text);
}

.proposal-confirm-input {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  background: var(--bg-elevated);
  color: var(--text);
  max-width: 28ch;
}

.proposal-confirm-input:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

/* ---------------------------------------------------------------- memory */

/* Sidebar entries to the two pages beside the chat pane — same shape as
   .new-chat-button. Memories adds a badge for however many facts are
   waiting on a decision; that badge is the only memory signal the chat view
   carries: a count, never a fact. */
.memory-nav-button,
.settings-nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  text-align: left;
  transition: background-color 0.15s ease;
}

.memory-nav-button .icon,
.settings-nav-button .icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.memory-nav-button span:nth-child(2),
.settings-nav-button span:nth-child(2) {
  flex: 1;
  min-width: 0;
}

.memory-nav-button:hover,
.settings-nav-button:hover {
  background: var(--bg-sunken);
}

/* Lit while that page is the view, the way the open thread is. */
.memory-nav-button.active,
.settings-nav-button.active {
  background: var(--accent-soft);
}

.memory-pending-badge,
.memory-tab-count {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

/* A held-fact card reuses .proposal's chrome (head, pill, actions, note —
   see proposals.js's card idiom); these three rules are all it adds. */
.fact-lead {
  margin: 0 0 6px;
  font-weight: 500;
}

.fact-statement {
  margin: 0 0 4px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
  font-style: italic;
  color: var(--text);
}

.fact-state-kept {
  background: var(--accent);
  color: var(--accent-contrast);
}

.fact-state-declined {
  background: var(--warning-bg);
  color: var(--warning-text);
}

/* The Memories and Settings pages: either is swapped in for .chat-pane by
   app.js (all three are `main`s in .app-body; `hidden` on two of them
   decides). One chrome for both — a header with the way back, then one
   scrolling body, which on Memories carries the two tabs. */
.memory-page,
.settings-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.memory-page-header,
.settings-page-header {
  padding: 20px 24px 0;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.memory-back-button,
.settings-back-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: -8px;
  padding: 6px 10px 6px 8px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.memory-back-button:hover,
.settings-back-button:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.memory-page-title,
.settings-page-title {
  margin: 12px 0 4px;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.memory-page-sub,
.settings-page-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.memory-tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  max-width: 760px;
  width: 100%;
  margin: 16px auto 0;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
}

.memory-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: -1px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.memory-tab:hover {
  color: var(--text);
}

.memory-tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.memory-page-body,
.settings-page-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.memory-tabpanel,
.settings-body {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px 32px;
  box-sizing: border-box;
}

/* Cards on the pending tab read a touch larger than the same card did in
   a transcript — they are the page's content, not an aside. */
.memory-tabpanel .proposal {
  font-size: 0.9rem;
  padding: 12px 14px;
}

.memory-empty {
  padding: 16px 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
}

.memory-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.memory-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.memory-item:last-child {
  border-bottom: none;
}

.memory-item-text {
  flex: 1;
  min-width: 0;
}

.memory-item-statement {
  margin: 0;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.memory-item-since {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.memory-item-forget {
  flex-shrink: 0;
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.memory-item-forget:hover {
  background: var(--bg-sunken);
}

.memory-item-forget:disabled {
  opacity: 0.6;
}

.memory-item-note,
.settings-error {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--error-text);
  width: 100%;
}

/* What the last answer about two names did, once its dialog has closed.
   Empty, it takes no room; it stays in the page so a screen reader hears
   the sentence when it arrives. */
.memory-page-status {
  margin: 8px 0 0;
  font-size: 0.88rem;
  color: var(--text);
}

.memory-page-status:empty {
  margin: 0;
}

/* "Are Kris and Chris the same person?" (memory.js buildPairQuestion): a
   modal dialog over the Memories page, in the page's own card chrome, with
   the buttons in the held-fact card's style. Below the 720px breakpoint it
   becomes a bottom sheet (see the responsive section). */
.subject-pair-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-md);
}

/* The sidebar scrim's shade, so the page dims the way it does behind the
   drawer. */
.subject-pair-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.pair-title {
  margin: 0 0 6px;
  font-size: 1.12rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* Focused by script so a screen reader starts at the question; it is not a
   control, so it draws no ring. */
.pair-title:focus {
  outline: none;
}

.pair-line {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.pair-names {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.pair-name {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.pair-name-title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
}

.pair-examples {
  margin: 0;
  padding-left: 18px;
  font-size: 0.85rem;
}

.pair-example {
  overflow-wrap: anywhere;
}

.pair-example + .pair-example {
  margin-top: 4px;
}

.pair-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pair-actions button {
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.pair-actions button:disabled {
  opacity: 0.6;
}

.pair-actions .pair-keep {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.pair-actions .pair-keep:not(:disabled):hover {
  background: var(--accent-hover);
}

.pair-actions .pair-different:not(:disabled):hover,
.pair-actions .pair-later:not(:disabled):hover {
  background: var(--bg-sunken);
}

.pair-actions .pair-later {
  border-color: transparent;
  color: var(--text-muted);
}

.pair-status {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--text);
}

.pair-status:empty {
  margin: 0;
}

.pair-status-error {
  color: var(--error-text);
}

/* -------------------------------------------------------------- settings */

/* One section per thing a client can change here: web research and sign-in
   methods, so far. The page is deliberately plain: a heading, the control,
   and the sentence that says what it actually does. */
.settings-section {
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section-title {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 600;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-label {
  flex: 1;
  min-width: 0;
  font-size: 0.92rem;
}

/* A native checkbox carrying role="switch": the accent colour is the only
   thing this changes, so the control keeps the platform's own focus ring,
   hit area and keyboard behaviour. */
.settings-switch {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.settings-switch:disabled {
  cursor: default;
  opacity: 0.6;
}

/* Each section is drawn into its own block (widget/settings.js), so the
   rule between them sits on the block rather than on the section. */
.settings-block + .settings-block {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* Sign-in methods: one row per provider, its state and its one action. */
.settings-provider {
  padding: 6px 0;
}

.settings-provider-state {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.83rem;
}

.settings-link-form {
  flex-shrink: 0;
  margin: 0;
}

.settings-link-button {
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 0.8rem;
  border: 1px solid var(--accent);
  background: var(--bg-elevated);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.settings-link-button:hover {
  background: var(--accent-soft);
}

.settings-account-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  font-size: 0.85rem;
}

/* The one-shot result of a link, read off the address the callback sent
   the browser to. Shown once, above the rows it is about. */
.settings-notice {
  margin: 0 0 10px;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  font-size: 0.85rem;
}

/* The honest line under a switch — what leaves this server when it is on,
   and what never does. Reads as prose, not as a hint. */
.settings-explain {
  margin: 6px 0 0;
  max-width: 62ch;
  color: var(--text-muted);
  font-size: 0.83rem;
  line-height: 1.5;
}

/* A notice that is not good news: a connect that did not complete, or a
   press that could not be done. The same warning tokens the staleness
   banner uses, so "look at this" reads the same everywhere. */
.settings-notice-warn {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

/* Connected accounts: one block per provider, the address and state at the
   top, then the sentence about it and its buttons. */
.settings-account {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.settings-section-title + .settings-account,
.settings-explain + .settings-account,
.settings-notice + .settings-account {
  border-top: none;
}

.settings-account-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.settings-account-name {
  font-size: 0.92rem;
  font-weight: 600;
}

/* The state, as a pill in the same shape the proposal cards use. */
.settings-account-status {
  font-size: 0.74rem;
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.settings-account-status-ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.settings-account-status-muted {
  background: var(--chip-bg);
  color: var(--chip-text);
}

.settings-account-status-warn {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.settings-account-status-error {
  background: var(--error-bg);
  color: var(--error-text);
}

.settings-account-email {
  margin: 4px 0 0;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.settings-account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.settings-account-button {
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.settings-account-button:hover:not(:disabled) {
  background: var(--bg-sunken);
}

.settings-account-button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.settings-account-button-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.settings-account-button:disabled {
  cursor: default;
  opacity: 0.6;
}

.staleness-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.82rem;
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
  border-radius: 10px;
  padding: 7px 12px;
}

.staleness-icon {
  flex-shrink: 0;
  line-height: 1.4;
}

.staleness-text {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}

/* The reconnect banner above the conversation: each line is a
   .staleness-banner (the same warning box) plus a button that opens
   Settings, held to the width of the messages below it. */
.connections-banner {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: 12px 24px 0;
}

.connections-banner-item {
  align-items: center;
}

.connections-banner-button {
  flex-shrink: 0;
  border-radius: 7px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--warning-border);
  background: var(--bg-elevated);
  color: var(--warning-text);
  cursor: pointer;
}

.connections-banner-button:hover {
  background: var(--warning-bg);
}

/* ---------------------------------------------------------- message actions */

/* Faded-until-hover action row (Copy, …) under a completed assistant
   message. Always visible on touch devices, which don't have a hover
   state to reveal it, and whenever a control inside it holds focus. */
.message-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.message-row:hover .message-actions,
.message-row:focus-within .message-actions {
  opacity: 1;
}

@media (hover: none) {
  .message-actions {
    opacity: 1;
  }
}

.message-action-button {
  display: flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: none;
  padding: 4px 9px;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 0.76rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.message-action-button:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.message-action-button.copied {
  color: var(--accent);
}

.message-action-button svg {
  flex-shrink: 0;
}

/* ------------------------------------------------------------ empty state */

.empty-state {
  margin: auto;
  width: 100%;
  max-width: 640px;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}

.empty-state-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  padding: 12px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-contrast);
}

.empty-state-greeting {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.prompt-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.prompt-card {
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.4;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.prompt-card:hover,
.prompt-card:focus-visible {
  transform: translateY(-2px);
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* -------------------------------------------------------------- composer */

.composer-area {
  flex-shrink: 0;
  padding: 0 24px 20px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 48rem;
  margin: 0 auto;
  padding: 9px 9px 9px 18px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
  padding: 7px 0;
  border: none;
  background: transparent;
  color: var(--text);
  line-height: 1.5;
}

.composer textarea:focus-visible {
  /* the wrapping .composer shows a focus-within ring; a second outline on
     the borderless textarea inside it would double up */
  outline: none;
}

.composer textarea:disabled {
  opacity: 0.6;
}

.composer-send {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.composer-send:hover:not(:disabled) {
  background: var(--accent-hover);
}

.composer-send:disabled {
  opacity: 0.5;
  cursor: default;
}

.composer-caption {
  max-width: 48rem;
  margin: 8px auto 0;
  padding: 0 24px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* -------------------------------------------------------------- documents */

.composer-chips,
.doc-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: 48rem;
  margin: 0 auto;
}

.composer-chips {
  margin-bottom: 8px;
}

/* [hidden] alone loses to the display rule above, so it is restated. */
.composer-chips[hidden],
.doc-strip[hidden],
.drop-overlay[hidden],
.document-panel[hidden] {
  display: none;
}

.doc-strip {
  width: 100%;
  padding: 8px 24px 0;
}

.doc-strip-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 0.82rem;
}

.doc-chip[data-state="failed"] {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

.doc-chip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.doc-chip-status {
  min-width: 0;
  overflow-wrap: anywhere;
}

.doc-chip-progress {
  width: 60px;
  height: 4px;
  accent-color: var(--accent);
}

.doc-chip-remove {
  padding: 0 4px;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

button.doc-chip-sent {
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
}

button.doc-chip-sent:hover:not(:disabled) {
  background: var(--accent-soft);
}

.doc-chip-sent.is-deleted {
  color: var(--text-muted);
  text-decoration: line-through;
  cursor: default;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 6px;
}

.composer-attach {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.composer-attach:hover:not(:disabled) {
  background: var(--bg-sunken);
}

.composer-attach:disabled {
  opacity: 0.5;
  cursor: default;
}

.composer {
  padding-left: 9px; /* the attach button sits where the text used to start */
}

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: var(--accent-soft);
  border: 2px dashed var(--accent);
  color: var(--text);
  font-weight: 600;
  pointer-events: none; /* drops must reach the pane underneath */
}

.document-panel {
  width: clamp(320px, 34vw, 480px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-elevated);
}

.document-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 4px;
}

.document-panel-title {
  min-width: 0;
  margin: 0;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.document-panel-close {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.document-panel-meta {
  margin: 0;
  padding: 0 16px 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.document-panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.doc-panel-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--bg-sunken);
  padding: 12px;
  border-radius: 10px;
}

.doc-panel-note {
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid var(--warning-border);
  border-radius: 10px;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 0.85rem;
}

.document-panel-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.doc-panel-button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
}

.doc-panel-button:hover {
  background: var(--bg-sunken);
}

.doc-panel-danger {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

/* The panel's download buttons: three for a document Karamos wrote, one for
   an upload. They wrap so three fit a phone-width panel. */
.document-panel-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* A written document is rendered markdown, so it reads as prose in the body
   font and lets the renderer's own blocks decide where lines break. */
.doc-panel-text.is-formatted {
  white-space: normal;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

/* The card under an answer that wrote a document. */
.doc-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.doc-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  padding: 12px 14px;
  max-width: 32rem;
}

.doc-card.is-deleted {
  color: var(--text-muted);
}

.doc-card.is-deleted .doc-card-title {
  text-decoration: line-through;
}

.doc-card-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.doc-card-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.doc-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.doc-card-open,
.doc-card-download {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
}

.doc-card-open:hover,
.doc-card-download:hover {
  background: var(--bg-sunken);
}

.doc-card-open:focus-visible,
.doc-card-download:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.doc-card-open:disabled,
.doc-card-download:disabled {
  cursor: default;
  opacity: 0.6;
}

.doc-card-error {
  margin: 8px 0 0;
  padding: 6px 10px;
  border: 1px solid var(--error-border);
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--error-text);
  font-size: 0.85rem;
}

.document-panel-error {
  margin: 0;
  padding: 0 16px 12px;
  color: var(--error-text);
  font-size: 0.85rem;
}

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

/* ------------------------------------------------------------ scrollbars */

.message-list,
.sidebar,
.thread-list,
pre {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.message-list::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.thread-list::-webkit-scrollbar,
pre::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.message-list::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.thread-list::-webkit-scrollbar-track,
pre::-webkit-scrollbar-track {
  background: transparent;
}

.message-list::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.thread-list::-webkit-scrollbar-thumb,
pre::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 720px) {
  .icon-button {
    display: inline-block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 20;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow-md);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 10;
  }

  .message-row {
    padding: 0 16px;
  }

  .message-row-user .bubble-user {
    max-width: 85%;
  }

  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .composer-area,
  .composer-caption,
  .connections-banner,
  .doc-strip {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Full screen over everything, the sidebar drawer (z-index 20) included. */
  .document-panel {
    position: fixed;
    inset: 0;
    width: auto;
    z-index: 30;
    border-left: none;
  }

  .memory-page-header,
  .settings-page-header,
  .memory-tabs,
  .memory-tabpanel,
  .settings-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* The question about two names as a bottom sheet: full width, pinned to
     the bottom edge, never taller than 85% of the visible screen, scrolling
     inside, with each answer a full-width button big enough for a thumb. */
  .subject-pair-dialog {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
    border-bottom: none;
    border-radius: 14px 14px 0 0;
  }

  .pair-names {
    grid-template-columns: 1fr;
  }

  .pair-actions {
    flex-direction: column;
  }

  .pair-actions button {
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 380px) {
  .app-header {
    padding: 8px 10px;
    gap: 8px;
  }

  .app-title {
    font-size: 0.92rem;
  }

  .status-indicator {
    max-width: 96px;
  }

  .message-list {
    padding: 16px 0;
    gap: 18px;
  }

  .message-row {
    padding: 0 10px;
  }

  .composer-area {
    padding: 0 10px 14px;
  }

  .connections-banner {
    padding: 10px 10px 0;
  }

  .composer-caption {
    padding: 0 10px;
  }

  .composer {
    padding: 7px;
  }

  .doc-strip {
    padding: 8px 10px 0;
  }

  .doc-chip {
    padding: 4px 8px;
  }
}

/* ------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------- natasha */
/* Playfair for the few headings; Inter for everything read at length. */
.login-card h1,
.app-title,
.memory-page h1,
.settings-page h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* ------------------------------------------------------------ voice call */
/* The mic button sits beside Send and matches Attach. */
.composer-voice {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.composer-voice:hover:not(:disabled) {
  background: var(--bg-sunken);
  color: var(--accent);
}

.composer-voice:disabled {
  opacity: 0.5;
  cursor: default;
}

/* The stage covers the conversation while a call is on: the star in the
   upper half, what was said beneath it, End at the foot. */
.voice-stage {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10vh 16px 24px;
  gap: 24px;
  background: var(--bg);
}

.voice-star {
  position: relative;
  width: 160px;
  height: 160px;
  color: var(--accent);
  flex-shrink: 0;
}

.voice-star-core {
  position: absolute;
  inset: 20%;
  width: 60%;
  height: 60%;
  fill: currentColor;
  filter: drop-shadow(0 0 10px rgba(199, 152, 122, 0.35));
  transform-origin: 50% 50%;
  animation: voice-breathe 4.8s ease-in-out infinite;
}

.voice-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0;
  transform: scale(0.55);
  pointer-events: none;
}

.voice-satellite {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  fill: var(--sage);
  opacity: 0;
  transform-origin: 50% 50%;
  pointer-events: none;
}

/* Idle / connecting: almost imperceptible breathing, dimmed. */
.voice-star[data-state="idle"] .voice-star-core,
.voice-star[data-state="connecting"] .voice-star-core {
  opacity: 0.45;
  animation-duration: 6s;
}

/* Listening: the form expands and contracts with more presence. */
.voice-star[data-state="listening"] .voice-star-core {
  animation: voice-listen 2.6s ease-in-out infinite;
}

/* Thinking: satellites emerge and orbit; the core steadies. */
.voice-star[data-state="thinking"] .voice-star-core {
  animation: none;
  transform: scale(0.9);
  opacity: 0.85;
}
.voice-star[data-state="thinking"] .voice-satellite {
  opacity: 0.9;
  animation: voice-orbit 3.2s linear infinite;
}
.voice-star[data-state="thinking"] .voice-satellite-2 {
  animation-delay: -0.8s;
}
.voice-star[data-state="thinking"] .voice-satellite-3 {
  animation-delay: -1.6s;
}
.voice-star[data-state="thinking"] .voice-satellite-4 {
  animation-delay: -2.4s;
}

/* Speaking: energy moves outward in rings. */
.voice-star[data-state="speaking"] .voice-star-core {
  animation: voice-breathe 1.6s ease-in-out infinite;
}
.voice-star[data-state="speaking"] .voice-ring {
  animation: voice-wave 1.8s ease-out infinite;
}
.voice-star[data-state="speaking"] .voice-ring-2 {
  animation-delay: 0.6s;
}
.voice-star[data-state="speaking"] .voice-ring-3 {
  animation-delay: 1.2s;
}

/* Ended / error: movement pauses, the bronze focal point holds. */
.voice-star[data-state="ended"] .voice-star-core,
.voice-star[data-state="error"] .voice-star-core {
  animation: none;
  opacity: 0.6;
  transform: scale(0.8);
}
.voice-star[data-state="error"] .voice-star-core {
  opacity: 1;
  filter: drop-shadow(0 0 16px rgba(199, 152, 122, 0.6));
}

@keyframes voice-breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

@keyframes voice-listen {
  0%,
  100% {
    transform: scale(0.96);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

@keyframes voice-orbit {
  from {
    transform: rotate(0deg) translateX(62px) rotate(0deg);
  }
  to {
    transform: rotate(360deg) translateX(62px) rotate(-360deg);
  }
}

@keyframes voice-wave {
  0% {
    transform: scale(0.55);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}

.voice-transcript {
  width: 100%;
  max-width: 36rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 1rem;
  line-height: 1.5;
}

.voice-line {
  margin: 0;
  color: var(--text-muted);
}

.voice-line-user {
  text-align: right;
  color: var(--text);
}

.voice-line-assistant {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text);
}

.voice-error {
  margin: 0;
  max-width: 36rem;
  text-align: center;
  color: var(--error-text);
}

.voice-end {
  flex-shrink: 0;
  padding: 10px 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.voice-end:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .voice-star-core,
  .voice-ring,
  .voice-satellite {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* --------------------------------------------------- awaiting approval */
/* The D26 pause on the header mark: movement stops, the bronze focal point
   holds. Anything else the mark does (hover, nothing today) yields to it. */
.brand-mark[data-state="awaiting"] {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 18px rgba(199, 152, 122, 0.55);
  animation: none;
}
.brand-mark[data-state="awaiting"] svg {
  transform: scale(1.08);
}

/* --------------------------------------------------------------- the box */
.box-form {
  max-width: 44rem;
  margin: 0 auto 32px;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.box-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.box-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.box-field-grow {
  flex: 1 1 14rem;
}

.box-field select,
.box-field input,
.box-field textarea {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.box-field textarea {
  resize: vertical;
  min-height: 8rem;
  line-height: 1.5;
}

.box-field select:focus,
.box-field input:focus,
.box-field textarea:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.box-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.box-keep {
  padding: 9px 26px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font: inherit;
  cursor: pointer;
}

.box-keep:hover:not(:disabled) {
  background: var(--accent-hover);
}

.box-keep:disabled {
  opacity: 0.5;
  cursor: default;
}

.box-status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.box-status.is-error {
  color: var(--error-text);
}

.box-hygiene {
  max-width: 44rem;
  margin: 0 auto 40px;
  padding: 20px 24px 0;
  border-top: 1px solid var(--border);
}

.box-hygiene-title {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.2rem;
}

.box-hygiene-summary {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.box-hygiene-group {
  margin: 0 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
}

.box-hygiene-group summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}

.box-hygiene-group summary .count {
  color: var(--text-muted);
  margin-left: 6px;
}

.box-hygiene-item {
  padding: 6px 12px 8px 24px;
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

.box-hygiene-item code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.box-hygiene-item .detail {
  display: block;
  color: var(--text-muted);
}
