/* ==========================================================================
   MABISI AI — Stage 1 prototype stylesheet
   Plain CSS. No frameworks, no build step required.
   Theme is driven by CSS variables; dark mode = html[data-theme="dark"]
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --font-display: "Bricolage Grotesque", "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Schibsted Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f3f4ee;
  --bg-glow-a: rgba(14, 124, 91, 0.08);
  --bg-glow-b: rgba(74, 111, 165, 0.06);
  --surface: #fbfbf7;
  --surface-2: #ecefe5;
  --surface-3: #e3e7da;
  --side-bg: #edefe6;
  --ink: #182420;
  --ink-2: #47564f;
  --muted: #6d7b73;
  --line: #dde2d4;
  --line-strong: #c9d0bf;
  --accent: #0e7c5b;
  --accent-strong: #0a6249;
  --accent-soft: rgba(14, 124, 91, 0.1);
  --accent-ring: rgba(14, 124, 91, 0.18);
  --btn-ink: #f2fbf6;
  --user-bg: #e7efe3;
  --user-border: #d4e0cf;
  --danger: #b3492f;
  --danger-soft: rgba(179, 73, 47, 0.1);
  --ok: #0e7c5b;

  --code-bg: #101a15;
  --code-head: #16241d;
  --code-border: #223329;
  --code-ink: #d8e5db;
  --code-muted: #7e948a;
  --tok-com: #748a7d;
  --tok-str: #9ad6a9;
  --tok-kw: #82bce8;
  --tok-num: #e3ba79;
  --tok-tag: #82bce8;

  --shadow-sm: 0 1px 2px rgba(24, 36, 32, 0.06);
  --shadow-md: 0 6px 24px -8px rgba(24, 36, 32, 0.16);
  --shadow-lg: 0 18px 50px -12px rgba(24, 36, 32, 0.25);
  --toast-bg: #1b2823;
  --toast-ink: #e9f2ec;

  --hue-explain: #0e7c5b;
  --hue-code: #4a6fa5;
  --hue-idea: #a37b1c;
  --hue-learn: #5f7f46;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --topbar-h: 56px;
  --side-w: 292px;
  --read-w: 780px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0c1210;
  --bg-glow-a: rgba(62, 207, 154, 0.07);
  --bg-glow-b: rgba(130, 188, 232, 0.05);
  --surface: #131b17;
  --surface-2: #1b2620;
  --surface-3: #23312a;
  --side-bg: #0e1613;
  --ink: #e5eee8;
  --ink-2: #b6c4bc;
  --muted: #84948b;
  --line: #243129;
  --line-strong: #35473c;
  --accent: #3ecf9a;
  --accent-strong: #63ddb1;
  --accent-soft: rgba(62, 207, 154, 0.13);
  --accent-ring: rgba(62, 207, 154, 0.22);
  --btn-ink: #06281c;
  --user-bg: #1a2620;
  --user-border: #2a3b32;
  --danger: #e0805f;
  --danger-soft: rgba(224, 128, 95, 0.14);
  --ok: #3ecf9a;

  --code-bg: #0a100d;
  --code-head: #101915;
  --code-border: #1e2c25;
  --code-ink: #d5e2d9;
  --code-muted: #77897f;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 26px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 60px -12px rgba(0, 0, 0, 0.6);
  --toast-bg: #e7f0ea;
  --toast-ink: #15201b;

  --hue-explain: #3ecf9a;
  --hue-code: #82bce8;
  --hue-idea: #d9ab4a;
  --hue-learn: #9dc278;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.35s ease, color 0.35s ease;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

input,
textarea {
  font-family: inherit;
  color: inherit;
}

::selection {
  background: var(--accent-soft);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Thin scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-track {
  background: transparent;
}

svg {
  display: block;
  flex: none;
}

/* ==========================================================================
   App shell
   ========================================================================== */
.mabisi-app {
  position: fixed;
  inset: 0;
  display: flex;
  overflow: hidden;
  background: var(--bg);
  transition: background-color 0.35s ease;
}

/* Ambient layered background: soft directional glows + fine grain */
.mabisi-app::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(880px 460px at 88% -12%, var(--bg-glow-a), transparent 62%),
    radial-gradient(720px 420px at -12% 112%, var(--bg-glow-b), transparent 62%),
    url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
}

.mabisi-app > * {
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  width: var(--side-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--side-bg);
  border-right: 1px solid var(--line);
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    background-color 0.35s ease;
  overflow: hidden;
}

.app-collapsed .sidebar {
  width: 0;
  border-right-color: transparent;
}

.side-inner {
  width: var(--side-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-brand {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 750;
  font-size: 18px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 7px;
  white-space: nowrap;
}

.wordmark .wm-ai {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 5px;
  transform: translateY(-2px);
}

.side-collapse {
  margin-left: auto;
}

.side-actions {
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: none;
}

.btn-newchat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--btn-ink);
  font-weight: 650;
  font-size: 14.5px;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.btn-newchat:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-newchat:active {
  transform: translateY(0);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box > svg {
  position: absolute;
  left: 11px;
  color: var(--muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 30px 0 34px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13.5px;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

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

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.search-clear {
  position: absolute;
  right: 6px;
  width: 26px;
  height: 26px;
  display: none;
  place-items: center;
  border-radius: 7px;
  color: var(--muted);
}

.search-clear:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.search-box.has-value .search-clear {
  display: grid;
}

.side-projects {
  flex: none;
  padding: 10px 14px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.side-projects-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.project-add {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--accent);
  background: var(--accent-soft);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.project-add svg { width: 14px; height: 14px; }

.project-add:hover {
  background: var(--accent);
  color: var(--btn-ink);
}

.project-list {
  display: none;
  flex-direction: column;
  gap: 2px;
  max-height: 160px;
  overflow-y: auto;
}

.project-list.has-items {
  display: flex;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  padding: 8px 9px;
  border-radius: 8px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.project-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.project-row {
  position: relative;
  display: flex;
  align-items: center;
}

.project-row.active .project-item,
.project-item.active {
  background: var(--accent-soft);
  color: var(--ink);
}

.project-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.project-dot-all {
  background: var(--muted);
}

.project-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-del {
  display: none;
  flex: none;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  margin-right: 4px;
}

.project-del svg { width: 13px; height: 13px; }

.project-row:hover .project-del {
  display: grid;
}

.project-del:hover {
  background: var(--surface-3);
  color: var(--danger, #d9534f);
}

.side-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 10px 12px;
  overscroll-behavior: contain;
}

.nav-group-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 8px 6px;
}

.nav-item {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 8px 9px 12px;
  border-radius: 10px;
  text-align: left;
  color: var(--ink-2);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--ink);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.nav-open {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.nav-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-title input {
  width: 100%;
  font-size: 14px;
  font-weight: 500;
  padding: 2px 6px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
}

.nav-tools {
  display: none;
  gap: 2px;
  flex: none;
}

.nav-item:hover .nav-tools,
.nav-item:focus-within .nav-tools,
.nav-item.confirming .nav-tools {
  display: flex;
}

.nav-tools button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--muted);
}

.nav-tools button:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.nav-tools .tool-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.nav-item.confirming {
  background: var(--danger-soft);
}

.nav-confirm-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--danger);
  margin-right: 4px;
  white-space: nowrap;
}

.nav-empty {
  padding: 22px 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

.side-status {
  flex: none;
  margin: 10px 14px 14px;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: transparent;
}

.side-account {
  flex: none;
  padding: 10px 14px 0;
}

.account-signin {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.account-signin svg { width: 16px; height: 16px; }

.account-signin:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--ink);
}

.account-row {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 6px 0 4px;
}

.account-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--btn-ink);
  font-size: 12.5px;
  font-weight: 700;
}

.account-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-logout {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--muted);
}

.account-logout svg { width: 13px; height: 13px; }

.account-logout:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 var(--accent-ring);
  animation: pulse-dot 2.4s ease-out infinite;
}

@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 var(--accent-ring); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.side-status .status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 650;
}

.side-status .status-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

/* ==========================================================================
   Backdrop (mobile drawer)
   ========================================================================== */
.backdrop {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(10, 16, 13, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
  border: 0;
}

/* ==========================================================================
   Main column
   ========================================================================== */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Canvas panel ---------- */
.canvas-panel {
  flex: none;
  width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: var(--surface);
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.canvas-open .canvas-panel {
  width: min(480px, 42vw);
}

.canvas-head {
  flex: none;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--line);
}

.canvas-lang {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.canvas-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.canvas-actions button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink-2);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.canvas-actions button svg { width: 16px; height: 16px; }

.canvas-actions button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.canvas-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.62;
  color: var(--ink);
  white-space: pre;
  background: var(--code-bg);
}

@media (max-width: 900px) {
  .canvas-open .canvas-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    z-index: 30;
  }
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 5;
}

.app-collapsed .topbar {
  padding-left: 14px;
}

.topbar-wordmark {
  display: none;
}

.model-pill {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: default;
}

.model-pill .status-dot {
  width: 7px;
  height: 7px;
}

.model-pill .pill-sep {
  color: var(--line-strong);
}

.topbar-spacer {
  flex: 1;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  min-width: 36px;
  padding: 0 8px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-ghost:active {
  transform: scale(0.96);
}

.btn-ghost .btn-label {
  padding-right: 4px;
}

/* Topbar "New chat" duplicates the sidebar button once the sidebar is
   visible — only show it once the sidebar is collapsed, on desktop. */
@media (min-width: 901px) {
  #btn-newchat-top { display: none; }
  .app-collapsed #btn-newchat-top { display: inline-flex; }
}

/* ---------- Popover ---------- */
.popover-wrap {
  position: relative;
}

.popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 248px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  transform-origin: top right;
  animation: pop-in 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.94) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.pop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 10px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink-2);
  text-align: left;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.pop-row:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.pop-row svg {
  color: var(--muted);
}

.pop-row:hover svg {
  color: var(--ink-2);
}

.pop-row.danger,
.pop-row.danger svg {
  color: var(--danger);
}

.pop-row.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.pop-divider {
  height: 1px;
  background: var(--line);
  margin: 6px 8px;
}

/* switch */
.switch {
  margin-left: auto;
  width: 36px;
  height: 21px;
  border-radius: 999px;
  background: var(--surface-3);
  position: relative;
  transition: background-color 0.2s ease;
  flex: none;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s cubic-bezier(0.3, 0.9, 0.4, 1.2);
}

.switch[aria-checked="true"] {
  background: var(--accent);
}

.switch[aria-checked="true"]::after {
  transform: translateX(15px);
}

/* ==========================================================================
   Chat area
   ========================================================================== */
.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.chat-col {
  max-width: var(--read-w);
  margin: 0 auto;
  padding: 8px 24px 24px;
}

/* ---------- Welcome ---------- */
.welcome {
  padding: clamp(28px, 7vh, 72px) 0 12px;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.welcome[hidden] {
  display: none;
}

.welcome-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  padding: 5px 11px;
  border-radius: 999px;
  margin-bottom: 20px;
}

.welcome h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.6vw, 46px);
  font-weight: 750;
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
  max-width: 15ch;
}

.welcome h1 .h1-accent {
  color: var(--accent);
}

.welcome-sub {
  color: var(--ink-2);
  font-size: 15.5px;
  max-width: 52ch;
  margin: 0 0 30px;
}

.suggest-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 640px;
}

.suggest-card {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: left;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.suggest-card:nth-child(1) { animation-delay: 0.06s; }
.suggest-card:nth-child(2) { animation-delay: 0.12s; }
.suggest-card:nth-child(3) { animation-delay: 0.18s; }
.suggest-card:nth-child(4) { animation-delay: 0.24s; }

.suggest-card:hover {
  transform: translateY(-2px);
  border-color: var(--card-hue, var(--accent));
  box-shadow: var(--shadow-md);
}

.suggest-card:active {
  transform: translateY(0);
}

.suggest-icon {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--card-hue, var(--accent));
  background: color-mix(in srgb, var(--card-hue, var(--accent)) 12%, transparent);
}

.suggest-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.suggest-label .sug-arrow {
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  color: var(--card-hue, var(--accent));
}

.suggest-card:hover .sug-arrow {
  opacity: 1;
  transform: translateX(0);
}

.suggest-prompt {
  font-size: 14px;
  font-weight: 550;
  color: var(--ink);
  margin-top: 3px;
  line-height: 1.45;
}

.welcome-hints {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 30px;
  font-size: 12.5px;
  color: var(--muted);
}

kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-2);
}

/* ---------- Messages ---------- */
.messages {
  padding-top: 10px;
}

.msg {
  display: flex;
  gap: 14px;
  padding: 18px 0;
  animation: rise 0.35s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.msg + .msg {
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  margin-top: 2px;
}

.msg-body {
  flex: 1;
  min-width: 0;
}

.msg-name {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-name .msg-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 400;
  color: var(--muted);
}

.msg-name .gen-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 5px;
}

/* user message */
.msg.user {
  flex-direction: row-reverse;
}

.msg.user .msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 86%;
  flex: 0 1 auto;
}

.user-panel {
  background: var(--user-bg);
  border: 1px solid var(--user-border);
  border-radius: 14px 14px 4px 14px;
  padding: 11px 15px;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
}

.user-attach {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.attach-chip-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 4px 9px;
  border-radius: 7px;
}

.attach-chip-mini svg {
  color: var(--muted);
}

/* message action bar */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.msg:hover .msg-actions,
.msg:focus-within .msg-actions,
.msg.acted .msg-actions {
  opacity: 1;
}

@media (hover: none) {
  .msg-actions { opacity: 0.55; }
}

.act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  min-width: 28px;
  padding: 0 7px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.act-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.act-btn.pressed {
  color: var(--accent);
  background: var(--accent-soft);
}

.msg.user .msg-actions {
  justify-content: flex-end;
}

/* typing dots */
.typing-dots {
  display: inline-flex;
  gap: 5px;
  padding: 12px 4px 6px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: dot-bounce 1.1s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.stream-caret {
  display: inline-block;
  width: 8px;
  height: 1.02em;
  margin-left: 2px;
  border-radius: 2px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: caret-blink 0.9s steps(2, start) infinite;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

/* edit composer inside a user message */
.msg-edit {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-edit textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  padding: 11px 13px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
  font-size: 15px;
  line-height: 1.55;
}

.msg-edit textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.msg-edit-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-sm {
  height: 32px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 650;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.btn-sm:active { transform: scale(0.97); }

.btn-sm.primary {
  background: var(--accent);
  color: var(--btn-ink);
}

.btn-sm.primary:hover { background: var(--accent-strong); }

.btn-sm.plain {
  background: var(--surface-2);
  color: var(--ink-2);
}

.btn-sm.plain:hover { background: var(--surface-3); color: var(--ink); }

/* ==========================================================================
   Markdown content
   ========================================================================== */
.md {
  font-size: 15.5px;
  line-height: 1.68;
  color: var(--ink);
  overflow-wrap: break-word;
  min-width: 0;
}

.md > * {
  margin: 0;
}

.md > * + * {
  margin-top: 0.85em;
}

.md h1, .md h2, .md h3, .md h4 {
  font-family: var(--font-display);
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.md h1 { font-size: 1.45rem; font-weight: 750; margin-top: 1.3em; }
.md h2 { font-size: 1.28rem; font-weight: 720; margin-top: 1.25em; }
.md h3 { font-size: 1.1rem; font-weight: 700; margin-top: 1.15em; }
.md h4 { font-size: 1rem; font-weight: 680; margin-top: 1.1em; }

.md > h1:first-child, .md > h2:first-child, .md > h3:first-child {
  margin-top: 0;
}

.md p { }

.md strong { font-weight: 700; }
.md em { font-style: italic; }

.md ul, .md ol {
  padding-left: 1.45em;
}

.md ul { list-style: disc; }
.md ol { list-style: decimal; }
.modal-list { list-style: disc; }

.md li { margin-top: 0.32em; }
.md li::marker { color: var(--accent); font-weight: 600; }

.md blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 10px 16px;
  border-radius: 0 10px 10px 0;
  color: var(--ink-2);
}

.md blockquote p + p { margin-top: 0.5em; }

.md code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.13em 0.42em;
  white-space: nowrap;
}

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

.md a:hover { color: var(--accent-strong); }

.md hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.2em 0;
}

/* tables */
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  white-space: nowrap;
}

.md th {
  text-align: left;
  font-weight: 680;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--surface-2);
  padding: 9px 15px;
  border-bottom: 1px solid var(--line);
}

.md td {
  padding: 9px 15px;
  border-bottom: 1px solid var(--line);
  white-space: normal;
}

.md tr:last-child td { border-bottom: 0; }

.md td code { white-space: nowrap; }

/* ---------- Code blocks ---------- */
.codeblock {
  border: 1px solid var(--code-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--code-bg);
  box-shadow: var(--shadow-sm);
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px 7px 14px;
  background: var(--code-head);
  border-bottom: 1px solid var(--code-border);
}

.code-lang {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--code-muted);
}

.code-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.code-copy,
.code-canvas {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 27px;
  padding: 0 10px;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--code-muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.code-copy:hover,
.code-canvas:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--code-ink);
}

.code-copy.copied {
  color: var(--tok-str);
}

.code-canvas svg { width: 12px; height: 12px; }

.codeblock pre {
  margin: 0;
  padding: 15px 17px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.3px;
  line-height: 1.62;
  color: var(--code-ink);
  tab-size: 2;
}

.codeblock pre code {
  font-family: inherit;
  background: none;
  border: 0;
  padding: 0;
  white-space: pre;
}

.tok-com { color: var(--tok-com); font-style: italic; }
.tok-str { color: var(--tok-str); }
.tok-kw { color: var(--tok-kw); }
.tok-num { color: var(--tok-num); }

/* ==========================================================================
   Composer
   ========================================================================== */
.composer-wrap {
  flex: none;
  padding: 6px 20px calc(12px + env(safe-area-inset-bottom));
  position: relative;
  z-index: 4;
}

.composer-col {
  max-width: var(--read-w);
  margin: 0 auto;
}

.composer-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.35s ease;
}

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

.attach-row {
  display: none;
  flex-wrap: wrap;
  gap: 7px;
  padding: 11px 13px 0;
}

.attach-row.has-items {
  display: flex;
}

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 230px;
  padding: 5px 6px 5px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 12.5px;
  font-weight: 550;
  animation: pop-in 0.18s ease both;
}

.attach-chip svg { color: var(--muted); }

.attach-chip .ac-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-chip .ac-size {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  flex: none;
}

.attach-chip button {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  flex: none;
}

.attach-chip button:hover {
  background: var(--surface-3);
  color: var(--danger);
}

#composer-input {
  display: block;
  width: 100%;
  max-height: 220px;
  padding: 14px 16px 4px;
  border: 0;
  background: transparent;
  resize: none;
  font-size: 15.5px;
  line-height: 1.55;
}

#composer-input:focus {
  outline: none;
}

#composer-input::placeholder {
  color: var(--muted);
}

.composer-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 9px 9px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--muted);
  transition: background-color 0.14s ease, color 0.14s ease, transform 0.14s ease;
  position: relative;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-btn:active { transform: scale(0.93); }

.icon-btn.listening {
  color: var(--danger);
}

.icon-btn.listening::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 8px;
  border: 1.5px solid var(--danger);
  animation: mic-ring 1.2s ease-out infinite;
}

@keyframes mic-ring {
  0% { opacity: 0.9; transform: scale(0.85); }
  100% { opacity: 0; transform: scale(1.25); }
}

.composer-hint {
  margin-left: 8px;
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  user-select: none;
}

.composer-hint kbd { font-size: 10px; }

.composer-spacer { flex: 1; }

.send-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: var(--btn-ink);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.send-btn svg { transition: transform 0.18s ease; }

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

.send-btn:hover:not(:disabled) svg { transform: translate(1px, -1px); }

.send-btn:active:not(:disabled) { transform: scale(0.94); }

.send-btn:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
  box-shadow: none;
}

.send-btn.stop-mode {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  animation: stop-glow 1.6s ease-in-out infinite;
}

@keyframes stop-glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-ring); }
  50% { box-shadow: 0 0 0 5px var(--accent-ring); }
}

.composer-foot {
  max-width: var(--read-w);
  margin: 8px auto 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

.composer-foot b { font-weight: 650; color: var(--ink-2); }

/* Jump to latest */
.jump-latest {
  position: absolute;
  left: 50%;
  bottom: 148px;
  transform: translate(-50%, 8px);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 6;
}

.jump-latest.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.jump-latest:hover { color: var(--accent); }

/* ==========================================================================
   Toast & modal
   ========================================================================== */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(104px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 17px;
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.toast.out { animation: toast-out 0.25s ease both; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px) scale(0.96); }
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 70;
}

.modal-root[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 15, 12, 0.5);
  backdrop-filter: blur(3px);
  animation: fade-in 0.2s ease both;
  border: 0;
  width: 100%;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  width: min(580px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  margin: 12vh auto 0;
  padding: 26px 28px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: rise 0.3s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h2 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin: 0;
}

.modal-close {
  margin-left: auto;
}

.modal-card p {
  color: var(--ink-2);
  font-size: 14.5px;
  margin: 0 0 12px;
}

.modal-card h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  margin: 18px 0 8px;
}

.arch-flow {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}

.arch-node {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.arch-node b {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 650;
}

.arch-node span {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
}

.arch-arrow {
  align-self: center;
  color: var(--accent);
}

.modal-list {
  padding-left: 1.3em;
  margin: 6px 0 0;
  color: var(--ink-2);
  font-size: 14px;
}

.modal-list li { margin-top: 5px; }

.modal-card-sm {
  width: min(420px, calc(100vw - 32px));
}

.modal-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 14.5px;
  color: var(--ink);
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.modal-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions .btn-ghost {
  padding: 0 14px;
  height: 38px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.modal-actions .btn-ghost:hover {
  background: var(--surface-2);
}

.btn-primary {
  height: 38px;
  padding: 0 16px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--btn-ink);
  font-size: 14px;
  font-weight: 650;
  transition: background-color 0.18s ease, transform 0.18s ease;
}

.btn-primary:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.modal-foot {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
/* Prevent iOS from zooming into inputs (font-size < 16px triggers it) */
@media (max-width: 900px) {
  #composer-input,
  .search-box input,
  .msg-edit textarea,
  .nav-title input {
    font-size: 16px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(320px, 87vw);
    transform: translateX(-103%);
    box-shadow: var(--shadow-lg);
  }

  .side-inner { width: min(320px, 87vw); }

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

  .drawer-open .backdrop {
    display: block;
    opacity: 1;
  }

  .app-collapsed .sidebar { width: min(320px, 87vw); }

  .side-collapse { display: none; }

  .topbar-wordmark { display: flex; }

  .chat-col { padding: 4px 16px 16px; }

  .composer-wrap { padding: 6px 12px calc(10px + env(safe-area-inset-bottom)); }

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

  .jump-latest { bottom: 132px; }
}

@media (min-width: 901px) {
  .backdrop { display: none !important; }
}

@media (max-width: 640px) {
  .model-pill { display: none; }
  .btn-ghost .btn-label { display: none; }
  .btn-ghost { padding: 0 6px; }
  .msg.user .msg-body { max-width: 94%; }
}

@media (max-width: 420px) {
  .composer-hint { display: none; }
  .chat-col { padding: 2px 12px 12px; }
  .msg { gap: 10px; padding: 15px 0; }
  .welcome h1 { max-width: none; }
}

/* Small phones: keep everything reachable, nothing overflows */
@media (max-width: 359px) {
  :root { --side-w: 250px; }
  .suggest-card { padding: 12px 13px; }
  .user-panel { font-size: 14.5px; }
  .md { font-size: 15px; }
}

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

/* ==========================================================================
   MABISI AI — polish pass
   ========================================================================== */
:root {
  --read-w: 820px;
  --side-w: 300px;
  --topbar-h: 60px;
  --radius-lg: 18px;
}

body { letter-spacing: -0.005em; }

.mabisi-app::before {
  background-image:
    radial-gradient(760px 420px at 90% -8%, var(--bg-glow-a), transparent 64%),
    radial-gradient(620px 360px at -8% 108%, var(--bg-glow-b), transparent 64%);
}

.sidebar { box-shadow: inset -1px 0 0 rgba(255,255,255,.025); }
.side-brand { padding-left: 18px; }
.brand-mark svg { filter: drop-shadow(0 5px 12px color-mix(in srgb, var(--accent) 18%, transparent)); }
.wordmark { letter-spacing: -0.035em; }
.wm-ai { color: var(--accent); font-weight: 500; }

.topbar {
  padding-inline: 16px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
}
.model-pill {
  height: 32px;
  padding-inline: 13px;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--line) 70%, transparent);
}

.chat-col { padding-top: 14px; padding-bottom: 30px; }
.welcome { padding-top: clamp(36px, 9vh, 94px); }
.welcome h1 { letter-spacing: -0.045em; }
.welcome-sub { max-width: 58ch; line-height: 1.7; }

.suggest-grid { max-width: 700px; gap: 10px; }
.suggest-card {
  min-height: 92px;
  padding: 16px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset;
}
.suggest-card:hover { transform: translateY(-3px); }
.suggest-icon { width: 38px; height: 38px; border-radius: 11px; }

.msg { padding: 21px 0; gap: 15px; }
.msg + .msg { border-top-color: color-mix(in srgb, var(--line) 48%, transparent); }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 10px;
  box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 8%, transparent);
}
.msg-name { margin-bottom: 7px; }
.md { font-size: 15.8px; line-height: 1.72; }
.md p { max-width: 74ch; }
.md h1, .md h2, .md h3 { letter-spacing: -0.028em; }
.md ul, .md ol { margin-block: .65em; }
.md blockquote { padding: 11px 16px; }

.user-panel {
  padding: 12px 16px;
  border-radius: 16px 16px 5px 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,.035) inset;
}

.msg-actions { margin-top: 10px; }
.act-btn { height: 30px; border-radius: 8px; }
.act-btn:hover { transform: translateY(-1px); }

.codeblock {
  margin-top: 1em;
  border-radius: 14px;
  box-shadow: 0 8px 28px -18px rgba(0,0,0,.7);
}
.code-head { padding: 8px 9px 8px 14px; }
.code-copy { height: 29px; }
.codeblock pre { padding: 17px 18px; font-size: 13px; }

.composer-wrap {
  padding: 10px 20px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--bg) 78%, transparent) 28%);
}
.composer-card {
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 0 12px 38px -22px rgba(0,0,0,.55), 0 1px 0 rgba(255,255,255,.05) inset;
}
.composer-card:focus-within { box-shadow: 0 14px 42px -22px rgba(0,0,0,.58), 0 0 0 3px var(--accent-ring); }
.send-btn { box-shadow: 0 5px 15px color-mix(in srgb, var(--accent) 24%, transparent); }

.toast { border-radius: 12px !important; box-shadow: 0 14px 35px rgba(0,0,0,.22) !important; }

@media (max-width: 900px) {
  .topbar { height: 56px; padding-inline: 10px; }
  .topbar-wordmark { display: inline-flex; font-size: 17px; }
  .model-pill { position: static; transform: none; margin-left: 2px; }
  .topbar .btn-ghost .btn-label { display: none; }
  .topbar .btn-ghost { padding-inline: 8px; }
  .chat-col { padding-inline: 16px; }
  .welcome { padding-top: 34px; }
  .welcome h1 { font-size: clamp(30px, 9vw, 42px); }
  .suggest-grid { grid-template-columns: 1fr; }
  .suggest-card { min-height: 78px; }
  .composer-wrap { padding-inline: 10px; }
  .composer-hint { display: none; }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .model-pill { font-size: 10px; padding-inline: 9px; }
  .model-pill .pill-sep, .model-pill .status-dot { display: none; }
  .chat-col { padding-inline: 12px; }
  .welcome-sub { font-size: 14.5px; }
  .welcome-hints { display: none; }
  .msg { gap: 10px; padding: 17px 0; }
  .msg-avatar { width: 28px; height: 28px; border-radius: 8px; }
  .msg.user .msg-body { max-width: 92%; }
  .user-panel { padding: 10px 13px; }
  .md { font-size: 15.3px; line-height: 1.68; }
  .msg-actions { opacity: .7; }
  .act-btn span { display: none; }
  .act-btn { min-width: 32px; }
  .composer-card { border-radius: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .suggest-card:hover, .act-btn:hover { transform: none; }
}
