/* ===========================================================================
   aibo — built on np.lol design system foundations
   Tokens copied verbatim from np.lol/colors_and_type.css.
   Component styles (.btn, .input, .tile, .flash-*) follow the system rules.
   =========================================================================== */

:root {
  /* PAPER */
  --paper:        #F6F1E7;
  --paper-2:      #EDE7D8;
  --paper-3:      #DCD3BD;

  /* INK */
  --ink:          #14110D;
  --ink-2:        #3A352D;
  --ink-3:        #776E5E;
  --ink-4:        #A99F8B;

  /* SIGNATURE */
  --tomato:       #FF4E2E;
  --tomato-deep:  #C9341B;
  --acid:         #DCFF3F;
  --acid-deep:    #B8DC1F;

  /* SUPPORT */
  --sky:          #4A8FFF;
  --bubble:       #FF8FA8;
  --leaf:         #2F8F5C;
  --amber:        #E6A300;
  --berry:        #B5274D;

  /* PER-APP ACCENT (aibo = tomato default) */
  --accent:       var(--tomato);
  --accent-deep:  var(--tomato-deep);

  /* SEMANTIC */
  --bg:           var(--paper);
  --bg-elev-1:    var(--paper-2);
  --bg-elev-2:    var(--paper-3);
  --fg:           var(--ink);
  --fg-2:         var(--ink-2);
  --fg-3:         var(--ink-3);
  --fg-muted:     var(--ink-4);
  --line:         var(--ink);
  --line-soft:    var(--paper-3);
  --success:      var(--leaf);
  --warning:      var(--amber);
  --danger:       var(--berry);
  --info:         var(--sky);

  /* TYPE */
  --font-sans:    'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --font-display: 'Boldonse', 'Bricolage Grotesque', serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --text-xs:      12px;
  --text-sm:      13px;
  --text-base:    15px;
  --text-md:      17px;
  --text-lg:      22px;
  --text-xl:      30px;
  --text-2xl:     44px;
  --text-3xl:     64px;
  --text-display: 96px;

  --lh-tight:    1.05;
  --lh-snug:     1.2;
  --lh-normal:   1.45;
  --lh-relaxed:  1.6;

  --tracking-tight: -0.02em;
  --tracking-snug:  -0.01em;
  --tracking-normal: 0;
  --tracking-wide:  0.04em;

  --weight-regular: 400;
  --weight-medium:  500;
  --weight-semi:    600;
  --weight-bold:    700;

  /* SPACING */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;
  --space-4: 16px; --space-5: 20px; --space-6: 24px;
  --space-8: 32px; --space-10: 40px; --space-14: 56px;
  --space-20: 80px; --space-30: 120px;

  /* RADII */
  --radius-xs: 4px;   --radius-sm: 8px;
  --radius-md: 14px;  --radius-lg: 20px;
  --radius-xl: 32px;  --radius-full: 999px;

  /* SHADOWS */
  --shadow-hard:    4px 4px 0 var(--ink);
  --shadow-hard-lg: 8px 8px 0 var(--ink);
  --shadow-hard-sm: 2px 2px 0 var(--ink);
  --shadow-soft:    0 8px 24px rgba(20,17,13,0.10);
  --shadow-inset:   inset 0 0 0 1.5px var(--ink);

  /* MOTION */
  --ease:        cubic-bezier(0.2, 0.9, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 120ms; --dur: 220ms; --dur-slow: 400ms;

  /* LAYOUT */
  --max-w:    1120px;
  --gutter:   clamp(20px, 5vw, 80px);
  --border-w: 1.5px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

/* ===========================================================================
   ELEMENT-LEVEL DEFAULTS (apply when body.nplol is set)
   =========================================================================== */

body.nplol {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.nplol h1 { font-size: var(--text-3xl); font-weight: var(--weight-semi); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); margin: 0 0 var(--space-4); }
.nplol h2 { font-size: var(--text-2xl); font-weight: var(--weight-semi); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); margin: 0 0 var(--space-3); }
.nplol h3 { font-size: var(--text-xl);  font-weight: var(--weight-semi); line-height: var(--lh-snug);  letter-spacing: var(--tracking-snug);  margin: 0 0 var(--space-3); }
.nplol h4 { font-size: var(--text-lg);  font-weight: var(--weight-semi); line-height: var(--lh-snug);  margin: 0 0 var(--space-2); }

.nplol p { margin: 0 0 var(--space-3); color: var(--fg-2); line-height: var(--lh-relaxed); }
.nplol small { font-size: var(--text-sm); color: var(--fg-3); }

.nplol a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
.nplol a:hover { text-decoration: underline; text-decoration-thickness: 1.5px; }

.nplol ::selection { background: var(--acid); color: var(--ink); }

/* Reserved for at-most-once-per-screen "lol moment" */
.nplol .display {
  font-family: var(--font-display);
  font-size: var(--text-display);
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: lowercase;
  margin: 0;
}

/* ===========================================================================
   COMPONENTS
   =========================================================================== */

/* Wordmark — Bricolage 800, lowercase, with tomato dot brand-moment */
.wordmark {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  text-transform: lowercase;
}
.wordmark .dot {
  display: inline-block;
  width: 0.4em;
  height: 0.4em;
  background: var(--accent);
  border-radius: 999px;
  align-self: center;
  margin: 0 0.05em;
}

/* Button — rounded 10px, 1.5px ink, 2px hard shadow that "presses in" */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 18px;
  font-family: var(--font-sans);
  font-weight: var(--weight-semi);
  font-size: 14px;
  line-height: 1.1;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow-hard-sm);
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}
.btn:hover  { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.nplol a.btn { color: var(--ink); text-decoration: none; }
.nplol a.btn:hover { text-decoration: none; }

.btn.fill-tomato { background: var(--accent); color: var(--ink); }
.btn.fill-tomato:hover { background: var(--accent-deep); }
.btn.fill-acid   { background: var(--acid); color: var(--ink); }
.btn.fill-ink    { background: var(--ink); color: var(--paper); }
.btn.fill-paper  { background: var(--paper); color: var(--ink); }
.btn.fill-berry  { background: var(--berry); color: var(--paper); }

.btn-ghost {
  border: 0;
  box-shadow: none;
  background: transparent;
}
.btn-ghost:hover  { background: var(--bg-elev-1); transform: none; box-shadow: none; }
.btn-ghost:active { transform: none; box-shadow: none; }

/* Input — rounded 10px, 1.5px ink, acid drop-shadow on focus */
.input {
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  outline: 0;
  width: 100%;
  box-sizing: border-box;
  transition: box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder { color: var(--fg-muted); }
.input:focus { box-shadow: 2px 2px 0 var(--acid); }

.field { display: flex; flex-direction: column; gap: 6px; }
.trigger-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.trigger-row .input { flex: 1; }
.trigger-enabled {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: var(--text-sm);
}
.field-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--fg-3);
}

/* Card / tile — slim 6px rounding · ink border · optional hard shadow */
.tile {
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  padding: 20px 24px;
  box-sizing: border-box;
}
.tile.shadow { box-shadow: 3px 3px 0 var(--ink); }
.tile.elev   { background: var(--paper-2); }

/* Flash — semantic color block, ink border, light hard shadow */
.flash {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.flash > div {
  padding: 10px 14px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow-hard-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  background: var(--paper);
  color: var(--ink);
}
.flash-notice { background: var(--acid); }
.flash-alert  { background: var(--berry); color: var(--paper); }

/* ===========================================================================
   PAGES
   =========================================================================== */

.auth-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-14) var(--gutter) var(--space-10);
  gap: var(--space-10);
  box-sizing: border-box;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: var(--space-8);
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hard);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.auth-card h1 {
  font-size: var(--text-xl);
  margin: 0;
}
.auth-card .lede {
  font-size: var(--text-sm);
  color: var(--fg-3);
  margin: 0;
}
.auth-card form { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-card .submit-row { margin-top: var(--space-2); }

.welcome-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-14) var(--gutter);
  gap: var(--space-10);
  text-align: center;
  box-sizing: border-box;
}
.welcome-page .display { color: var(--ink); }
.welcome-page .display .accent { color: var(--accent); }

/* ===========================================================================
   APP LAYOUT — sidebar + main
   =========================================================================== */

.app-layout {
  display: flex;
  min-height: 100dvh;
}

.modes-nav,
.sidebar {
  flex-shrink: 0;
  border-right: 1.5px solid var(--ink);
  background: var(--bg-elev-1);
  padding: var(--space-5) var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  position: sticky;
  top: 0;
  height: 100dvh;
  box-sizing: border-box;
}

.modes-nav { width: 200px; }
.sidebar   { width: 260px; }

.modes-nav-top { display: flex; flex-direction: column; gap: var(--space-4); }
.modes-nav-brand { display: inline-block; text-decoration: none; }
.modes-nav-brand .wordmark { font-size: 32px; }

.modes-nav-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 2px;
}
.nplol a.modes-nav-item {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--fg-2);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nplol a.modes-nav-item:hover { background: var(--paper); color: var(--fg-2); text-decoration: none; }
.nplol a.modes-nav-item.is-current {
  background: var(--paper);
  color: var(--ink);
  font-weight: var(--weight-semi);
  box-shadow: var(--shadow-inset);
}

.modes-nav-bottom {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line-soft);
  font-size: var(--text-sm);
}
.modes-nav-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.modes-nav-user { color: var(--fg-2); font-weight: var(--weight-medium); }
.modes-nav-logout { padding: 6px 12px; font-size: var(--text-sm); }

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.sidebar-brand {
  display: inline-block;
  text-decoration: none;
}
.sidebar-brand .wordmark { font-size: 32px; }

.sidebar-new {
  display: flex;
}
.sidebar-new-btn { width: 100%; justify-content: center; }

.chat-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
}
.chat-list-row {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: background var(--dur-fast) var(--ease);
}
.chat-list-row:hover { background: var(--paper); }
.chat-list-row.is-current { background: var(--paper); box-shadow: var(--shadow-inset); }

.nplol a.chat-list-item {
  display: block;
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  color: var(--fg-2);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nplol a.chat-list-item:hover { text-decoration: none; color: var(--fg-2); }
.chat-list-row.is-current a.chat-list-item { color: var(--ink); font-weight: var(--weight-semi); }

.chat-delete-form { margin: 0; display: flex; }
.chat-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--fg-3);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.chat-list-row:hover .chat-delete-btn { opacity: 1; }
.chat-delete-btn:hover { background: var(--bg-elev-2); color: var(--berry); }

.sidebar-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line-soft);
  font-size: var(--text-sm);
}
.sidebar-user { color: var(--fg-2); font-weight: var(--weight-medium); }
.sidebar-logout { padding: 6px 12px; font-size: var(--text-sm); }

/* Main column */
.app-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6) var(--gutter) var(--space-8);
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  min-height: 100dvh;
}

/* Profile picker — native <details> disclosure */
.profile-picker { position: relative; width: 100%; }
.profile-picker-trigger {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 8px 14px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  font-weight: var(--weight-semi);
  font-size: var(--text-sm);
  color: var(--ink);
  user-select: none;
  transition: background var(--dur-fast) var(--ease);
}
.profile-picker-trigger::-webkit-details-marker { display: none; }
.profile-picker-trigger:hover { background: var(--bg-elev-2); }
.profile-picker[open] .profile-picker-trigger { background: var(--bg-elev-2); }
.profile-picker .chev { font-size: 10px; color: var(--fg-3); }

.profile-picker-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 180px;
  padding: 6px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hard);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.profile-picker-item:hover { background: var(--bg-elev-1); }
.profile-picker-item.is-current { font-weight: var(--weight-semi); cursor: default; }
.profile-picker-item.is-current:hover { background: transparent; }
.profile-picker-item .check { color: var(--accent); }
.nplol a.profile-picker-item { color: var(--ink); text-decoration: none; }
.nplol a.profile-picker-item:hover { text-decoration: none; }
.nplol a.profile-picker-new { color: var(--accent); font-weight: var(--weight-semi); }

.profile-picker-form { margin: 0; }
.profile-picker-divider {
  margin: 4px 6px;
  border-bottom: 1px solid var(--line-soft);
}

/* Form errors */
.form-errors {
  background: var(--berry);
  color: var(--paper);
  padding: 10px 14px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow-hard-sm);
  font-size: var(--text-sm);
}

.form-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* Settings */
.settings {
  gap: var(--space-8);
  padding-top: var(--space-10);
}
.settings-header h1 {
  font-size: var(--text-2xl);
  margin: 0;
}
.settings-section {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-6) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.settings-section h3 {
  margin: 0;
  font-size: var(--text-lg);
}
.settings-section .section-lede {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--fg-3);
}
.settings-section .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.settings-section .section-head-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.settings-section.danger {
  border-color: var(--berry);
}
.settings-section .muted { color: var(--fg-3); font-size: var(--text-sm); margin: 0; }
.field.field-inline { flex-direction: row; align-items: flex-start; gap: var(--space-3); }
.field-inline-label { font-size: var(--text-sm); cursor: pointer; font-weight: var(--weight-semi); }
.tool-info { display: flex; flex-direction: column; gap: 2px; }
.tool-desc { font-size: var(--text-xs); color: var(--fg-3); margin: 0; }
.lock-glyph { font-size: 0.9em; opacity: 0.8; }

.settings-subline {
  font-size: var(--text-sm);
  color: var(--fg-3);
  margin-top: var(--space-2);
}
.tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--bg-elev-2);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
}
.tag-pending  { background: var(--bg-elev-2); color: var(--fg-3); }
.tag-building { background: var(--amber); color: var(--ink); }
.tag-ready    { background: var(--leaf); color: var(--paper); }
.tag-failed   { background: var(--berry); color: var(--paper); }

.tag-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.code-block {
  margin: 0;
  padding: var(--space-3);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--lh-snug);
  white-space: pre;
}

.build-log {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  max-height: 400px;
  overflow-y: auto;
  min-height: 80px;
}
.build-log:empty::before { content: "Ingen logg enda."; color: var(--ink-4); }
.build-log-line { white-space: pre-wrap; word-break: break-all; }

.auth-card-wide { max-width: 720px; }

.provider-list, .llm-model-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.provider-row {
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-1);
}
.nplol a.provider-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  color: var(--ink);
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease);
}
.nplol a.provider-link:hover { background: var(--bg-elev-2); text-decoration: none; }
.provider-name { font-weight: var(--weight-semi); }
.provider-meta { font-size: var(--text-xs); color: var(--fg-3); display: flex; align-items: center; gap: var(--space-2); }

.llm-model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px 12px;
  background: var(--bg-elev-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.llm-model-info { display: flex; flex-direction: column; gap: 2px; }
.llm-model-id { font-family: var(--font-mono); font-size: var(--text-sm); }
.llm-model-display { font-size: var(--text-xs); color: var(--fg-3); }

.inline-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line-soft);
  margin-top: var(--space-2);
}

.btn.destructive { color: var(--berry); }
.back-link { font-size: var(--text-sm); color: var(--fg-3); }
.nplol a.back-link { color: var(--fg-3); text-decoration: none; }
.nplol a.back-link:hover { color: var(--ink); text-decoration: none; }

/* Dashboard (profile home) */
.dashboard {
  gap: var(--space-8);
  padding-top: var(--space-10);
}
.dashboard-header h1 {
  font-size: var(--text-2xl);
  margin: 0;
}

.dashboard-chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.dashboard-chat-row {
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-1);
}
.nplol a.dashboard-chat-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 12px 14px;
  color: var(--ink);
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease);
}
.nplol a.dashboard-chat-link:hover { background: var(--bg-elev-2); text-decoration: none; }
.dashboard-chat-title {
  font-weight: var(--weight-semi);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dashboard-chat-meta {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-3);
}

.dashboard-actions {
  display: flex;
  justify-content: flex-end;
}

.chat-main { /* shared layout from .app-main; nothing extra needed yet */ }

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-2) 0 var(--space-6);
  overflow-y: auto;
  min-height: 0;
}
.messages .empty {
  color: var(--fg-3);
  font-size: var(--text-sm);
  text-align: center;
  margin: auto;
}
.messages:has(.message) .empty { display: none; }

.message {
  display: flex;
  max-width: 100%;
}
.message-user      { justify-content: flex-end; }
.message-assistant { justify-content: flex-start; }

.message-stack {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}
.message-user      .message-stack { align-items: flex-end; }
.message-assistant .message-stack { align-items: flex-start; }

.message-bubble {
  display: inline-block;
  padding: 10px 14px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  line-height: var(--lh-snug);
  word-wrap: break-word;
  white-space: pre-wrap;
  max-width: 100%;
}
.message-user      .message-bubble { background: var(--accent); color: var(--ink); border-top-right-radius: var(--radius-xs); }
.message-assistant .message-bubble { background: var(--paper);  color: var(--ink); border-top-left-radius:  var(--radius-xs); box-shadow: var(--shadow-hard-sm); }

/* Markdown styling within assistant bubbles. Keep typography compact —
   the bubble already provides padding and a max-width. */
.message-bubble.markdown { white-space: normal; }
.message-bubble.markdown > *:first-child { margin-top: 0; }
.message-bubble.markdown > *:last-child  { margin-bottom: 0; }
.message-bubble.markdown p { margin: 0 0 var(--space-2); color: inherit; }
.message-bubble.markdown h1,
.message-bubble.markdown h2,
.message-bubble.markdown h3,
.message-bubble.markdown h4 { margin: var(--space-3) 0 var(--space-2); line-height: var(--lh-snug); }
.message-bubble.markdown h1 { font-size: var(--text-lg); }
.message-bubble.markdown h2 { font-size: var(--text-md); }
.message-bubble.markdown h3,
.message-bubble.markdown h4 { font-size: var(--text-base); }
.message-bubble.markdown ul,
.message-bubble.markdown ol { margin: 0 0 var(--space-2); padding-left: var(--space-5); }
.message-bubble.markdown li { margin: 2px 0; }
.message-bubble.markdown code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-elev-2);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
}
.message-bubble.markdown pre {
  margin: var(--space-2) 0;
  padding: var(--space-3);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: var(--text-sm);
  line-height: var(--lh-snug);
}
.message-bubble.markdown pre code { background: transparent; padding: 0; color: inherit; font-size: inherit; }
.message-bubble.markdown a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.message-bubble.markdown a:hover { color: var(--accent-deep); }
.message-bubble.markdown blockquote {
  margin: var(--space-2) 0;
  padding: 4px 0 4px var(--space-3);
  border-left: 2px solid var(--ink);
  color: var(--fg-2);
}
.message-bubble.markdown table { border-collapse: collapse; margin: var(--space-2) 0; }
.message-bubble.markdown th, .message-bubble.markdown td {
  border: 1px solid var(--line-soft);
  padding: 6px 10px;
  font-size: var(--text-sm);
}
.message-bubble.markdown th { background: var(--bg-elev-2); font-weight: var(--weight-semi); text-align: left; }
.message-bubble.markdown hr { border: 0; border-top: 1px solid var(--line-soft); margin: var(--space-3) 0; }
/* Hide the anchor links Commonmarker injects into headings */
.message-bubble.markdown .anchor { display: none; }

.message-meta {
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-3);
  padding: 0 6px;
}

.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  padding: 0 4px;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.message:hover .message-actions { opacity: 1; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--fg-3);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--bg-elev-2); color: var(--ink); }
.icon-btn-destructive:hover { color: var(--berry); }
.inline-icon-form { margin: 0; display: inline-flex; }

.is-hidden { display: none !important; }
.message-edit-form { display: flex; flex-direction: column; gap: var(--space-2); width: 100%; max-width: 520px; }
.message-edit-form .composer { min-height: 80px; }
.message-edit-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }

/* Thinking indicator — three pulsing dots */
.message-bubble.thinking {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 14px 16px;
}
.thinking-dot {
  width: 7px;
  height: 7px;
  background: var(--ink-3);
  border-radius: 999px;
  animation: thinking-pulse 1.2s ease-in-out infinite;
}
.thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinking-pulse {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40%           { opacity: 1;    transform: translateY(-3px); }
}

.thinking-cancel {
  margin-top: var(--space-2);
  padding: 4px 10px;
  font-size: var(--text-xs);
  color: var(--fg-3);
  background: transparent;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.thinking-cancel:hover {
  color: var(--berry);
  border-color: var(--berry);
}

.message-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: var(--space-3) 0 var(--space-2);
}
.message-form .input { flex: 1; }

.composer-model-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--fg-3);
}
.composer-pickers {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
}
.composer-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.composer-model-label {
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  font-weight: var(--weight-semi);
  color: var(--fg-3);
}
.composer-model-select {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  padding: 4px 10px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  font-weight: var(--weight-medium);
}
.composer-model-hint .nplol a,
.composer-model-hint a { color: var(--accent); }

.composer-input-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
}

.composer {
  resize: none;
  min-height: 52px;
  max-height: 360px;
  line-height: 1.5;
  font-size: 16px;
  padding: 14px 18px;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-4) transparent;
}
.composer.is-scrollable { overflow-y: auto; }
.composer::-webkit-scrollbar { width: 8px; }
.composer::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 999px; }
.composer::-webkit-scrollbar-track { background: transparent; }
.message-form .btn { flex: 0 0 auto; padding-top: 14px; padding-bottom: 14px; }

/* Reset some Rails defaults */
.button_to { margin: 0; }
input, button { font-family: inherit; }
