/* ==========================================================================
   MEPX Cloud - interface styles
   ========================================================================== */

/* --------------------------------------------------------------- tokens -- */

:root {
  --bg: #ffffff;
  --bg-sunken: #f6f6f8;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-hover: #f1f1f4;
  --surface-active: #e9e9ee;
  --border: #e4e4e9;
  --border-strong: #d3d3db;

  --text: #17171c;
  --text-muted: #6a6a78;
  --text-faint: #9494a1;

  --accent: #5847e6;
  --accent-hover: #4b3ad8;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(88, 71, 230, 0.09);
  --accent-ring: rgba(88, 71, 230, 0.28);
  --focus-ring-soft: rgba(88, 71, 230, 0.13);

  --danger: #d13b3b;
  --danger-soft: rgba(209, 59, 59, 0.1);

  --code-bg: #f7f7fa;
  --code-head: #eeeef3;
  --tok-comment: #8a8a99;
  --tok-string: #1f7a4d;
  --tok-keyword: #8b2fb8;
  --tok-number: #b4601a;
  --tok-func: #2b5bd7;
  --tok-punct: #6a6a78;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(18, 18, 30, 0.06);
  --shadow-md: 0 4px 16px rgba(18, 18, 30, 0.08);
  --shadow-lg: 0 16px 44px rgba(18, 18, 30, 0.16);

  --sidebar-width: 272px;
  --thread-width: 780px;
  --speed: 160ms;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101014;
    --bg-sunken: #0b0b0e;
    --surface: #16161c;
    --surface-raised: #1c1c23;
    --surface-hover: #22222b;
    --surface-active: #2a2a34;
    --border: #26262f;
    --border-strong: #35353f;

    --text: #ececef;
    --text-muted: #9c9caa;
    --text-faint: #71717f;

    --accent: #8878ff;
    --accent-hover: #9a8dff;
    --accent-contrast: #12121a;
    --accent-soft: rgba(136, 120, 255, 0.14);
    --accent-ring: rgba(136, 120, 255, 0.32);
    --focus-ring-soft: rgba(136, 120, 255, 0.16);

    --danger: #ff6b6b;
    --danger-soft: rgba(255, 107, 107, 0.14);

    --code-bg: #0e0e13;
    --code-head: #17171e;
    --tok-comment: #6e6e80;
    --tok-string: #7ec699;
    --tok-keyword: #c792ea;
    --tok-number: #f0a35e;
    --tok-func: #82aaff;
    --tok-punct: #9c9caa;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #101014;
  --bg-sunken: #0b0b0e;
  --surface: #16161c;
  --surface-raised: #1c1c23;
  --surface-hover: #22222b;
  --surface-active: #2a2a34;
  --border: #26262f;
  --border-strong: #35353f;

  --text: #ececef;
  --text-muted: #9c9caa;
  --text-faint: #71717f;

  --accent: #8878ff;
  --accent-hover: #9a8dff;
  --accent-contrast: #12121a;
  --accent-soft: rgba(136, 120, 255, 0.14);
  --accent-ring: rgba(136, 120, 255, 0.32);
  --focus-ring-soft: rgba(136, 120, 255, 0.16);

  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.14);

  --code-bg: #0e0e13;
  --code-head: #17171e;
  --tok-comment: #6e6e80;
  --tok-string: #7ec699;
  --tok-keyword: #c792ea;
  --tok-number: #f0a35e;
  --tok-func: #82aaff;
  --tok-punct: #9c9caa;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.6);
}

/* ---------------------------------------------------------------- reset -- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/*
 * The `hidden` attribute is only a UA-stylesheet rule, so any author rule that
 * sets `display` silently defeats it. Several controls here are toggled with
 * `hidden` and do set `display`, so this has to win.
 */
[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -60px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  text-decoration: none;
  transition: top var(--speed) ease;
}

.skip-link:focus {
  top: 12px;
}

/* ---------------------------------------------------------------- shell -- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}

/* -------------------------------------------------------------- sidebar -- */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 12px;
  gap: 12px;
  background: var(--bg-sunken);
  border-right: 1px solid var(--border);
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand__logo {
  display: block;
  flex: none;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.brand__name {
  font-size: 15px;
}

.sidebar__close {
  display: none;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  font-weight: 550;
  transition: background var(--speed) ease, border-color var(--speed) ease, transform var(--speed) ease;
}

.new-chat:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.new-chat:active {
  transform: translateY(1px);
}

.conversations {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 -4px;
  padding: 0 4px;
}

.conversations__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.conversations__empty {
  margin: 12px 8px;
  color: var(--text-faint);
  font-size: 13px;
}

.conversation {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: background var(--speed) ease;
}

.conversation:hover {
  background: var(--surface-hover);
}

.conversation.is-active {
  background: var(--surface-active);
}

.conversation__open {
  flex: 1;
  min-width: 0;
  padding: 9px 4px 9px 10px;
  text-align: left;
  font-size: 13.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: var(--radius-sm);
}

.conversation.is-active .conversation__open {
  color: var(--text);
  font-weight: 550;
}

.conversation__more {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  margin-right: 5px;
  border-radius: 7px;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity var(--speed) ease, background var(--speed) ease, color var(--speed) ease;
}

.conversation:hover .conversation__more,
.conversation:focus-within .conversation__more,
.conversation.is-active .conversation__more {
  opacity: 1;
}

.conversation__more:hover {
  background: var(--surface-active);
  color: var(--text);
}

.conversation__rename {
  flex: 1;
  min-width: 0;
  margin: 4px 6px;
  padding: 5px 8px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--surface);
  font-size: 13.5px;
}

.conversation__rename:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.sidebar__foot {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.ghost-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  transition: background var(--speed) ease, color var(--speed) ease;
}

.ghost-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.ghost-btn__icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
}

.icon-moon {
  display: none;
}

:root[data-theme="dark"] .icon-sun {
  display: none;
}

:root[data-theme="dark"] .icon-moon {
  display: block;
}

/* ----------------------------------------------------------------- main -- */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
}

.topbar__menu {
  display: none;
}

.topbar__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding-right: 8px;
  font-size: 14.5px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--speed) ease, color var(--speed) ease;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* --------------------------------------------------------- model picker -- */

.model-picker {
  position: relative;
  flex: none;
  /* keeps the attach button and the model name together on the left */
  margin-right: auto;
}

.model-picker__button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px 5px 11px;
  border: 1px solid transparent;
  border-radius: 99px;
  background: none;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 550;
  transition: background var(--speed) ease, border-color var(--speed) ease, color var(--speed) ease;
}

.model-picker__button:hover,
.model-picker__button[aria-expanded="true"] {
  background: var(--surface-hover);
  border-color: var(--border);
  color: var(--text);
}

.model-picker__button svg {
  transition: transform var(--speed) ease;
}

.model-picker__button[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.model-picker__list {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  z-index: 40;
  width: 280px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  animation: pop-up var(--speed) ease;
}

@keyframes pop-up {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.model-option {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: background var(--speed) ease;
}

.model-option:hover,
.model-option.is-focused {
  background: var(--surface-hover);
}

.model-option__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.model-option__name {
  font-size: 13.5px;
  font-weight: 600;
}

.model-option__check {
  color: var(--accent);
  opacity: 0;
}

.model-option[aria-selected="true"] .model-option__check {
  opacity: 1;
}

.model-option__desc {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.45;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* --------------------------------------------------------------- thread -- */

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
}

.messages {
  max-width: var(--thread-width);
  margin: 0 auto;
  padding: 28px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.messages:empty {
  padding: 0;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: rise 220ms ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.msg--user {
  align-items: flex-end;
}

.msg--user .msg__body {
  max-width: min(560px, 88%);
  padding: 11px 15px;
  border-radius: var(--radius-lg) var(--radius-lg) 5px var(--radius-lg);
  background: var(--accent);
  color: var(--accent-contrast);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg--assistant .msg__body {
  overflow-wrap: anywhere;
}

.msg__role {
  padding: 0 2px;
  color: var(--text-faint);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.msg__actions {
  display: flex;
  gap: 4px;
  padding: 0 2px;
  opacity: 0;
  transition: opacity var(--speed) ease;
}

.msg:hover .msg__actions,
.msg:focus-within .msg__actions,
.msg__actions.is-persistent {
  opacity: 1;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 12.5px;
  transition: background var(--speed) ease, color var(--speed) ease;
}

.chip-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.msg__edit {
  width: 100%;
  max-width: min(560px, 88%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg__edit textarea {
  width: 100%;
  min-height: 84px;
  padding: 11px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  resize: vertical;
}

.msg__edit textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.msg__edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.solid-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 13px;
  font-weight: 550;
  transition: background var(--speed) ease;
}

.solid-btn:hover {
  background: var(--accent-hover);
}

/*
 * Anything shaped like a button is not underlined, whether it is a <button> or
 * an <a> wearing the same class. Links inside prose keep their underline - that
 * is how a reader tells a link from the text around it - so this names the
 * button classes rather than switching it off for every anchor.
 */
.quiet-btn,
.solid-btn,
.ghost-btn,
.plan__cta,
.chip-btn,
.new-chat,
.brand--link,
.menu__item,
.consent__btn,
.truncated__continue {
  text-decoration: none;
}

.quiet-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  transition: background var(--speed) ease, color var(--speed) ease;
}

.quiet-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* streaming cursor */
.cursor {
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  background: var(--accent);
  animation: blink 1.05s steps(2, start) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.thinking {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 20px;
}

.thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: bounce 1.2s ease-in-out infinite;
}

.thinking span:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.55;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* -------------------------------------------------------------- welcome -- */

.welcome {
  max-width: var(--thread-width);
  margin: 0 auto;
  padding: clamp(40px, 12vh, 120px) 24px 24px;
  text-align: center;
}

.welcome__title {
  margin: 0 0 8px;
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.welcome__text {
  margin: 0 0 28px;
  color: var(--text-muted);
}

.welcome__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  text-align: left;
}

.suggestion {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13.5px;
  color: var(--text-muted);
  transition: background var(--speed) ease, border-color var(--speed) ease, transform var(--speed) ease;
}

.suggestion:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
  transform: translateY(-1px);
}

.suggestion strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-weight: 600;
}

/* ------------------------------------------------------------- composer -- */

.composer {
  flex: none;
  padding: 10px 24px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, transparent);
}

.composer__inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: var(--thread-width);
  margin: 0 auto;
  padding: 10px 10px 10px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease;
}

/* the model choice sits with the message it applies to, not in the chrome */
.composer__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.composer__inner:focus-within {
  /* The accent border carries the focus state; the ring only lifts the field
     off the page. Anything heavier reads as a glow across the whole width. */
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring-soft), var(--shadow-sm);
}

.composer__input {
  flex: 1;
  min-width: 0;
  max-height: 220px;
  padding: 8px 0;
  border: none;
  background: none;
  resize: none;
  line-height: 1.55;
}

.composer__input:focus {
  outline: none;
}

.composer__input::placeholder {
  color: var(--text-faint);
}

/* the + button, its tray, and what has been attached ---------------------- */

.attach-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  transition: background var(--speed) ease, color var(--speed) ease,
    border-color var(--speed) ease;
}

.attach-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 2px;
}

.attachment {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 4px 6px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-hover);
  font-size: 12.5px;
}

.attachment__thumb {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
}

.attachment__name {
  overflow: hidden;
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment__remove {
  display: grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: var(--text-faint);
  transition: background var(--speed) ease, color var(--speed) ease;
}

.attachment__remove:hover {
  background: var(--surface);
  color: var(--text);
}

/* the same files, shown again beneath the message they were sent with */
.msg__files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.msg__file {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg__file img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
}

.composer__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer__count {
  color: var(--text-faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.composer__count.is-warning {
  color: var(--danger);
}

.send-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  transition: background var(--speed) ease, opacity var(--speed) ease, transform var(--speed) ease;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  font-size: 13px;
  font-weight: 550;
  transition: background var(--speed) ease;
}

.stop-btn:hover {
  background: var(--surface-hover);
}

.composer__hint {
  max-width: var(--thread-width);
  margin: 8px auto 0;
  color: var(--text-faint);
  font-size: 11.5px;
  text-align: center;
}

/* ------------------------------------------------------------- markdown -- */

.markdown > *:first-child {
  margin-top: 0;
}

.markdown > *:last-child {
  margin-bottom: 0;
}

.markdown p {
  margin: 0 0 14px;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  margin: 24px 0 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.markdown h1 {
  font-size: 21px;
}

.markdown h2 {
  font-size: 18px;
}

.markdown h3 {
  font-size: 16px;
}

.markdown h4 {
  font-size: 15px;
}

.markdown ul,
.markdown ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

.markdown li {
  margin: 4px 0;
}

.markdown li > ul,
.markdown li > ol {
  margin: 4px 0;
}

.markdown blockquote {
  margin: 0 0 14px;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
}

.markdown a {
  color: var(--accent);
  text-underline-offset: 2px;
}

.markdown hr {
  margin: 20px 0;
  border: none;
  border-top: 1px solid var(--border);
}

.markdown code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--accent-soft);
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.markdown .table-wrap {
  margin: 0 0 14px;
  overflow-x: auto;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.markdown th,
.markdown td {
  padding: 7px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.markdown th {
  background: var(--surface-hover);
  font-weight: 600;
}

/* code blocks */
.code-block {
  margin: 0 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code-bg);
}

.code-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--code-head);
}

.code-block__lang {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.code-block__copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  transition: background var(--speed) ease, color var(--speed) ease;
}

.code-block__copy:hover {
  background: var(--surface-active);
  color: var(--text);
}

.code-block pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
}

.code-block code {
  padding: 0;
  background: none;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
}

.tok-comment {
  color: var(--tok-comment);
  font-style: italic;
}

.tok-string {
  color: var(--tok-string);
}

.tok-keyword {
  color: var(--tok-keyword);
}

.tok-number {
  color: var(--tok-number);
}

.tok-func {
  color: var(--tok-func);
}

.tok-punct {
  color: var(--tok-punct);
}

/* ----------------------------------------------------------------- menu -- */

.menu {
  position: fixed;
  z-index: 60;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  animation: pop var(--speed) ease;
}

.menu__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  text-align: left;
  transition: background var(--speed) ease, color var(--speed) ease;
}

.menu__item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.menu__item--danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.menu__sep {
  height: 1px;
  margin: 5px 6px;
  background: var(--border);
}

/* --------------------------------------------------------------- toasts -- */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  animation: slide-in 200ms ease;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
}

.toast__text {
  flex: 1;
}

.toast__retry {
  flex: none;
  align-self: center;
  padding: 5px 11px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 12.5px;
  font-weight: 550;
}

.toast__close {
  flex: none;
  align-self: flex-start;
  color: var(--text-faint);
  line-height: 1;
}

.toast__close:hover {
  color: var(--text);
}

/* --------------------------------------------------------------- scrim -- */

.scrim {
  display: none;
}

/* ----------------------------------------------------------- responsive -- */

@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    width: min(84vw, var(--sidebar-width));
    transform: translateX(-102%);
    transition: transform 220ms cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: var(--shadow-lg);
  }

  .app.drawer-open .sidebar {
    transform: translateX(0);
  }

  .sidebar__close,
  .topbar__menu {
    display: grid;
  }

  .app.drawer-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(8, 8, 14, 0.45);
    animation: fade 200ms ease;
  }

  @keyframes fade {
    from {
      opacity: 0;
    }
  }

  .messages {
    padding: 22px 16px 32px;
  }

  .composer {
    padding-inline: 14px;
  }

  .welcome {
    padding-inline: 16px;
  }
}

@media (max-width: 420px) {
  body {
    font-size: 14.5px;
  }

  .topbar {
    padding: 0 10px;
    gap: 8px;
  }

  .model-picker__list {
    width: min(280px, calc(100vw - 36px));
  }

  .model-picker__name {
    max-width: 42vw;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .msg--user .msg__body {
    max-width: 94%;
  }

  .composer__hint {
    display: none;
  }
}

/* thin scrollbars, without hiding them entirely */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 99px;
  background-clip: content-box;
  background-color: var(--border-strong);
}

/* plain-text fallback when a document cannot be parsed as Markdown */
.plain-fallback {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ======================================================= subscription page */

.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.page__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}

.brand--link {
  text-decoration: none;
  color: inherit;
}

.page__main {
  flex: 1;
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  padding: clamp(32px, 7vw, 72px) 24px 64px;
}

.pricing__intro {
  text-align: center;
  margin-bottom: 36px;
}

.pricing__title {
  margin: 0 0 10px;
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 600;
  letter-spacing: -0.025em;
}

.pricing__lede {
  max-width: 46ch;
  margin: 0 auto 26px;
  color: var(--text-muted);
}

.billing-toggle {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--bg-sunken);
}

.billing-toggle__option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: 99px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 550;
  transition: background var(--speed) ease, color var(--speed) ease;
}

.billing-toggle__option:hover {
  color: var(--text);
}

.billing-toggle__option.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.billing-toggle__badge {
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
}

.pricing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  align-items: start;
}

.plan {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 26px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.plan--featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-md);
}

.plan__flag {
  position: absolute;
  top: -11px;
  left: 24px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.plan__name {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.plan__price {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 0 0 8px;
}

.plan__amount {
  font-size: 38px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.plan__period {
  color: var(--text-muted);
  font-size: 13.5px;
}

.plan__note {
  min-height: 38px;
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.plan__cta {
  display: block;
  width: 100%;
  padding: 11px 16px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: background var(--speed) ease, opacity var(--speed) ease;
}

.plan__cta:hover {
  background: var(--accent-hover);
}

.plan__cta:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.plan__cta.is-done {
  opacity: 1;
  background: var(--surface-active);
  color: var(--text);
}

.plan__cta--quiet {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.plan__cta--quiet:hover {
  background: var(--surface-hover);
}

.plan__features {
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.plan__features li {
  position: relative;
  padding-left: 24px;
  line-height: 1.5;
}

.plan__features li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 7px;
  width: 9px;
  height: 5px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}

.plan__features strong {
  color: var(--text);
}

.pricing__status {
  margin: 22px 0 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

.faq {
  margin-top: 56px;
}

.faq__title {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 600;
}

.faq__item {
  border-bottom: 1px solid var(--border);
}

.faq__item summary {
  padding: 15px 2px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 550;
  list-style: none;
}

.faq__item summary::-webkit-details-marker {
  display: none;
}

.faq__item summary::after {
  content: "+";
  float: right;
  color: var(--text-faint);
  font-weight: 400;
}

.faq__item[open] summary::after {
  content: "\2212";
}

.faq__item p {
  margin: 0 0 16px;
  padding-right: 24px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.page__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 22px 24px calc(28px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 12px;
}

.page__foot a {
  color: var(--text-muted);
  text-decoration: none;
}

/* ------------------------------------------------ locked model in picker -- */

.model-option--locked .model-option__name {
  color: var(--text-muted);
}

.model-option__lock {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

/*
 * "Limited time", under the description rather than beside the name.
 *
 * Quieter than the lock badge on purpose: the lock is a gate you have to act on
 * to get past, this is a fact about the offer. Giving them the same weight
 * would make every gated model look like two warnings.
 */
.model-option__flag {
  display: inline-block;
  margin-top: 6px;
  padding: 1px 7px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

@media (max-width: 560px) {
  .page__bar {
    padding: 12px 16px;
  }

  .page__main {
    padding-inline: 16px;
  }

  .plan {
    padding: 22px 18px;
  }

  .plan__amount {
    font-size: 32px;
  }
}

/* ghost-btn is used for both buttons and links in the sidebar footer */
a.ghost-btn {
  text-decoration: none;
}

/* ============================================================= sign-in page */

.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 520px;
}

.auth__card {
  width: 100%;
  padding: 32px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.auth__title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth__lede {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.auth__providers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth__provider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  transition: background var(--speed) ease, border-color var(--speed) ease, transform var(--speed) ease;
}

.auth__provider:hover {
  background: var(--surface-hover);
  border-color: var(--text-faint);
}

.auth__provider:active {
  transform: translateY(1px);
}

.auth__loading {
  margin: 0;
  color: var(--text-faint);
  font-size: 13.5px;
}

.auth__error {
  margin: 16px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.auth__note {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

.auth__fine {
  margin: 12px 0 0;
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.55;
}

/* ------------------------------------------------- account row in sidebar -- */

.account {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  text-decoration: none;
  transition: background var(--speed) ease, color var(--speed) ease;
}

.account:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.account__avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
}

.account__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
}

.account__badge {
  flex: none;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
}

/* ============================================================= updates page */

.page__nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- hero: the coastal photograph, with a scrim so text stays readable --- */

.hero {
  position: relative;
  isolation: isolate;
  /*
   * `overflow: hidden` makes a flex item's automatic minimum size 0, so as a
   * child of the column-flex page this would otherwise shrink to nothing and
   * let its own content overflow. Opt out of shrinking.
   */
  flex: none;
  overflow: hidden;
  background-color: #0d1417;
  background-image: url("/updates-hero.jpg");
  background-image: -webkit-image-set(url("/updates-hero.webp") type("image/webp"), url("/updates-hero.jpg") type("image/jpeg"));
  background-image: image-set(url("/updates-hero.webp") type("image/webp"), url("/updates-hero.jpg") type("image/jpeg"));
  background-size: cover;
  background-position: center 42%;
}

/*
 * The photograph is bright, so the copy needs its own ground rather than
 * relying on the image. Fixed light-on-dark here in both themes: the picture
 * does not change with the theme, so the text over it must not either.
 */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    180deg,
    rgba(8, 10, 16, 0.55) 0%,
    rgba(8, 10, 16, 0.62) 45%,
    rgba(8, 10, 16, 0.82) 100%
  );
}

.hero__inner {
  max-width: 940px;
  margin: 0 auto;
  padding: clamp(56px, 12vw, 118px) 24px clamp(48px, 10vw, 96px);
  text-align: center;
  color: #f4f4f8;
}

.hero__eyebrow {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244, 244, 248, 0.72);
}

.hero__title {
  margin: 0 0 14px;
  font-size: clamp(34px, 7vw, 60px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.4);
}

.hero__lede {
  max-width: 52ch;
  margin: 0 auto;
  color: rgba(244, 244, 248, 0.86);
  font-size: clamp(14.5px, 2vw, 17px);
  line-height: 1.6;
}

/* ------------------------------------------------------------- timeline -- */

.updates {
  max-width: 860px;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline__loading {
  padding: 24px 0;
  color: var(--text-faint);
  font-size: 13.5px;
}

.release {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 24px;
  padding: 30px 0;
  border-top: 1px solid var(--border);
}

.release:first-child {
  border-top: none;
}

.release__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding-top: 3px;
}

.release__version {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.release--latest .release__version {
  color: var(--accent);
}

.release__date {
  color: var(--text-faint);
  font-size: 12.5px;
}

.release__latest {
  margin-top: 6px;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.release__title {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.release__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.tag {
  padding: 2px 9px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tag--new {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}

.tag--improved {
  border-color: transparent;
  background: rgba(46, 140, 90, 0.14);
  color: #2f8b58;
}

.tag--fixed {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger);
}

.tag--design {
  border-color: transparent;
  background: rgba(180, 96, 26, 0.14);
  color: #b4601a;
}

:root[data-theme="dark"] .tag--improved,
:root[data-theme="dark"] .tag--design {
  color: #8fd0a8;
}

:root[data-theme="dark"] .tag--design {
  color: #f0a35e;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag--improved {
    color: #8fd0a8;
  }
  :root:not([data-theme="light"]) .tag--design {
    color: #f0a35e;
  }
}

.release__summary {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.6;
}

.release__items {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.release__items li {
  position: relative;
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.release__items li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border-strong);
}

.updates__error {
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ------------------------------ closing banner: the keynote photograph -- */

.stage {
  position: relative;
  isolation: isolate;
  flex: none; /* same reason as .hero */
  margin-top: 24px;
  overflow: hidden;
  background: #16101f;
}

.stage__image {
  display: block;
  width: 100%;
  height: clamp(280px, 34vw, 420px);
  object-fit: cover;
  object-position: center 44%;
}

.stage__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: #f4f4f8;
  /* Enough to carry white text, light enough to still read as a photograph. */
  background: radial-gradient(
    ellipse at center,
    rgba(14, 10, 24, 0.5) 0%,
    rgba(14, 10, 24, 0.72) 62%,
    rgba(14, 10, 24, 0.82) 100%
  );
}

.stage__logo {
  width: clamp(56px, 8vw, 76px);
  height: clamp(56px, 8vw, 76px);
  margin-bottom: 4px;
  filter: drop-shadow(0 6px 24px rgba(0, 0, 0, 0.5));
}

.stage__name {
  margin: 0;
  font-size: clamp(20px, 3.4vw, 28px);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.stage__tagline {
  margin: 0 0 6px;
  color: rgba(244, 244, 248, 0.9);
  font-size: 14px;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
}

.stage__cta {
  margin-top: 8px;
  padding: 10px 22px;
  border-radius: 99px;
  background: var(--accent);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--speed) ease, transform var(--speed) ease;
}

.stage__cta:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .release {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 24px 0;
  }

  .release__meta {
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
  }

  .release__latest {
    margin-top: 0;
  }

  .page__nav .quiet-btn:first-child {
    display: none;
  }
}

/* reply stopped at the token ceiling rather than finishing */
.truncated {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--tok-number);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12.5px;
}

.truncated__continue {
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 12px;
  font-weight: 600;
  transition: background var(--speed) ease;
}

.truncated__continue:hover {
  background: var(--accent-hover);
}

/* ------------------------------------------------------- share control -- */

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 6px 13px 6px 11px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 550;
  transition: background var(--speed) ease, border-color var(--speed) ease, color var(--speed) ease;
}

.share-btn:hover,
.share-btn[aria-expanded="true"] {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

/* explanatory copy inside the popup, before a consequential choice */
.menu__note {
  margin: 2px 4px 10px;
  padding: 0 6px;
  max-width: 260px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ------------------------------------------------- shared conversation -- */

.shared {
  max-width: var(--thread-width);
}

.shared__head {
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.shared__title {
  margin: 0 0 6px;
  font-size: clamp(21px, 4vw, 27px);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.shared__meta {
  margin: 0;
  color: var(--text-faint);
  font-size: 12.5px;
}

.shared .messages {
  padding: 0;
  gap: 26px;
}

.shared__status {
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

.shared__cta {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.shared__cta-text {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.shared__cta .plan__cta {
  display: inline-block;
  width: auto;
  padding: 10px 24px;
}

@media (max-width: 560px) {
  .share-btn span {
    display: none;
  }

  .share-btn {
    padding: 7px 10px;
  }
}

/* a plan feature that is announced but not yet switched on */
.feature-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--surface-active);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: 1px;
}

/* ==========================================================================
   Cookie consent and the policy page
   ========================================================================== */

.consent {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 10, 16, 0.5);
  overscroll-behavior: contain;
}

.consent--panel {
  align-items: center;
}

/* The page behind must not scroll while a decision is outstanding. */
.has-consent-dialog,
.has-consent-dialog body {
  overflow: hidden;
}

.consent__card {
  width: 100%;
  max-width: 620px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

/* The card takes focus so the dialog is announced and Tab starts inside it.
   It is not a control, so it must not draw a focus ring of its own. */
.consent__card:focus,
.consent__card:focus-visible {
  outline: none;
}

.consent__card--panel {
  max-width: 560px;
  max-height: min(84vh, 720px);
  overflow-y: auto;
}

.consent__title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.consent__text {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.consent__text--small {
  margin: 14px 0 0;
  font-size: 12.5px;
}

.consent__link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/*
 * Reject and Accept are the same size, the same padding and the same weight.
 * Only the colour differs. A consent choice where one option is quieter than
 * the other is not really a choice.
 */
.consent__btn {
  flex: 1 1 auto;
  min-width: 140px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  transition: background var(--speed) ease, border-color var(--speed) ease;
}

.consent__btn:hover {
  background: var(--surface-hover);
}

.consent__btn--accent {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.consent__btn--accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.consent__btn--quiet {
  flex: 0 1 auto;
  border-color: transparent;
  color: var(--text-muted);
}

.consent__list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}

.consent__row {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-hover);
}

.consent__row-head {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.consent__row-name {
  font-size: 14px;
  font-weight: 600;
}

.consent__row-state {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 12px;
}

.consent__switch {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.consent__switch:disabled {
  cursor: default;
  opacity: 0.55;
}

.consent__row-text {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.consent__row-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.7;
}

@media (max-width: 520px) {
  .consent__btn {
    flex: 1 1 100%;
  }
}

/* ------------------------------------------------------- the policy page -- */

.legal {
  max-width: 760px;
}

.legal__title {
  margin: 0 0 12px;
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.legal__lede {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 15.5px;
  line-height: 1.65;
}

.legal__meta {
  margin: 0 0 34px;
  color: var(--text-faint);
  font-size: 12.5px;
}

.legal h2 {
  margin: 34px 0 10px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.legal h3 {
  margin: 24px 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.legal p,
.legal li {
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.7;
}

.legal p {
  margin: 0 0 12px;
}

.legal ul {
  margin: 0 0 12px;
  padding-left: 20px;
}

.legal li {
  margin-bottom: 8px;
}

.legal code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-hover);
  color: var(--text);
  font-size: 0.9em;
}

/* A table is the clearest shape for this, so it must survive a narrow screen
   by scrolling itself rather than widening the page. */
.legal__scroll {
  overflow-x: auto;
  margin: 0 0 16px;
}

.legal__table {
  width: 100%;
  min-width: 460px;
  border-collapse: collapse;
  font-size: 13.5px;
}

.legal__table th,
.legal__table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  text-align: left;
  vertical-align: top;
  line-height: 1.6;
}

.legal__table th {
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

/* An unmissable admonition for the few facts a human still has to supply. */
.legal__note {
  margin: 0 0 30px;
  padding: 14px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--focus-ring-soft);
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.65;
}

.legal__note strong {
  color: var(--text);
}

.help-menu .menu__item[aria-current='page'] {
  color: var(--text);
  background: var(--surface-hover);
}

.legal__cta {
  margin-top: 28px;
}
