/* HaughtStudio — one stylesheet, no build step.
   Surfaces run darkest to lightest, the brand gradient is used sparingly
   (the user's own message, the primary action, the send button), and nothing
   else competes with it. */

/* ---------------------------------------------------------------- tokens */

:root {
  /* Surfaces, darkest to lightest. */
  --bg: #0b0912;
  --bg-drawer: #0a0810;
  --surface: #14111c;
  --card: #1b1826;
  --card-2: #221d30;
  --card-3: #2a2438;

  /* The logo's own purples. */
  --purple-900: #2b0f52;
  --purple-700: #4c1d95;
  --purple-500: #7c5ce6;
  --purple-400: #8b6be8;
  --purple-300: #a98cf0;

  /* Brand accent is a gradient, used sparingly: the user's own message, the
     primary action, and the send button. Nothing else. */
  --accent: #8b5cf6;
  --accent-2: #5b9af5;
  --grad: linear-gradient(100deg, #8a6be8 0%, #5b9af5 100%);
  --grad-soft: linear-gradient(100deg, rgba(138, 107, 232, 0.18), rgba(91, 154, 245, 0.18));

  /* Text. */
  --text: #f3f1f8;
  --text-dim: #9c96ae;
  --text-faint: #6e6880;

  /* Semantic. */
  --gold: #f0c24b;
  --danger: #e5484d;
  --ok: #46b17b;
  --warn: #e2a33c;

  /* Lines and shape. */
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --radius: 14px;
  --radius-lg: 18px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);

  --drawer-w: 272px;
  --topbar-h: 56px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 0.75em; }
p:last-child { margin-bottom: 0; }

a { color: var(--purple-300); }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.09);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.mono { font-family: var(--mono); font-size: 0.78em; letter-spacing: 0.02em; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.grow { flex: 1; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Clamp helper for multi-line previews. */
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ----------------------------------------------------------------- layout */

.app {
  display: flex;
  height: 100%;
  height: 100dvh;
  min-height: 0;
}

.drawer {
  width: var(--drawer-w);
  flex: 0 0 var(--drawer-w);
  background: var(--bg-drawer);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 17, 28, 0.9), rgba(11, 9, 18, 0.65));
  backdrop-filter: blur(8px);
}

.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.view-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 22px 20px 60px;
}

.view-inner.wide { max-width: 1280px; }

/* --------------------------------------------------------------- sidebar */

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 14px 12px;
}

.brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--card-2);
  display: grid; place-items: center;
  flex: 0 0 38px;
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }

.brand-text { min-width: 0; }
.brand-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--purple-300);
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--mono);
  margin-top: -1px;
}

.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 10px 16px;
}

.drawer-foot {
  padding: 10px;
  border-top: 1px solid var(--line);
}

.newchat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  margin: 4px 4px 14px;
  width: calc(100% - 8px);
  border: 0;
  border-radius: 12px;
  background: var(--grad);
  color: #fff;
  font-weight: 650;
  font-size: 14.5px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(110, 90, 230, 0.28);
}
.newchat:hover { filter: brightness(1.06); }
.newchat:active { transform: translateY(1px); }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-size: 14.5px;
}
.nav-row:hover { background: rgba(255, 255, 255, 0.045); color: var(--text); }
.nav-row.active { background: var(--card-2); color: var(--text); }
.nav-row .icon { flex: 0 0 18px; opacity: 0.85; }
.nav-row .count { margin-left: auto; color: var(--text-faint); font-size: 12.5px; }

.section-label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 18px 11px 7px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
}

.chat-list { display: flex; flex-direction: column; gap: 3px; }

.chat-row {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 8px 11px;
  cursor: pointer;
  color: var(--text-dim);
}
.chat-row:hover { background: rgba(255, 255, 255, 0.045); }
.chat-row.active { background: var(--card-2); color: var(--text); }
.chat-row-top {
  display: flex; align-items: baseline; gap: 8px; min-width: 0;
}
.chat-row-title {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.chat-row-time {
  font-size: 11.5px;
  color: var(--text-faint);
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 5px;
}
.chat-row-preview {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-row .star-on { color: var(--gold); }

/* ------------------------------------------------------------------ bits */

.icon { width: 18px; height: 18px; flex: 0 0 auto; display: block; }
.icon-lg { width: 26px; height: 26px; }
.icon-xl { width: 34px; height: 34px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  flex: 0 0 auto;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.icon-btn.danger:hover { background: rgba(229, 72, 77, 0.14); color: var(--danger); }
.icon-btn.gold { color: var(--gold); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: var(--card-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--card-3); }
.btn.primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  font-weight: 650;
  box-shadow: 0 8px 22px rgba(110, 90, 230, 0.25);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.btn.danger { color: var(--danger); border-color: rgba(229, 72, 77, 0.35); background: rgba(229, 72, 77, 0.08); }
.btn.wide { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.tint {
  background: var(--grad-soft);
  border-color: rgba(139, 92, 246, 0.35);
  color: var(--purple-300);
}
.btn.tint:hover { background: rgba(139, 92, 246, 0.22); }
.btn:disabled { opacity: 0.5; cursor: default; }

.big-action {
  width: 100%;
  padding: 15px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--grad);
  color: #fff;
  font-size: 15.5px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(110, 90, 230, 0.28);
}
.big-action:hover { filter: brightness(1.06); }
.big-action .icon { width: 21px; height: 21px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card-pad { padding: 16px 18px; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }

.divider { height: 1px; background: var(--line); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12.5px;
}
.chip.plain { background: transparent; border-color: transparent; }
.chip.danger { color: var(--danger); border-color: rgba(229, 72, 77, 0.3); }

.badge {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 2px 6px;
}

.avatar {
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  background: var(--card-3);
  display: grid;
  place-items: center;
  font-size: 20px;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 32px; height: 32px; flex-basis: 32px; border-radius: 9px; font-size: 16px; }

/* ---------------------------------------------------------------- inputs */

.field { display: flex; flex-direction: column; gap: 6px; }

.label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.input, .textarea, .select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  color: var(--text);
  outline: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(124, 92, 230, 0.18);
}
.textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
.textarea.mono { font-family: var(--mono); font-size: 13px; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }

.hint { font-size: 12.5px; color: var(--text-faint); line-height: 1.45; }

/* A checkbox with an explanation beside it. */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  cursor: pointer;
}
.check-row input { margin-top: 2px; flex: 0 0 auto; }
.check-row strong { display: block; font-weight: 600; }

/* Switch */

.switch {
  position: relative;
  display: inline-block;
  width: 52px; height: 31px;
  flex: 0 0 52px;
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--card-3);
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  transition: background 0.16s ease;
  pointer-events: none;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 23px; height: 23px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.16s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.switch input:checked + .track { background: var(--purple-500); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(21px); }

/* Segmented control (markdown toggle, list/grid) */

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.segmented button.on { background: var(--card-3); color: var(--text); }

/* Stepper */

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 3px;
}
.stepper button {
  width: 34px; height: 32px;
  border: 0; background: transparent;
  color: var(--text); font-size: 17px;
  border-radius: 8px; cursor: pointer;
}
.stepper button:hover { background: rgba(255, 255, 255, 0.06); }
.stepper .value { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ page shells */

.page-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.page-head .icon { width: 26px; height: 26px; color: var(--purple-300); }
.page-head h1 { font-size: 25px; }
.page-lede {
  color: var(--text-dim);
  font-size: 14.5px;
  max-width: 62ch;
  margin: 0 0 20px;
}
.page-foot {
  margin-top: 22px;
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.5;
  max-width: 72ch;
}

/* List rows with a right-hand action, as on the persona and skills screens. */

.list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
  border-left: 0; border-right: 0; border-top: 0;
  color: inherit;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--card-2); }
.list-row .avatar { flex: 0 0 42px; }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { font-size: 15.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.list-row-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.list-row-end { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* Card with a title/description on the left and a control on the right. */
.setting-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.setting-card .body { flex: 1; min-width: 0; }
.setting-card h3 { font-size: 16.5px; margin-bottom: 6px; }
.setting-card p { color: var(--text-dim); font-size: 13.5px; }

/* --------------------------------------------------------------- markdown */

.md { font-size: 15px; line-height: 1.65; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 { margin: 1.2em 0 0.5em; line-height: 1.3; }
.md h1 { font-size: 1.45em; }
.md h2 { font-size: 1.25em; }
.md h3 { font-size: 1.1em; }
.md ul, .md ol { margin: 0.6em 0; padding-left: 1.4em; }
.md li { margin: 0.25em 0; }
.md blockquote {
  margin: 0.8em 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--purple-700);
  color: var(--text-dim);
}
.md code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 5px;
  border-radius: 5px;
}
.md pre {
  background: #0d0b14;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  overflow-x: auto;
  margin: 0.8em 0;
}
.md pre code { background: none; padding: 0; font-size: 13px; line-height: 1.55; }
.md table { border-collapse: collapse; margin: 0.8em 0; width: 100%; font-size: 14px; }
.md th, .md td { border: 1px solid var(--line-strong); padding: 7px 10px; text-align: left; }
.md th { background: var(--card-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md img { max-width: 100%; border-radius: var(--radius-sm); }
.md a { color: var(--purple-300); }

/* ------------------------------------------------------------------ chat */

.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.chat-thread {
  max-width: 820px;
  margin: 0 auto;
  padding: 26px 20px 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg { display: flex; flex-direction: column; }
.msg.user { align-items: flex-end; }
.msg.assistant { align-items: stretch; }

.bubble {
  max-width: 100%;
  border-radius: var(--radius-lg);
  padding: 14px 17px 8px;
  position: relative;
}
.msg.user .bubble {
  max-width: 78%;
  background: var(--grad);
  color: #fff;
  border-bottom-right-radius: 8px;
  box-shadow: 0 10px 26px rgba(110, 90, 230, 0.22);
}
.msg.assistant .bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 8px;
}
.msg.error .bubble { border-color: rgba(229, 72, 77, 0.4); }

.bubble-body { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.bubble-body.md { white-space: normal; }
.msg.user .bubble .md code { background: rgba(0, 0, 0, 0.22); }

.bubble-foot {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  min-height: 32px;
}
.msg.user .bubble-foot { justify-content: flex-end; }
.msg.user .bubble-foot .icon-btn { color: rgba(255, 255, 255, 0.82); }
.msg.user .bubble-foot .icon-btn:hover { background: rgba(0, 0, 0, 0.16); color: #fff; }
.bubble-foot .tool-tag {
  font-size: 12px;
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 9px;
  border-radius: 999px;
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  cursor: pointer;
}
.bubble-foot .tool-tag:hover { background: rgba(255, 255, 255, 0.09); }
.bubble-foot .spacer { flex: 1; }

.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attachment {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
}
.msg.assistant .attachment { background: var(--card-2); }
.attachment .icon-btn { width: 22px; height: 22px; color: inherit; opacity: 0.72; }
.attachment .icon-btn:hover { opacity: 1; background: rgba(255, 255, 255, 0.14); color: inherit; }
.attachment .icon { width: 15px; height: 15px; }
.attachment-thumb {
  width: 26px; height: 26px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.attach-thumb {
  width: 20px; height: 20px;
  object-fit: cover;
  border-radius: 5px;
  display: block;
}

/* Collapsible bubbles */

.bubble-content { min-width: 0; }
.bubble.collapsed .bubble-content { display: none; }

.bubble-preview {
  display: none;
  color: var(--text-dim);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg.user .bubble-preview { color: rgba(255, 255, 255, 0.88); }
.bubble.collapsed .bubble-preview { display: block; }

.collapse-btn .icon { transition: transform 0.15s ease; }
.bubble.collapsed .collapse-btn .icon { transform: rotate(-90deg); }

/* Downloadable media (images inside replies, attachments, tool output) */

.media-block {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}
.media-block img, .media-block video { display: block; max-width: 100%; border-radius: var(--radius-sm); }
.media-block.media-broken .media-actions { display: none; }

.media-actions {
  position: absolute;
  top: 8px; right: 8px;
  display: flex;
  gap: 4px;
  line-height: 0;
}
.media-btn {
  width: 30px; height: 30px;
  display: inline-grid; place-items: center;
  border: 0;
  border-radius: 8px;
  background: rgba(10, 8, 16, 0.7);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.media-btn:hover { background: rgba(10, 8, 16, 0.92); }
.media-btn .icon { width: 16px; height: 16px; }

.media-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.media-tile {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  line-height: 0;
}
.media-tile img { display: block; width: 100%; height: 150px; object-fit: cover; }

/* A tile whose asset has not decoded yet, or has gone missing. */
.media-loading, .media-missing {
  display: grid;
  place-items: center;
  height: 150px;
  line-height: 1;
  color: var(--text-faint);
  font-size: 12px;
  padding: 0 10px;
  text-align: center;
}

/* Thinking panel */

.thinking {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 2px;
}
.thinking summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 550;
}
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary:hover { color: var(--text); }
.thinking .chevron { margin-left: auto; transition: transform 0.15s ease; }
.thinking[open] .chevron { transform: rotate(90deg); }
.thinking-body {
  padding: 0 14px 13px;
  color: var(--text-dim);
  font-size: 13.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 42vh;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  padding-top: 11px;
}

.spinner {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--purple-300);
  animation: spin 0.7s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tool-log { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 2px; }
.tool-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 11px;
}
.tool-line .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: 0 0 7px; }
.tool-line.bad .dot { background: var(--danger); }
.tool-line .name { font-family: var(--mono); }

/* Empty state */

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 40px 24px;
}
.empty-state .mark {
  width: 84px; height: 84px;
  border-radius: 24px;
  background: var(--card-2);
  display: grid; place-items: center;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}
.empty-state .mark img { width: 100%; height: 100%; object-fit: cover; }
.empty-state h2 { font-size: 27px; color: var(--purple-300); letter-spacing: -0.02em; }
.empty-state p { color: var(--text-dim); max-width: 44ch; }

/* Composer */

.composer { padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); }
.composer-inner {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 26px;
  padding: 6px 6px 6px 8px;
}
.composer-inner:focus-within { border-color: rgba(139, 92, 246, 0.55); }
.composer textarea {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  max-height: 200px;
  min-height: 40px;
  padding: 9px 4px;
  line-height: 1.5;
}
.composer textarea::placeholder { color: var(--text-faint); }
.send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--grad);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  flex: 0 0 40px;
}
.send-btn:disabled { opacity: 0.45; cursor: default; }
.send-btn:not(:disabled):hover { filter: brightness(1.08); }

.attach-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px 5px 11px;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ----------------------------------------------------------- hover / menu */

.menu {
  position: fixed;
  z-index: 60;
  min-width: 210px;
  background: var(--card-2);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow);
}
.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.menu button:hover { background: rgba(255, 255, 255, 0.07); }
.menu button.danger { color: var(--danger); }
.menu .sep { height: 1px; background: var(--line); margin: 5px 4px; }

/* ---------------------------------------------------------------- modals */

.modal-root { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.modal-root:empty { display: none; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(6, 4, 10, 0.62);
  backdrop-filter: blur(3px);
  border: 0;
  padding: 0;
}

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal {
  pointer-events: auto;
  width: min(620px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal.wide { width: min(880px, 100%); }
.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 18px; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.16);
}

/* ----------------------------------------------------------------- toast */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--card-3);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease;
  max-width: min(92vw, 520px);
}
.toast.bad { border-color: rgba(229, 72, 77, 0.5); color: #ffd9da; }
.toast.good { border-color: rgba(70, 177, 123, 0.5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------- mcp / etc */

.server-card { padding: 0; overflow: hidden; }
.server-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}
.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 9px;
}
.status-dot.ok { background: var(--ok); }
.status-dot.error { background: var(--danger); }
.server-card .tools {
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.15);
}
.tool-item { display: flex; gap: 10px; padding: 6px 0; font-size: 13px; }

.memory-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}
.memory-row:last-child { border-bottom: 0; }
.memory-row blockquote {
  margin: 0;
  border-left: 3px solid var(--purple-700);
  padding-left: 11px;
  color: var(--text-dim);
  font-size: 13.5px;
}

.drop-zone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.015);
}
.drop-zone.hot { border-color: var(--purple-500); background: rgba(124, 92, 230, 0.08); }

.preview-tile {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  background: var(--card-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--text-faint);
}
.preview-tile img { width: 100%; height: 100%; object-fit: cover; }

/* ------------------------------------------------- topbar and chat shell */

[hidden] { display: none !important; }

.view--chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar-side {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}
.topbar-side.end { justify-content: flex-end; }
.topbar-mid { flex: 0 1 auto; min-width: 0; display: flex; justify-content: center; }
.topbar-center { text-align: center; min-width: 0; }
.topbar-title { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.topbar-sub { font-size: 11.5px; color: var(--text-faint); margin-top: -1px; }

.persona-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px 3px 3px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  color: var(--text-dim);
  cursor: pointer;
  max-width: 240px;
  font-size: 13.5px;
}
.persona-chip:hover { border-color: var(--line-strong); color: var(--text); }
.persona-chip-mark {
  width: 28px; height: 28px;
  flex: 0 0 28px;
  border-radius: 9px;
  background: var(--card-3);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 15px;
}
.persona-chip-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.persona-chip-name {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------- list extras */

.row-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
}
.row-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-faint);
}
.row-note .icon { width: 15px; height: 15px; }
.section-label .icon { width: 14px; height: 14px; }

.current-persona {
  border-color: rgba(139, 92, 246, 0.45);
  background: linear-gradient(100deg, rgba(139, 92, 246, 0.15), rgba(91, 154, 245, 0.09));
}

.chat-list-full { display: flex; flex-direction: column; }
.chat-list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 14px 4px;
  cursor: pointer;
  color: inherit;
}
.chat-list-row:hover { background: rgba(255, 255, 255, 0.03); }
.chat-list-row:last-child { border-bottom: 0; }

/* ------------------------------------------------------------- widgets */

.stop-square {
  width: 12px; height: 12px;
  border-radius: 3px;
  background: #fff;
  display: block;
}

.preview-box {
  min-height: 200px;
  max-height: 46vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.tool-output {
  margin-top: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
  max-height: 40vh;
  overflow: auto;
}

/* ------------------------------------------------------------ responsive */

.only-mobile { display: none; }
.only-desktop { display: initial; }

@media (max-width: 900px) {
  .only-mobile { display: initial; }
  .only-desktop { display: none; }

  .drawer {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 90;
    width: min(86vw, var(--drawer-w));
    flex-basis: auto;
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }
  body.drawer-open .drawer { transform: none; }

  .view-inner { padding: 18px 16px 46px; }
  .chat-thread { padding: 18px 14px; }
  .msg.user .bubble { max-width: 92%; }
  .composer { padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 22px; }
  .modal-wrap { padding: 0; place-items: end center; }
  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .topbar { gap: 6px; padding: 0 8px; }
  .topbar .chat-title-block { min-width: 0; }
}

@media (min-width: 901px) {
  #hamburger { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
