@charset "UTF-8";
:root {
  color-scheme: dark;
  --bg: #0d0d12;
  --sidebar: #111117;
  --surface: #17171f;
  --surface-raised: #1d1d27;
  --surface-soft: #20202b;
  --surface-hover: #252532;
  --inset: #101016;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #f5f3fa;
  --text-soft: #bbb7c8;
  --text-muted: #858190;
  --text-faint: #5f5b69;
  --accent: #9d7bf3;
  --accent-bright: #b89aff;
  --accent-soft: rgba(157, 123, 243, 0.14);
  --accent-border: rgba(169, 137, 249, 0.3);
  --success: #67d6a2;
  --danger: #f47f8e;
  --danger-soft: rgba(244, 127, 142, 0.1);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  --sidebar-width: 292px;
  --header-height: 76px;
  --content-width: 860px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --ease: 160ms ease;
  font-family: "DM Sans", "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme=light] {
  color-scheme: light;
  --bg: #f8f7fb;
  --sidebar: #f0eef5;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #f3f1f7;
  --surface-hover: #eae7f0;
  --inset: #f6f4f9;
  --border: rgba(25, 20, 38, 0.085);
  --border-strong: rgba(25, 20, 38, 0.14);
  --text: #211e29;
  --text-soft: #5c5669;
  --text-muted: #7b7488;
  --text-faint: #a19aa9;
  --accent: #7452d5;
  --accent-bright: #6544c4;
  --accent-soft: rgba(116, 82, 213, 0.09);
  --accent-border: rgba(116, 82, 213, 0.22);
  --success: #288b63;
  --danger: #c6485b;
  --danger-soft: rgba(198, 72, 91, 0.08);
  --shadow: 0 22px 70px rgba(37, 27, 57, 0.14);
}

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

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  /* The app draws its own buttons; without this every new one silently
     inherits the user agent's grey ButtonFace. */
  border: 0;
  background: transparent;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

a {
  color: inherit;
}

::selection {
  color: #fff;
  background: rgba(137, 99, 225, 0.7);
}

/* The browser's own find-in-page (⌘/Ctrl + F) is the only search over a
   transcript, so its highlights must not be mistaken for the app's purple
   selection: every match is yellow, and the match the browser is sitting on is
   amber. Both pair a dark ink with a bright ground, so they read the same in
   either theme. Browsers without `::search-text` keep their own defaults. */
::search-text {
  color: #1c1400;
  background: #ffe14d;
}

::search-text:current {
  color: #1c1400;
  background: #ff9e2c;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 40%, transparent);
  background-clip: padding-box;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

.ui-icon {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.moon-mark {
  display: inline-flex;
  width: 32px;
  height: 32px;
  flex: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  color: var(--accent-bright);
  background: var(--accent-soft);
}

.moon-mark svg {
  width: 25px;
  height: 25px;
  overflow: visible;
  fill: currentColor;
}

.moon-mark .moon-star {
  fill: var(--text);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0;
  color: var(--accent-bright);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.primary-button {
  display: inline-flex;
  min-height: 43px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border-radius: 10px;
  color: #fff;
  background: var(--accent);
  font-weight: 650;
  transition: background var(--ease), transform var(--ease);
}

.primary-button:hover {
  background: var(--accent-bright);
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.icon-button {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-muted);
  background: transparent;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}

.icon-button:hover:not(:disabled) {
  border-color: var(--border);
  color: var(--text);
  background: var(--surface-soft);
}

.icon-button:disabled {
  color: var(--text-faint);
  opacity: 0.45;
  cursor: not-allowed;
}

/* Access gate */
.gate-page {
  position: relative;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  padding: 28px;
  background: radial-gradient(circle at 50% -20%, rgba(138, 103, 226, 0.14), transparent 45%), var(--bg);
}

.gate-page::before {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 48px 48px;
  content: "";
  mask-image: radial-gradient(circle at center, #000 10%, transparent 72%);
}

:root[data-theme=light] .gate-page::before {
  background-image: linear-gradient(rgba(20, 12, 40, 0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(20, 12, 40, 0.025) 1px, transparent 1px);
}

.gate-glow {
  position: absolute;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: rgba(128, 91, 219, 0.09);
  filter: blur(90px);
  pointer-events: none;
}

.gate-glow-one {
  top: -170px;
  left: 5%;
}

.gate-glow-two {
  right: 4%;
  bottom: -210px;
}

.gate-card {
  position: relative;
  z-index: 1;
  width: min(100%, 444px);
  padding: 30px 34px 26px;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.gate-brand {
  margin-bottom: 46px;
}

.gate-copy h1 {
  margin: 8px 0 8px;
  font-size: clamp(30px, 8vw, 38px);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.gate-copy > p:last-child {
  margin: 0;
  color: var(--text-muted);
}

.gate-form {
  margin-top: 30px;
}

.gate-form > label,
.setting-label {
  display: block;
  margin: 0 0 8px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
}

.gate-input-wrap {
  display: flex;
  height: 50px;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--inset);
  transition: border-color var(--ease), box-shadow var(--ease);
}

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

.gate-input-wrap.error {
  border-color: var(--danger);
}

.gate-input-wrap svg {
  width: 18px;
  fill: none;
  stroke: var(--text-muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.gate-input-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.gate-input-wrap input::placeholder {
  color: var(--text-faint);
}

.field-error {
  margin: 7px 2px 0;
  color: var(--danger);
  font-size: 12px;
}

.gate-submit {
  width: 100%;
  margin-top: 18px;
}

.gate-submit svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.gate-footnote {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 24px 0 0;
  color: var(--text-faint);
  font-size: 11px;
}

.status-dot,
.online-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 13%, transparent);
}

/* Main app shell */
.chat-app {
  display: flex;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.sidebar {
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}

.sidebar-top {
  display: flex;
  height: var(--header-height);
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 0 20px;
}

.mobile-close,
.menu-button,
.sidebar-scrim {
  display: none;
}

.new-chat-button {
  display: flex;
  min-height: 45px;
  align-items: center;
  gap: 10px;
  margin: 2px 14px 12px;
  padding: 0 12px;
  border: 1px solid var(--accent-border);
  border-radius: 11px;
  color: var(--text);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--ease), border-color var(--ease);
}

.new-chat-button:hover {
  border-color: color-mix(in srgb, var(--accent) 48%, transparent);
  background: color-mix(in srgb, var(--accent) 19%, transparent);
}

.new-chat-button kbd {
  margin-left: auto;
  color: var(--text-faint);
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
}

.search-box {
  display: flex;
  min-height: 39px;
  align-items: center;
  gap: 9px;
  margin: 0 14px 14px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text-faint);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}

.search-box:focus-within {
  border-color: var(--accent-border);
  color: var(--text-muted);
}

.search-box .ui-icon {
  width: 16px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 12px;
}

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

.conversation-nav {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.nav-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 8px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.nav-label span:last-child {
  font-size: 9px;
  letter-spacing: 0;
}

.conversation-list {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.conversation-row {
  position: relative;
  display: flex;
  min-height: 58px;
  align-items: stretch;
  margin: 2px 0;
  border-radius: 9px;
  overflow: hidden;
  transition: background var(--ease);
}

.conversation-row:hover,
.conversation-row:focus-within {
  background: var(--surface-hover);
}

.conversation-row.active {
  background: var(--surface-soft);
}

.conversation-row.active::before {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 2px;
  border-radius: 2px;
  background: var(--accent-bright);
  content: "";
}

.conversation-select {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 8px 66px 8px 10px;
  text-align: left;
  text-decoration: none;
  background: transparent;
}

.conversation-glyph {
  display: flex;
  width: 29px;
  height: 29px;
  flex: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  background: var(--surface);
}

.conversation-glyph .ui-icon {
  width: 14px;
  height: 14px;
}

.conversation-row.active .conversation-glyph {
  border-color: var(--accent-border);
  color: var(--accent-bright);
  background: var(--accent-soft);
}

.conversation-copy {
  display: block;
  min-width: 0;
}

.conversation-copy strong,
.conversation-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-copy strong {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
}

.conversation-copy small {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 10px;
}

.conversation-row.active .conversation-copy strong {
  color: var(--text);
}

.conversation-actions {
  position: absolute;
  top: 0;
  right: 5px;
  display: flex;
  height: 100%;
  align-items: center;
  gap: 1px;
  opacity: 0;
  transition: opacity var(--ease);
}

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

.conversation-actions button {
  display: flex;
  width: 27px;
  height: 27px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: var(--text-faint);
  background: var(--surface-soft);
}

.conversation-actions button:hover {
  color: var(--text);
  background: var(--surface-raised);
}

.conversation-actions .ui-icon {
  width: 13px;
  height: 13px;
}

.empty-search {
  display: grid;
  place-items: center;
  padding: 45px 20px;
  color: var(--text-faint);
  text-align: center;
}

.empty-search p {
  margin: 8px 0 0;
  font-size: 11px;
}

.sidebar-footer {
  padding: 12px 10px 14px;
  border-top: 1px solid var(--border);
}

.key-status {
  display: flex;
  min-height: 53px;
  align-items: center;
  gap: 9px;
  margin: 0 1px 8px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 65%, transparent);
}

.key-status-icon {
  display: flex;
  width: 30px;
  height: 30px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text-muted);
  background: var(--surface-soft);
}

.key-status-icon .ui-icon {
  width: 14px;
}

.key-status > span:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.key-status strong,
.key-status small {
  display: block;
}

.key-status strong {
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 650;
}

.key-status small {
  margin-top: 1px;
  overflow: hidden;
  color: var(--text-faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-status:not(.connected) .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.sidebar-action {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--text-muted);
  background: transparent;
  font-size: 11px;
  text-align: left;
}

.sidebar-action:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.sidebar-action .ui-icon {
  width: 15px;
  height: 15px;
}

.chat-main {
  display: flex;
  min-width: 0;
  height: 100%;
  flex: 1;
  flex-direction: column;
}

.chat-header {
  z-index: 10;
  display: flex;
  height: var(--header-height);
  flex: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.header-left,
.header-actions {
  display: flex;
  align-items: center;
}

.header-left {
  min-width: 0;
  gap: 11px;
}

.header-left > div {
  min-width: 0;
}

.header-left h1 {
  max-width: min(55vw, 620px);
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-left p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0 0;
  color: var(--text-faint);
  font-size: 10px;
}

.header-left .online-dot,
.model-pill .online-dot {
  width: 5px;
  height: 5px;
  box-shadow: none;
}

.header-actions {
  gap: 3px;
}

.conversation-stage {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Welcome */
.welcome {
  display: flex;
  width: min(100% - 40px, 760px);
  min-height: 100%;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  margin: 0 auto;
  padding: 54px 0 60px;
  text-align: center;
}

.welcome-mark {
  margin-bottom: 17px;
}

.welcome-mark .moon-mark {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  box-shadow: 0 12px 36px var(--accent-soft);
}

.welcome-mark .moon-mark svg {
  width: 40px;
  height: 40px;
}

.welcome h2 {
  margin: 8px 0 10px;
  font-size: clamp(27px, 4vw, 38px);
  line-height: 1.14;
  letter-spacing: -0.045em;
}

.welcome-subtitle {
  max-width: 520px;
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.connect-banner {
  display: flex;
  width: min(100%, 535px);
  min-height: 62px;
  align-items: center;
  gap: 12px;
  margin: 28px 0 5px;
  padding: 9px 13px;
  border: 1px solid var(--accent-border);
  border-radius: 13px;
  color: var(--text);
  background: var(--accent-soft);
  text-align: left;
  transition: border-color var(--ease), background var(--ease);
}

.connect-banner:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.connect-icon {
  display: flex;
  width: 37px;
  height: 37px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--accent-bright);
  background: color-mix(in srgb, var(--accent) 17%, var(--surface));
}

.connect-banner > span:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.connect-banner strong,
.connect-banner small {
  display: block;
}

.connect-banner strong {
  font-size: 12px;
}

.connect-banner small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
}

.connect-banner > .ui-icon {
  width: 15px;
  color: var(--text-muted);
}

.suggestion-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 30px;
}

.suggestion-card {
  position: relative;
  min-height: 105px;
  padding: 15px 40px 14px 16px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 68%, transparent);
  text-align: left;
  transition: border-color var(--ease), background var(--ease), transform var(--ease);
}

.suggestion-card:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  transform: translateY(-1px);
}

.suggestion-card > span {
  color: var(--accent-bright);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.suggestion-card p {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.45;
}

.suggestion-card > .ui-icon {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 14px;
  color: var(--text-faint);
  transition: color var(--ease), transform var(--ease);
}

.suggestion-card:hover > .ui-icon {
  color: var(--accent-bright);
  transform: translateX(2px);
}

/* Messages */
.message-list {
  width: min(100% - 42px, var(--content-width));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 13px;
  padding: 20px 0;
}

.message + .message {
  border-top: 1px solid var(--border);
}

.message-avatar {
  display: flex;
  width: 31px;
  height: 31px;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
}

.user-avatar {
  border: 1px solid var(--border-strong);
  color: var(--text-soft);
  background: var(--surface-soft);
}

.assistant-avatar .moon-mark {
  width: 31px;
  height: 31px;
  border-radius: 9px;
}

.assistant-avatar .moon-mark svg {
  width: 24px;
  height: 24px;
}

.message-column {
  min-width: 0;
}

.message-meta {
  display: flex;
  min-height: 24px;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}

.message-meta strong {
  font-size: 12px;
  font-weight: 650;
}

.message-meta span {
  padding: 1px 5px;
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  color: var(--accent-bright);
  background: var(--accent-soft);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.user-bubble {
  width: fit-content;
  max-width: min(100%, 680px);
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 4px 13px 13px 13px;
  color: var(--text-soft);
  background: var(--surface-soft);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.message-tools {
  display: flex;
  min-height: 27px;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity var(--ease);
}

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

.message-tools button {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  gap: 5px;
  padding: 0 7px;
  border-radius: 7px;
  color: var(--text-faint);
  background: transparent;
  font-size: 9px;
}

.message-tools button:hover {
  color: var(--text-soft);
  background: var(--surface-soft);
}

.message-tools .ui-icon {
  width: 13px;
  height: 13px;
}

.continuation-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 11px 12px;
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  background: var(--accent-soft);
}

.continuation-notice > div {
  display: grid;
  gap: 2px;
}

.continuation-notice strong {
  color: var(--text);
  font-size: 11px;
}

.continuation-notice span {
  color: var(--text-soft);
  font-size: 10px;
  line-height: 1.45;
}

.continuation-notice button {
  flex: none;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--accent-border);
  border-radius: 7px;
  color: var(--accent-bright);
  background: var(--surface-raised);
  font-size: 10px;
  font-weight: 650;
}

.continuation-notice button:hover {
  border-color: var(--accent);
}

.reasoning-panel {
  margin: 5px 0 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 48%, transparent);
}

.reasoning-panel summary {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  list-style: none;
}

.reasoning-panel summary::-webkit-details-marker {
  display: none;
}

.reasoning-panel summary > .ui-icon:first-child {
  width: 14px;
  color: var(--accent-bright);
}

.reasoning-panel summary > .ui-icon:last-child {
  width: 13px;
  margin-left: auto;
  transition: transform var(--ease);
}

.reasoning-panel[open] summary > .ui-icon:last-child {
  transform: rotate(90deg);
}

.reasoning-content {
  max-height: 320px;
  overflow-y: auto;
  padding: 0 12px 12px 31px;
  color: var(--text-muted);
  font-size: 11px;
}

.reasoning-content .markdown-body {
  font-size: inherit;
  line-height: 1.65;
}

.thinking-indicator {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 4px;
}

.thinking-indicator span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-bright);
  animation: thinking 1.2s infinite ease-in-out;
}

.thinking-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes thinking {
  0%, 60%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}
/* Markdown */
.markdown-body {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

/* Live replies stay cheap: one pre-wrapped text node until the final Markdown
   tree is ready. This also preserves line breaks while a code fence streams. */
.streaming-text {
  white-space: pre-wrap;
}

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

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

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.45em 0 0.55em;
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.markdown-body h1 {
  font-size: 1.55em;
}

.markdown-body h2 {
  font-size: 1.35em;
}

.markdown-body h3 {
  font-size: 1.16em;
}

.markdown-body h4 {
  font-size: 1.04em;
}

.markdown-body p {
  margin: 0.78em 0;
}

.markdown-body strong {
  color: var(--text);
  font-weight: 650;
}

.markdown-body em {
  color: var(--text-soft);
}

.markdown-body del {
  color: var(--text-muted);
}

.markdown-body a {
  color: var(--accent-bright);
  text-decoration: underline;
  text-decoration-color: var(--accent-border);
  text-underline-offset: 3px;
}

.markdown-body a:hover {
  text-decoration-color: currentColor;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.8em 0;
  padding-left: 1.45em;
}

.markdown-body li {
  margin: 0.32em 0;
  padding-left: 0.2em;
}

.custom-ordered-list {
  padding: 0 !important;
  list-style: none;
}

.custom-ordered-list li {
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  padding: 0;
}

.ordered-marker {
  color: var(--accent-bright);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.markdown-body blockquote {
  margin: 1em 0;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
}

.markdown-body hr {
  height: 1px;
  margin: 1.5em 0;
  border: 0;
  background: var(--border);
}

.inline-code {
  padding: 0.15em 0.38em;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: color-mix(in srgb, var(--accent-bright) 72%, var(--text));
  background: var(--surface-soft);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
}

.code-block {
  margin: 1em 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: #0b0b10;
}

:root[data-theme=light] .code-block {
  background: #201d28;
}

.code-head {
  display: flex;
  height: 34px;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #8f8a99;
  background: #121219;
  font-size: 9px;
  text-transform: lowercase;
}

.code-copy {
  padding: 4px 7px;
  border-radius: 5px;
  color: #9e98a8;
  background: transparent;
  font-size: 9px;
}

.code-copy:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.code-block pre {
  margin: 0;
  overflow-x: auto;
  padding: 14px 15px;
}

.code-block code {
  color: #ded9e8;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.65;
  white-space: pre;
}

/* Composer */
.composer-region {
  position: relative;
  z-index: 12;
  width: 100%;
  flex: none;
  padding: 8px 24px 14px;
  background: linear-gradient(to bottom, transparent, var(--bg) 18%);
}

.composer-shell,
.error-banner,
.composer-note {
  width: min(100%, var(--content-width) + 20px);
  margin-inline: auto;
}

.composer-shell {
  position: relative;
  padding: 12px 12px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 17px;
  background: var(--surface-raised);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.16);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.composer-shell:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 12px 38px rgba(0, 0, 0, 0.18);
}

.composer-shell textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  /* Two lines by default, growing (via JS) up to eight before scrolling. */
  min-height: 54px;
  max-height: 178px;
  resize: none;
  overflow-y: auto;
  padding: 4px 5px 8px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 13px;
  line-height: 1.6;
}

.composer-shell textarea::placeholder {
  color: var(--text-faint);
}

.composer-shell textarea:disabled {
  opacity: 0.65;
}

.composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.model-pill {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  background: var(--surface-soft);
  font-size: 9px;
  font-weight: 600;
}

.model-pill small {
  padding-left: 6px;
  border-left: 1px solid var(--border-strong);
  color: var(--accent-bright);
  font-size: 8px;
  text-transform: uppercase;
}

/* Thinking effort: a two-option segmented switch, in the composer and Settings. */
.effort-switch {
  display: inline-flex;
  align-items: center;
  /* DeepSeek offers five thinking modes, so the row wraps rather than pushing
     the send button off a narrow composer. */
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  border-radius: 7px;
  background: var(--inset);
}

.model-pill .effort-switch {
  margin-left: 2px;
}

.effort-option {
  padding: 3px 7px;
  border-radius: 5px;
  color: var(--text-faint);
  background: transparent;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color var(--ease), background var(--ease);
}

.effort-option:hover {
  color: var(--text-soft);
}

.effort-option.selected {
  color: var(--accent-bright);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.model-setting .effort-switch {
  flex: none;
}

.model-setting .effort-option {
  padding: 5px 11px;
  font-size: 10px;
}

.send-button {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: #fff;
  background: var(--accent);
  transition: opacity var(--ease), background var(--ease), transform var(--ease);
}

.send-button:hover:not(:disabled) {
  background: var(--accent-bright);
  transform: translateY(-1px);
}

.send-button:disabled {
  color: var(--text-faint);
  background: var(--surface-soft);
  opacity: 0.72;
}

.send-button.stop {
  color: var(--text);
  background: var(--surface-hover);
}

.send-button .ui-icon {
  width: 16px;
  height: 16px;
}

/* Model picker: a bare select that reads as part of the composer pill. */
.model-select {
  max-width: 168px;
  padding: 0;
  border: 0;
  outline: 0;
  color: inherit;
  background: transparent;
  font-size: 9px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.model-select:focus-visible {
  border-radius: 4px;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.model-select option {
  color: var(--text);
  background: var(--surface);
}

/* The send button and, when enabled, the named follow-up process button. */
.composer-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.autocritique-button {
  display: inline-flex;
  height: 34px;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  color: var(--accent-bright);
  background: var(--accent-soft);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 180px;
  transition: color var(--ease), background var(--ease), border-color var(--ease), opacity var(--ease), transform var(--ease);
}

.autocritique-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
  transform: translateY(-1px);
}

.autocritique-button:disabled {
  border-color: var(--border);
  color: var(--text-faint);
  background: var(--surface-soft);
  opacity: 0.72;
}

.autocritique-button .ui-icon {
  flex: none;
  width: 14px;
  height: 14px;
}

.autocritique-button span {
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 560px) {
  /* Keep the composer on one row on narrow screens: the icon still says it. */
  .autocritique-button span {
    display: none;
  }
  .autocritique-button {
    width: 34px;
    justify-content: center;
    padding: 0;
  }
  .model-select {
    max-width: 104px;
  }
}
.composer-note {
  margin-top: 7px;
  color: var(--text-faint);
  font-size: 9px;
  text-align: center;
}

.error-banner {
  display: flex;
  min-height: 39px;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  padding: 7px 8px 7px 11px;
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  border-radius: 10px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  font-size: 10px;
}

.error-banner > span {
  flex: 1;
}

.error-banner .ui-icon {
  width: 15px;
}

.error-banner button {
  display: flex;
  width: 25px;
  height: 25px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: inherit;
  background: transparent;
}

.error-banner button:hover {
  background: var(--danger-soft);
}

/* Settings */
.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 3, 8, 0.68);
  animation: fade-in 130ms ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.settings-modal {
  display: flex;
  width: min(100%, 590px);
  max-height: min(760px, 100dvh - 48px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: modal-in 170ms ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.modal-header {
  display: flex;
  min-height: 80px;
  flex: none;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 15px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 4px 0 0;
  font-size: 20px;
  letter-spacing: -0.03em;
}

.settings-scroll {
  overflow-y: auto;
  padding: 3px 24px;
}

.settings-section {
  padding: 23px 0;
}

.settings-section + .settings-section {
  border-top: 1px solid var(--border);
}

.settings-section-head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 19px;
}

.settings-section-icon {
  display: flex;
  width: 32px;
  height: 32px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: var(--accent-bright);
  background: var(--accent-soft);
}

.settings-section-icon .ui-icon {
  width: 15px;
  height: 15px;
}

.settings-section-head h3,
.settings-section-head p {
  margin: 0;
}

.settings-section-head h3 {
  font-size: 13px;
  font-weight: 650;
}

.settings-section-head p {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10px;
}

.api-key-input {
  display: flex;
  height: 43px;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--inset);
}

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

.api-key-input input {
  min-width: 0;
  height: 100%;
  flex: 1;
  padding: 0 12px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

.api-key-input button {
  display: flex;
  width: 40px;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
}

.api-key-input button:hover {
  color: var(--text);
}

.api-key-input .ui-icon {
  width: 16px;
}

.server-key-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 12px;
}

.server-key-actions .primary-button,
.server-key-actions .danger-button {
  min-height: 37px;
  font-size: 10px;
}

.server-key-status > span {
  flex: none;
}

/* A short caveat under a setting — shown when the setting is usable but not yet
   effective, such as an OpenRouter model chosen before its key is saved. */
.settings-note {
  margin-top: 11px;
  color: var(--text-faint);
  font-size: 10px;
  line-height: 1.5;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 13px;
  color: var(--text-soft);
  cursor: pointer;
}

.check-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.custom-check {
  display: flex;
  width: 17px;
  height: 17px;
  flex: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  color: transparent;
  background: var(--inset);
}

.check-row input:checked + .custom-check {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.custom-check .ui-icon {
  width: 12px;
  height: 12px;
  stroke-width: 2.5;
}

.check-row strong,
.check-row small {
  display: block;
}

.check-row strong {
  font-size: 10px;
  font-weight: 600;
}

.check-row small {
  margin-top: 1px;
  color: var(--text-faint);
  font-size: 9px;
}

.preserved-thinking-setting,
.autocritique-setting {
  margin: -3px 0 17px;
}

.preserved-thinking-setting small,
.autocritique-setting small {
  max-width: 420px;
  line-height: 1.45;
}

.external-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 15px;
  color: var(--accent-bright);
  font-size: 10px;
  text-decoration: none;
}

.external-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.external-link .ui-icon {
  width: 12px;
  height: 12px;
}

.model-setting {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 17px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
}

.model-setting strong,
.model-setting small {
  display: block;
}

.model-setting strong {
  font-size: 11px;
}

.model-setting small {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 9px;
}

.model-setting > span {
  padding: 3px 7px;
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  color: var(--accent-bright);
  background: var(--accent-soft);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
}

.openrouter-model-list {
  display: grid;
  gap: 7px;
  margin: 12px 0 14px;
}

.openrouter-model-row {
  gap: 8px;
  margin: 0;
  padding: 7px 8px;
}

.openrouter-model-choice {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 0;
  color: var(--text-soft);
  background: transparent;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  text-align: left;
}

.openrouter-model-choice:hover,
.openrouter-model-choice.selected {
  color: var(--accent-bright);
}

.openrouter-model-choice small {
  color: var(--text-faint);
  font-family: inherit;
  font-size: 8px;
}

.system-prompt {
  display: block;
  width: 100%;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  outline: 0;
  color: var(--text-soft);
  background: var(--inset);
  font-size: 10px;
  line-height: 1.55;
}

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

.prompt-picker {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 12px;
}

.prompt-select {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  outline: 0;
  color: var(--text-soft);
  background: var(--inset);
  font-size: 11px;
}

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

/* The model picker in Settings is a full-width select rather than one column of
   the prompt picker's row. */
#active-model {
  width: 100%;
  margin-bottom: 12px;
}

.prompt-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text-soft);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color var(--ease), color var(--ease), background var(--ease);
}

.prompt-action:hover:not(:disabled) {
  border-color: var(--accent-border);
  color: var(--text);
}

.prompt-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.prompt-action.danger:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}

.prompt-action .ui-icon {
  width: 13px;
  height: 13px;
}

.autocritique-steps {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.autocritique-step {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--inset) 72%, transparent);
}

.autocritique-step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.autocritique-step-head .setting-label {
  margin-top: 0;
}

.autocritique-step-actions {
  display: inline-flex;
  gap: 4px;
}

.prompt-action.compact {
  width: 28px;
  min-height: 26px;
  justify-content: center;
  padding: 0;
}

.setting-invalid {
  color: var(--danger);
}

.prompt-name-input {
  display: block;
  width: 100%;
  margin-bottom: 12px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  outline: 0;
  color: var(--text-soft);
  background: var(--inset);
  font-size: 11px;
}

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

.danger-section .settings-section-icon {
  color: var(--danger);
  background: var(--danger-soft);
}

.danger-button {
  display: inline-flex;
  min-height: 37px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid color-mix(in srgb, var(--danger) 24%, transparent);
  border-radius: 8px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 10px;
  font-weight: 600;
}

.danger-button:hover {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}

.danger-button .ui-icon {
  width: 14px;
  height: 14px;
}

.modal-footer {
  display: flex;
  min-height: 66px;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 20px 11px 24px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-soft) 42%, var(--surface));
}

.modal-footer p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--text-faint);
  font-size: 9px;
}

.modal-footer p .ui-icon {
  width: 14px;
  color: var(--success);
}

.modal-footer .primary-button {
  min-height: 36px;
  padding-inline: 16px;
  font-size: 10px;
}

/* ==========================================================================
   Display preferences
   --------------------------------------------------------------------------
   Every local preference is published onto `:root` as a `data-*` attribute by
   `prefs::Prefs::apply_to_document`, so changing one is a single attribute
   write rather than a re-render. Anything that varies with a preference must
   be expressed here, not in inline styles.
   ========================================================================== */
:root[data-text-size=small] {
  --type-scale: 0.92;
}

:root[data-text-size=medium] {
  --type-scale: 1;
}

:root[data-text-size=large] {
  --type-scale: 1.1;
}

:root[data-density=comfortable] {
  --message-gap: 20px;
}

:root[data-density=cozy] {
  --message-gap: 13px;
}

:root[data-density=compact] {
  --message-gap: 7px;
}

:root[data-content-width=narrow] {
  --content-width: 680px;
}

:root[data-content-width=regular] {
  --content-width: 860px;
}

:root[data-content-width=wide] {
  --content-width: 1080px;
}

:root[data-content-width=full] {
  --content-width: 100%;
}

.markdown-body,
.user-bubble,
.reasoning-content {
  font-size: calc(13px * var(--type-scale, 1));
}

.message {
  padding: calc(var(--message-gap, 20px)) 0;
}

/* Code blocks follow the wrap and line-number preferences. */
:root[data-code-wrap=on] .code-block code {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

:root[data-code-wrap=on] .code-block pre {
  overflow-x: visible;
}

.code-line {
  display: inline;
}

:root[data-code-lines=on] .code-block pre {
  counter-reset: code-line;
}

:root[data-code-lines=on] .code-line {
  display: block;
  counter-increment: code-line;
}

:root[data-code-lines=on] .code-line::before {
  display: inline-block;
  width: 2.6em;
  margin-right: 1em;
  color: #57525f;
  content: counter(code-line);
  text-align: right;
  user-select: none;
}

.code-language {
  font-weight: 600;
}

.code-lines-label {
  margin-left: auto;
  margin-right: 10px;
  color: #6d6878;
  font-size: 9px;
}

/* ==========================================================================
   Markdown: tables and task lists
   ========================================================================== */
.table-scroll {
  margin: 1em 0;
  overflow-x: auto;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
}

.markdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94em;
}

.markdown-table th,
.markdown-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.markdown-table thead th {
  position: sticky;
  top: 0;
  color: var(--text);
  background: var(--surface-soft);
  font-weight: 650;
  white-space: nowrap;
}

.markdown-table tbody tr:last-child td {
  border-bottom: 0;
}

.markdown-table tbody tr:hover {
  background: var(--surface-hover);
}

.align-left {
  text-align: left;
}

.align-center {
  text-align: center;
}

.align-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.markdown-body .list-content {
  display: block;
}

.markdown-body ul.task-list {
  padding-left: 0.35em;
  list-style: none;
}

.task-check {
  width: 13px;
  height: 13px;
  margin: 0 7px 0 0;
  accent-color: var(--accent);
  vertical-align: -1px;
}

.markdown-body li > .list-content > ul,
.markdown-body li > .list-content > ol {
  margin: 0.35em 0 0.1em;
}

/* ==========================================================================
   Header controls, menus, and the find bar
   ========================================================================== */
.collapse-button {
  display: none;
}

@media (min-width: 801px) {
  .collapse-button {
    display: inline-flex;
  }
  .chat-app.sidebar-collapsed .sidebar {
    display: none;
  }
}
.menu-anchor {
  position: relative;
  display: inline-flex;
}

.menu-anchor .icon-button {
  width: auto;
  gap: 1px;
  padding: 0 5px;
}

.menu-anchor .icon-button .ui-icon:last-child {
  width: 13px;
  height: 13px;
  opacity: 0.7;
}

.menu-scrim {
  position: fixed;
  z-index: 40;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
}

.menu-popover {
  position: absolute;
  z-index: 41;
  top: calc(100% + 7px);
  right: 0;
  width: 262px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  animation: modal-in 130ms ease-out;
}

.menu-heading {
  margin: 5px 8px 4px;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  text-align: left;
}

.menu-item:hover {
  background: var(--surface-hover);
}

.menu-item strong {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
}

.menu-item small {
  display: block;
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 9.5px;
}

.menu-divider {
  height: 1px;
  margin: 5px 8px;
  background: var(--border);
}

/* ==========================================================================
   Jump to latest, toasts
   ========================================================================== */
.jump-to-latest {
  position: absolute;
  bottom: 128px;
  left: 50%;
  z-index: 13;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 550;
  transform: translateX(-50%);
  animation: modal-in 140ms ease-out;
}

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

.jump-to-latest.streaming {
  border-color: var(--accent-border);
  color: var(--accent-bright);
}

.jump-to-latest .ui-icon {
  width: 15px;
  height: 15px;
}

.chat-main {
  position: relative;
}

.toast-rack {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 60;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 7px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 8px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  font-size: 11.5px;
  pointer-events: auto;
  animation: modal-in 150ms ease-out;
}

/* ==========================================================================
   Inline editing and renaming
   ========================================================================== */
.message-editor {
  margin-top: 4px;
}

.message-editor-input {
  display: block;
  width: 100%;
  min-height: 76px;
  padding: 11px 13px;
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  color: var(--text);
  background: var(--inset);
  font-family: inherit;
  font-size: calc(13px * var(--type-scale, 1));
  line-height: 1.6;
  resize: none;
}

.message-editor-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 9px;
}

.message-editor-hint {
  margin-right: auto;
  color: var(--text-faint);
  font-size: 10px;
}

.message-editor-actions .primary-button {
  padding: 7px 13px;
  font-size: 11px;
}

.ghost-button {
  padding: 7px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text-soft);
  background: transparent;
  font-size: 11px;
  font-weight: 550;
}

.ghost-button:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.conversation-rename {
  flex: 1;
  padding: 9px 10px;
}

.conversation-rename input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--accent-border);
  border-radius: 7px;
  color: var(--text);
  background: var(--inset);
  font-size: 11.5px;
  font-weight: 600;
}

.search-clear {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: var(--text-faint);
}

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

.search-clear .ui-icon {
  width: 13px;
  height: 13px;
}

.conversation-row.generating .conversation-glyph {
  color: var(--accent-bright);
  animation: pulse-glyph 1.4s ease-in-out infinite;
}

@keyframes pulse-glyph {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}
/* The key status is a button now, so it needs the row layout back. */
.key-status {
  width: 100%;
  text-align: left;
}

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

/* ==========================================================================
   Message metadata
   ========================================================================== */
.message-time,
.message-stats,
.draft-meter {
  color: var(--text-faint);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
}

.message-stats {
  margin-left: auto;
  padding-right: 2px;
}

.draft-meter {
  margin-right: 6px;
  white-space: nowrap;
}

.message-tools button.copied {
  color: var(--success);
}

/* ==========================================================================
   Tabbed settings
   ========================================================================== */
.settings-modal {
  width: min(100%, 780px);
}

.settings-body {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: 186px minmax(0, 1fr);
}

.settings-tabs {
  display: flex;
  overflow-y: auto;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
  border-right: 1px solid var(--border);
  background: var(--inset);
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 550;
  text-align: left;
}

.settings-tab:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.settings-tab.selected {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.settings-tab .ui-icon {
  width: 15px;
  height: 15px;
  flex: none;
  opacity: 0.85;
}

.settings-tab.selected .ui-icon {
  color: var(--accent-bright);
  opacity: 1;
}

.settings-summary {
  margin: 18px 0 0;
  color: var(--text-muted);
  font-size: 10.5px;
}

.settings-scroll .settings-section:first-of-type {
  padding-top: 16px;
}

.setting-note {
  margin: 4px 0 0;
  color: var(--text-faint);
  font-size: 9.5px;
  line-height: 1.55;
}

/* A setting whose control is too wide to sit beside its label. */
.model-setting.stacked {
  align-items: flex-start;
  flex-direction: column;
  gap: 9px;
}

.model-setting.stacked .effort-switch {
  width: 100%;
  flex-wrap: wrap;
}

.settings-section .check-row + .check-row {
  margin-top: 11px;
}

.system-prompt.tall {
  min-height: 200px;
}

/* ==========================================================================
   Shortcuts dialog
   ========================================================================== */
.shortcuts-modal {
  display: flex;
  width: min(100%, 520px);
  max-height: min(700px, 100dvh - 48px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: modal-in 170ms ease-out;
}

.shortcuts-body {
  overflow-y: auto;
  padding: 6px 24px 18px;
}

.shortcut-group {
  padding: 14px 0;
}

.shortcut-group + .shortcut-group {
  border-top: 1px solid var(--border);
}

.shortcut-group h3 {
  margin: 0 0 9px;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 0;
  font-size: 11.5px;
}

.shortcut-row kbd,
.sidebar-action kbd {
  flex: none;
  padding: 3px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-soft);
  background: var(--inset);
  font-family: inherit;
  font-size: 9.5px;
  white-space: nowrap;
}

.sidebar-action kbd {
  margin-left: auto;
}

/* ==========================================================================
   Responsive: the settings tabs become a scrolling strip on narrow screens
   ========================================================================== */
@media (max-width: 700px) {
  .settings-body {
    display: flex;
    flex-direction: column;
  }
  .settings-tabs {
    flex-direction: row;
    overflow-x: auto;
    padding: 9px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .settings-tab {
    flex: none;
    white-space: nowrap;
  }
  .settings-tab span {
    display: none;
  }
  .settings-tab.selected span {
    display: inline;
  }
  .menu-popover {
    width: 232px;
  }
  .jump-to-latest {
    bottom: 118px;
  }
}
@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(var(--sidebar-width), 100vw - 44px);
    transform: translateX(-102%);
    transition: transform 220ms ease;
  }
  .chat-app.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .sidebar-scrim {
    position: fixed;
    z-index: 29;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.52);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
  }
  .chat-app.sidebar-open .sidebar-scrim {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
  .mobile-close,
  .menu-button {
    display: inline-flex;
  }
  .chat-header {
    padding: 0 12px;
  }
  .header-left h1 {
    max-width: 55vw;
  }
  .message-list {
    width: min(100% - 26px, var(--content-width));
  }
  .composer-region {
    padding-inline: 12px;
  }
  .welcome {
    width: min(100% - 28px, 680px);
  }
}
@media (max-width: 560px) {
  :root {
    --header-height: 66px;
  }
  .header-actions .icon-button:first-child {
    display: none;
  }
  .welcome {
    justify-content: flex-start;
    padding-top: 48px;
  }
  .welcome h2 {
    font-size: 28px;
  }
  .suggestion-grid {
    grid-template-columns: 1fr;
    gap: 7px;
    margin-top: 24px;
  }
  .suggestion-card {
    min-height: 78px;
    padding-block: 12px;
  }
  .connect-banner {
    margin-top: 22px;
  }
  .message-list {
    width: calc(100% - 22px);
    padding-top: 20px;
  }
  .message {
    grid-template-columns: 29px minmax(0, 1fr);
    gap: 10px;
    padding: 17px 0;
  }
  .message-avatar,
  .assistant-avatar .moon-mark {
    width: 28px;
    height: 28px;
  }
  .message-tools {
    opacity: 1;
  }
  .composer-region {
    padding-bottom: max(9px, env(safe-area-inset-bottom));
  }
  .composer-note {
    display: none;
  }
  .modal-backdrop {
    align-items: end;
    padding: 0;
  }
  .settings-modal {
    width: 100%;
    max-height: 92dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }
  .settings-scroll {
    padding-inline: 18px;
  }
  .modal-footer {
    padding-inline: 18px;
  }
  .modal-footer p {
    max-width: 230px;
  }
  .gate-page {
    padding: 18px;
  }
  .gate-card {
    padding: 25px 22px 22px;
  }
  .gate-brand {
    margin-bottom: 40px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
