/* Chat, Code and sign-in pages. Colour tokens and base styles come from /style.css. */

:root {
  --bad: #B8432F;
  --sidebar: #ECE7DC;
  --hover: rgba(24, 23, 20, 0.06);
  --field: #FBF9F4;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 24px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bad: #E0694F;
    --sidebar: #121210;
    --hover: rgba(242, 238, 230, 0.07);
    --field: #1F1F1C;
  }
}
:root[data-theme="dark"] {
  --bad: #E0694F;
  --sidebar: #121210;
  --hover: rgba(242, 238, 230, 0.07);
  --field: #1F1F1C;
}
[hidden] { display: none !important; }

body.app { height: 100dvh; overflow: hidden; }
.shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); height: 100%; }

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex; flex-direction: column;
  padding: 16px 12px;
  min-height: 0;
  background: var(--sidebar);
}
.sidebar .brand { padding: 8px 10px 20px; font-size: 20px; }

.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px;
  background: none; border: 0; border-radius: var(--r-sm);
  font: inherit; font-size: 15px; color: var(--text); text-decoration: none; text-align: left; cursor: pointer;
}
.side-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); flex-shrink: 0; }
.side-item:hover { background: var(--hover); }
.side-item[aria-current="page"] { background: var(--hover); }
.side-item[aria-current="page"] svg { color: var(--accent); }

.side-label { margin: 28px 10px 8px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.history { flex: 1; overflow-y: auto; }
.history li { position: relative; border-radius: var(--r-sm); }
.history li:hover, .history li.is-current { background: var(--hover); }
.history-open {
  display: block; width: 100%; padding: 8px 36px 8px 10px;
  background: none; border: 0;
  font: inherit; font-size: 14px; color: var(--text); text-align: left; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-delete {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 28px; height: 28px;
  background: none; border: 0; border-radius: 6px; color: var(--muted); cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
.history-delete svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.history li:hover .history-delete, .history-delete:focus-visible { opacity: 1; }
.history-delete:hover { color: var(--accent); background: var(--hover); }
@media (hover: none) { .history-delete { opacity: .6; } }
.history-empty { padding: 8px 10px; font-size: 14px; color: var(--muted); }

.account { position: relative; padding: 12px 0 0; margin-top: 8px; border-top: 1px solid var(--line); }
.account-note { font-size: 13.5px; color: var(--muted); margin: 4px 6px 12px; line-height: 1.45; }
.account-actions { display: flex; gap: 8px; padding: 0 4px; }
.account-actions .pill-btn { flex: 1; }
.account-links { display: flex; gap: 14px; padding: 14px 6px 2px; }
.account-links a, .menu-links a { font-size: 12.5px; color: var(--muted); text-decoration: none; }
.account-links a:hover, .menu-links a:hover { color: var(--text); }

.account-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; background: none; border: 0; border-radius: var(--r-sm);
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
}
.account-row:hover, .account-row[aria-expanded="true"] { background: var(--hover); }
.avatar {
  display: grid; place-items: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
}
.account-name { flex: 1; min-width: 0; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chevron { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.account-row[aria-expanded="true"] .account-chevron { transform: rotate(180deg); }

.account-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 30;
  padding: 6px;
  background: var(--field); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 40px -8px rgba(0, 0, 0, .22);
  animation: pop .14s var(--ease);
}
.menu-switch { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.menu-switch:hover { background: var(--hover); }
.menu-switch > span { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.menu-switch strong { font-size: 14px; font-weight: 500; }
.menu-switch small { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.menu-switch input {
  appearance: none; flex-shrink: 0; position: relative;
  width: 36px; height: 20px; margin: 0; border-radius: 999px;
  background: var(--line); cursor: pointer; transition: background .2s;
}
.menu-switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s var(--ease);
}
.menu-switch input:checked { background: var(--accent); }
.menu-switch input:checked::after { transform: translateX(16px); }
.menu-switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.menu-links { display: flex; gap: 14px; padding: 10px 12px; margin: 4px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.menu-item {
  display: block; width: 100%; padding: 9px 12px;
  background: none; border: 0; border-radius: 10px;
  font: inherit; font-size: 14px; color: var(--text); text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--hover); }
.menu-item.is-danger { color: var(--bad, #B8432F); }

/* Delete-account dialog */
.dialog {
  width: min(420px, calc(100vw - 32px)); padding: 0;
  background: var(--field); color: var(--text);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .35);
}
.dialog::backdrop { background: rgba(0, 0, 0, .35); }
.dialog-body { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.dialog h2 { font-family: var(--serif); font-weight: 400; font-size: 24px; }
.dialog p { color: var(--muted); font-size: 15px; }
.dialog .dialog-error { color: var(--bad, #B8432F); font-size: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.pill-btn.is-danger { background: var(--bad, #B8432F); border-color: var(--bad, #B8432F); color: #fff; }
.pill-btn.is-danger:hover { background: #9c3726; }

/* ---------- Buttons ---------- */
.pill-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 14px;
  background: none; border: 1px solid var(--line); border-radius: 999px;
  font: inherit; font-size: 14px; color: var(--text); text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.pill-btn:hover:not(:disabled) { background: var(--hover); }
.pill-btn.is-solid { background: var(--text); color: var(--bg); border-color: var(--text); }
.pill-btn.is-solid:hover { background: var(--accent); border-color: var(--accent); }
.pill-btn:disabled { opacity: .4; cursor: default; }

.link-btn {
  padding: 0; background: none; border: 0;
  font: inherit; font-size: 13px; color: var(--muted); cursor: pointer;
}
.link-btn:hover:not(:disabled) { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.icon-btn { display: none; place-items: center; width: 40px; height: 40px; margin-left: -8px; background: none; border: 0; color: var(--text); cursor: pointer; border-radius: var(--r-sm); }
.icon-btn:hover { background: var(--hover); }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.bar { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px; flex-shrink: 0; }
.bar-title { flex: 1; min-width: 0; font-family: var(--sans); letter-spacing: 0; line-height: 1.4; font-size: 15px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
body[data-product="code"] .workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }

/* ---------- Conversation ---------- */
.conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.scroller { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.thread, .empty, .composer, .starters, .composer-note { width: 100%; max-width: 780px; margin-left: auto; margin-right: auto; padding-left: 28px; padding-right: 28px; }

/* Empty: greeting and composer sit together in the middle of the screen. */
.empty { display: none; }
.conversation.is-empty { justify-content: center; padding-bottom: 8vh; }
.conversation.is-empty .scroller { flex: 0 0 auto; overflow: visible; }
.conversation.is-empty .empty { display: block; padding-bottom: 28px; text-align: center; }
.conversation.is-empty .thread, .conversation.is-empty .composer-note { display: none; }
.conversation:not(.is-empty) .starters { display: none; }
.empty h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(30px, 4vw, 42px); letter-spacing: -.015em; line-height: 1.15; }

.starters { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.starters button {
  padding: 8px 16px;
  background: none; border: 1px solid var(--line); border-radius: 999px;
  font: inherit; font-size: 14px; color: var(--muted); cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.starters button:hover { color: var(--text); background: var(--hover); }

.thread { display: flex; flex-direction: column; gap: 40px; padding-top: 24px; padding-bottom: 40px; }
.msg.user { align-self: flex-end; max-width: 80%; }
.bubble { padding: 12px 18px; background: var(--surface); border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }

.md { overflow-wrap: anywhere; line-height: 1.7; }
.md > * + * { margin-top: 16px; }
.md h2, .md h3, .md h4 { font-family: var(--serif); font-weight: 400; line-height: 1.25; }
.md h2 { font-size: 24px; margin-top: 32px; }
.md h3 { font-size: 20px; margin-top: 28px; }
.md h4 { font-size: 17px; margin-top: 24px; }
.md ul { list-style: disc; padding-left: 24px; }
.md ol { list-style: decimal; padding-left: 24px; }
.md li + li { margin-top: 6px; }
.md li::marker { color: var(--muted); }
.md a { color: var(--accent); text-underline-offset: 3px; }
.md strong { font-weight: 600; }
.md blockquote { padding-left: 16px; border-left: 2px solid var(--line); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.md :not(pre) > code { padding: 2px 6px; background: var(--surface); border-radius: 5px; font-family: var(--mono); font-size: .86em; }

.codeblock { border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.codeblock-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line); }
.codeblock pre { padding: 16px; overflow-x: auto; font: 13.5px/1.65 var(--mono); }

.file-chip {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  padding: 14px 16px; background: var(--surface); border: 1px solid transparent; border-radius: var(--r-md);
  font: inherit; font-size: 13px; color: var(--muted); text-align: left; cursor: pointer;
  transition: border-color .15s;
}
.file-chip .mono { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip > span:last-child { flex-shrink: 0; white-space: nowrap; }
.file-chip:hover { border-color: var(--line); }
.md > .file-chip + .file-chip { margin-top: 8px; }

/* Work line: "Thinking · 4s" while streaming, "Worked for 12s" after. Expands to reasoning. */
.work { margin-bottom: 14px; }
.work summary {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px; margin-left: -4px;
  list-style: none; border-radius: 999px;
  font-size: 14px; color: var(--muted); cursor: default; user-select: none;
}
.work summary::-webkit-details-marker { display: none; }
.work.has-reasoning summary { cursor: pointer; }
.work.has-reasoning summary:hover { color: var(--text); background: var(--hover); }
.work-icon { display: inline-flex; }
.work-chevron { display: none; width: 7px; height: 7px; margin-left: 2px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .2s; }
.work.has-reasoning .work-chevron { display: inline-block; }
.work[open] .work-chevron { transform: rotate(45deg); }
.work-label { font-variant-numeric: tabular-nums; }
.work[data-state="thinking"] .work-label {
  background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 40%, var(--text) 50%, var(--muted) 60%, var(--muted) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 2.2s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
.reasoning-body { margin: 10px 0 4px 12px; padding-left: 18px; border-left: 2px solid var(--line); max-height: 360px; overflow-y: auto; white-space: pre-wrap; font-size: 14.5px; line-height: 1.6; color: var(--muted); }

.think { width: 22px; height: 22px; overflow: visible; }
.think-lines { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; opacity: .35; }
.think-dot { fill: var(--text); }
.think-end { fill: var(--accent); transform-origin: 24.5px 16px; animation: land 1.5s ease-in-out infinite; }
.think.is-done .think-lines { opacity: .9; stroke: var(--text); }
.think.is-done .think-end { animation: none; }
@keyframes land { 0%, 60% { transform: scale(.75); } 80% { transform: scale(1.15); } 100% { transform: scale(.75); } }

.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 14px; }
.action-btn { padding: 4px 8px; margin-left: -8px; background: none; border: 0; border-radius: 6px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; }
.action-btn:hover { background: var(--hover); color: var(--text); }
.action-btn.icon { display: grid; place-items: center; width: 30px; height: 28px; padding: 0; margin-left: 0; }
.action-btn.icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.action-btn.icon[aria-pressed="true"] { color: var(--accent); }
.action-btn.icon[aria-pressed="true"] svg { fill: color-mix(in srgb, var(--accent) 20%, transparent); }
.msg-actions .meta { margin-left: 6px; }
.meta { font-size: 13px; color: var(--muted); }
.msg-error { margin-top: 10px; font-size: 15px; color: var(--accent); }

/* ---------- Composer ---------- */
.composer { flex-shrink: 0; padding-top: 4px; }
.composer-box {
  padding: 14px 14px 10px 20px;
  background: var(--field);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px -12px rgba(0, 0, 0, .12);
  transition: border-color .2s;
}
.composer-box:focus-within { border-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.composer textarea {
  display: block; width: 100%; max-height: 240px; padding: 4px 0 8px;
  background: none; border: 0; outline: 0; resize: none;
  font: inherit; font-size: 16px; line-height: 1.5; color: var(--text);
}
.composer textarea::placeholder { color: var(--muted); opacity: .85; }
.composer-row { display: flex; align-items: center; gap: 8px; }

/* Model picker */
.picker { position: relative; }
.picker-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: none;
  border: 1px solid var(--line); border-radius: 999px;
  font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer;
  transition: background .15s;
}
.picker-btn:hover, .picker-btn[aria-expanded="true"] { background: var(--hover); }
.picker-btn svg { width: 12px; height: 12px; fill: none; stroke: var(--muted); stroke-width: 1.4; transition: transform .2s; }
.picker-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.picker-menu {
  position: absolute; left: -6px; bottom: calc(100% + 10px); z-index: 30;
  width: 300px; padding: 6px;
  background: var(--field); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 40px -8px rgba(0, 0, 0, .22), 0 2px 6px rgba(0, 0, 0, .06);
  outline: none;
  animation: pop .14s var(--ease);
}
.picker.drop-down .picker-menu { bottom: auto; top: calc(100% + 10px); }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.picker-menu li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.picker-menu li.is-active { background: var(--hover); }
.opt-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.opt-name { font-size: 14.5px; color: var(--text); }
.opt-note { font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.opt-check { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.picker-menu [aria-selected="true"] .opt-check { visibility: visible; }

.seg { display: flex; margin: 0; padding: 2px; border: 1px solid var(--line); border-radius: 999px; }
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.seg span, .seg button { display: block; padding: 4px 12px; font-size: 13.5px; color: var(--muted); border-radius: 999px; transition: background .15s, color .15s; }
.seg button { background: none; border: 0; font: inherit; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.seg input:checked + span, .seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.send {
  display: grid; place-items: center; flex-shrink: 0;
  width: 36px; height: 36px; margin-left: auto;
  background: var(--text); color: var(--bg); border: 0; border-radius: 50%; cursor: pointer;
  transition: background .2s, opacity .2s;
}
.send:hover:not(:disabled) { background: var(--accent); }
.send:disabled { opacity: .25; cursor: default; }
.send .i-stop, .send.is-stop .i-send { display: none; }
.send.is-stop .i-stop { display: block; }

.composer-note { padding-top: 10px; padding-bottom: 14px; text-align: center; font-size: 12.5px; color: var(--muted); }

/* ---------- Files (Code) ---------- */
.view-switch { display: none; }
.view-switch .badge { display: inline; padding: 0; }
.badge:not(:empty) { margin-left: 6px; color: var(--accent); }

.files {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  margin: 0 16px 16px 0;
  background: var(--surface); border-radius: var(--r-md); overflow: hidden;
}
.files-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 12px 20px; flex-shrink: 0; }
.files-head h2 { font-size: 15px; font-weight: 500; }
.files-head h2 span { color: var(--muted); font-weight: 400; margin-left: 4px; }
.files-empty { flex: 1; display: grid; place-items: center; padding: 24px; text-align: center; font-family: var(--serif); font-style: italic; color: var(--muted); }

.file-tabs { display: flex; gap: 4px; padding: 0 12px 10px; overflow-x: auto; flex-shrink: 0; border-bottom: 1px solid var(--line); }
.file-tabs:empty { display: none; }
.file-tabs button {
  padding: 6px 12px; background: none; border: 0; border-radius: var(--r-sm);
  font: 12.5px var(--mono); color: var(--muted); white-space: nowrap; cursor: pointer;
}
.file-tabs button:hover { color: var(--text); background: var(--hover); }
.file-tabs button[aria-pressed="true"] { color: var(--text); background: var(--bg); }

.file-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.file-view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; color: var(--muted); font-size: 12.5px; }
.file-view-head .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: flex; gap: 16px; flex-shrink: 0; }
.file-code { flex: 1; overflow: auto; padding: 4px 0 16px; font: 13px/1.7 var(--mono); counter-reset: ln; }
.file-code .ln { display: block; padding-right: 20px; white-space: pre; }
.file-code .ln::before {
  counter-increment: ln; content: counter(ln);
  display: inline-block; width: 3.4em; padding-right: 1.4em;
  text-align: right; color: var(--muted); opacity: .55; user-select: none;
}

/* ---------- Sign in ---------- */
body.auth-page { min-height: 100dvh; display: grid; place-items: center; padding: 40px 16px; }
.auth { width: 100%; max-width: 380px; text-align: center; }
.auth-mark .mark { width: 44px; height: 44px; }
.auth h1 { margin-top: 28px; font-family: var(--serif); font-weight: 400; font-size: 34px; letter-spacing: -.015em; line-height: 1.15; }
.auth-sub { margin-top: 10px; color: var(--muted); }
.auth-form { display: flex; flex-direction: column; gap: 16px; margin-top: 36px; text-align: left; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; font-weight: 500; }
.field input {
  padding: 12px 14px;
  background: var(--field); border: 1px solid var(--line); border-radius: var(--r-md);
  font: inherit; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: 0; border-color: var(--muted); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.field-hint { font-size: 13px; color: var(--muted); }
.auth-error { padding: 10px 14px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-size: 14px; }
.btn-primary {
  margin-top: 4px; padding: 13px;
  background: var(--text); color: var(--bg); border: 0; border-radius: 999px;
  font: inherit; font-weight: 500; cursor: pointer; transition: background .2s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.auth-switch { margin-top: 28px; font-size: 15px; color: var(--muted); }
.auth-switch a { color: var(--text); margin-left: 4px; text-underline-offset: 3px; }
.auth-foot { margin-top: 12px; font-size: 14px; }
.auth-foot a { color: var(--muted); text-underline-offset: 3px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  body[data-product="code"] .workspace { grid-template-columns: minmax(0, 1fr); }
  body[data-product="code"]:not(.show-files) .files { display: none; }
  body.show-files .conversation { display: none; }
  body.show-files .files { margin: 0 16px 16px; }
  .view-switch { display: flex; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20;
    width: min(300px, 85vw);
    transform: translateX(-100%); visibility: hidden;
    transition: transform .25s var(--ease), visibility .25s;
    box-shadow: 0 0 40px rgba(0, 0, 0, .2);
  }
  .sidebar.is-open { transform: none; visibility: visible; }
  .scrim { position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .3); }
  .icon-btn { display: grid; }
  .bar { padding: 0 16px; }
}

@media (max-width: 600px) {
  .thread, .empty, .composer, .starters, .composer-note { padding-left: 14px; padding-right: 14px; }
  .thread { gap: 32px; }
  .msg.user { max-width: 88%; }
  .composer-box { padding: 12px 10px 8px 16px; border-radius: 20px; }
  .seg span { padding: 4px 10px; }
  .conversation.is-empty { padding-bottom: 4vh; }
}
.auth-consent { font-size: 13px; line-height: 1.5; color: var(--muted); text-align: center; }
.auth-consent a { color: var(--text); text-underline-offset: 2px; }

/* ---------- Community ---------- */
.channels { flex: 1; overflow-y: auto; }
.channel {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: var(--r-sm); font-size: 14.5px; color: var(--muted); text-decoration: none;
}
.channel span { font-family: var(--mono); opacity: .7; }
.channel:hover { background: var(--hover); color: var(--text); }
.channel[aria-current="page"] { background: var(--hover); color: var(--text); }
.channel[aria-current="page"] span { color: var(--accent); opacity: 1; }

.elsewhere { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.elsewhere-card {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--hover); border-radius: var(--r-md); color: var(--text); text-decoration: none;
  transition: background .15s;
}
.elsewhere-card:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.elsewhere-card svg { width: 22px; height: 22px; fill: #5865F2; flex-shrink: 0; }
.elsewhere-card span { display: flex; flex-direction: column; }
.elsewhere-card strong { font-size: 14px; font-weight: 500; }
.elsewhere-card small { font-size: 12.5px; color: var(--muted); }
.elsewhere-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; font-size: 14px; color: var(--muted); text-decoration: none; border-radius: var(--r-sm); }
.elsewhere-link:hover { color: var(--text); background: var(--hover); }
.elsewhere-link svg { width: 16px; height: 16px; fill: currentColor; margin: 0 3px; }
.account-row.is-static { cursor: default; }
.account-row.is-static:hover { background: none; }

.community-page .bar { height: 64px; border-bottom: 1px solid var(--line); }
.room-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 14px; }
.room-title h1 { font-family: var(--sans); font-size: 16px; font-weight: 600; letter-spacing: 0; line-height: 1.3; white-space: nowrap; }
.room-about { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.presence { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.presence:not(:empty)::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #4E8A5B; }

.room { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.feed { max-width: 860px; margin: 0 auto; padding: 24px 28px 16px; }
.feed-status { padding: 40px 0; text-align: center; color: var(--muted); }
.feed-empty { padding: 12vh 0 24px; }
.feed-empty h2 { font-family: var(--serif); font-weight: 400; font-size: 32px; }
.feed-empty p { margin-top: 8px; color: var(--muted); }

.post { position: relative; display: grid; grid-template-columns: 36px 1fr; column-gap: 14px; padding: 6px 40px 6px 8px; margin: 0 -8px; border-radius: var(--r-sm); }
.post:not(.is-grouped) { margin-top: 14px; }
.post:hover { background: var(--hover); }
.post .avatar { width: 36px; height: 36px; margin-top: 2px; font-size: 15px; }
.post.is-grouped .post-body { grid-column: 2; }
.post header { display: flex; align-items: baseline; gap: 10px; }
.post header strong { font-size: 15px; font-weight: 600; }
.post time { font-size: 12.5px; color: var(--muted); }
.post p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.post p a { color: var(--accent); text-underline-offset: 3px; }
.post-delete {
  position: absolute; right: 8px; top: 6px;
  display: grid; place-items: center; width: 28px; height: 28px;
  background: var(--field); border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .15s;
}
.post-delete svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.post:hover .post-delete, .post-delete:focus-visible { opacity: 1; }
.post-delete:hover { color: var(--bad); }
@media (hover: none) { .post-delete { opacity: .7; } }

.room-foot { flex-shrink: 0; width: 100%; max-width: 860px; margin: 0 auto; padding: 0 28px; }
.room-foot .composer, .room-foot .composer-note { max-width: none; padding-left: 0; padding-right: 0; }
.room-composer { display: flex; align-items: flex-end; gap: 10px; padding: 10px 10px 10px 18px; }
.room-composer textarea { padding: 7px 0; }
.composer-note a { color: var(--muted); text-underline-offset: 2px; }
.room-error { margin-bottom: 8px; padding: 8px 14px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); font-size: 14px; }
.guest-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px 14px 20px; background: var(--field);
  border: 1px solid var(--line); border-radius: var(--r-lg);
}
.guest-bar span { flex: 1; min-width: 180px; color: var(--muted); }

@media (max-width: 720px) {
  .room-about { display: none; }
  .feed { padding: 16px 16px 12px; }
  .room-foot { padding: 0 14px; }
}

/* ---------- Account menu (profile · usage · settings · log out) ---------- */
.account-id { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.account-plan { font-size: 12.5px; color: var(--muted); }
.avatar.is-lg { width: 40px; height: 40px; font-size: 16px; }
.menu-profile { display: flex; align-items: center; gap: 12px; padding: 10px 12px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.menu-profile span { display: flex; flex-direction: column; min-width: 0; }
.menu-profile strong { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.menu-profile small { font-size: 13px; color: var(--muted); }
.account-menu .menu-item { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.account-menu .menu-item > svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.menu-sep { height: 1px; margin: 4px 0; background: var(--line); }
.menu-usage summary { list-style: none; cursor: pointer; }
.menu-usage summary::-webkit-details-marker { display: none; }
.menu-chevron { margin-left: auto; width: 16px !important; height: 16px !important; transition: transform .2s; }
.menu-usage[open] .menu-chevron { transform: rotate(180deg); }
.menu-usage-body { padding: 4px 12px 10px; }
.account-menu .menu-links { flex-wrap: wrap; row-gap: 6px; border-bottom: 0; margin-bottom: 0; }

/* Usage rows and bars (menu + meter popover) */
.usage-row + .usage-row { margin-top: 14px; }
.usage-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 7px; }
.usage-head strong { font-size: 13.5px; font-weight: 600; }
.usage-head span { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.usage-empty { font-size: 13px; color: var(--muted); }
.usage-hint { margin-top: 10px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.usage-hint a { color: var(--accent); }
.usage-divider { height: 1px; margin: 16px 0; background: var(--line); }
.usage-plan { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.usage-plan a { color: var(--text); text-decoration: none; }
.usage-plan a:hover { color: var(--accent); }
.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--text); transition: width .4s var(--ease); }
.bar.is-mid > span { background: var(--warn, #C08A2B); }
.bar.is-high > span { background: var(--bad); }

/* Context meter in the composer */
.meter { position: relative; margin-left: auto; }
.meter + .send { margin-left: 0; }
.meter-btn { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; background: none; border: 0; border-radius: 50%; cursor: pointer; }
.meter-btn:hover, .meter-btn[aria-expanded="true"] { background: var(--hover); }
.meter-btn svg { width: 20px; height: 20px; transform: rotate(-90deg); }
.meter-track { fill: none; stroke: var(--line); stroke-width: 2.5; }
.meter-fill { fill: none; stroke: var(--muted); stroke-width: 2.5; stroke-linecap: round; transition: stroke-dashoffset .4s var(--ease); }
.meter-fill.is-mid { stroke: var(--warn, #C08A2B); }
.meter-fill.is-high { stroke: var(--bad); }
.meter-pop {
  position: absolute; right: -44px; bottom: calc(100% + 14px); z-index: 30;
  width: 320px; padding: 18px;
  background: var(--field); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 40px -8px rgba(0, 0, 0, .22);
  animation: pop .14s var(--ease);
}
.conversation.is-empty .meter-pop { bottom: auto; top: calc(100% + 14px); }
:root { --warn: #C08A2B; }

/* ---------- Settings dialog ---------- */
.dialog.settings { width: min(560px, calc(100vw - 24px)); max-height: min(720px, calc(100dvh - 32px)); }
.settings-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 20px 12px 24px; }
.settings-head h2 { font-family: var(--serif); font-weight: 400; font-size: 26px; }
.icon-close { display: grid; place-items: center; width: 34px; height: 34px; background: none; border: 0; border-radius: 50%; color: var(--muted); cursor: pointer; }
.icon-close:hover { background: var(--hover); color: var(--text); }
.icon-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.settings-body { padding: 0 24px 24px; overflow-y: auto; }
.settings-body section + section { margin-top: 24px; }
.settings-body h3 { margin-bottom: 4px; font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setting strong { font-size: 15px; font-weight: 500; }
.setting small { font-size: 13px; line-height: 1.45; color: var(--muted); }
.setting small a { color: var(--accent); }
.setting-stack { flex-direction: column; align-items: stretch; }
.password-fields { display: flex; gap: 8px; flex-wrap: wrap; }
.password-fields input {
  flex: 1 1 160px; padding: 9px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  font: inherit; font-size: 14px; color: var(--text);
}
.password-fields input:focus { outline: 0; border-color: var(--muted); }
.form-note { font-size: 13px; color: var(--ok, #4E8A5B); }
.form-note.is-error { color: var(--bad); }
.settings-select {
  padding: 7px 30px 7px 12px; appearance: none;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%2368645D' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
  border: 1px solid var(--line); border-radius: 999px;
  font: inherit; font-size: 14px; color: var(--text); cursor: pointer;
}
.switch {
  appearance: none; flex-shrink: 0; position: relative;
  width: 40px; height: 22px; margin: 0; border-radius: 999px;
  background: var(--line); cursor: pointer; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  transition: transform .2s var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill-btn.is-danger-outline { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.pill-btn.is-danger-outline:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }

@media (max-width: 600px) {
  .meter-pop { right: -50px; width: min(320px, calc(100vw - 28px)); }
  .setting { flex-wrap: wrap; }
}
