:root {
  --canvas: #f5f5f7;
  --surface: #ffffff;
  --sidebar: rgba(255, 255, 255, 0.72);
  --control-surface: rgba(245, 245, 247, 0.82);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: rgba(60, 60, 67, 0.18);
  --accent: #007aff;
  --accent-text: #005ecb;
  --accent-pressed: #0066d6;
  --accent-soft: #eaf3ff;
  --danger: #d70015;
  --danger-soft: #fff1f2;
  --warning-soft: #fff8e7;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sidebar-width: 272px;
  --message-max: 760px;
  --composer-max: 820px;
  --focus-ring: 0 0 0 3px rgba(0, 122, 255, 0.28), 0 0 0 1px var(--accent);
  color-scheme: light;
  font-family: var(--font);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--canvas);
  color: var(--text);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: rgba(0, 122, 255, 0.16);
}

button,
input,
textarea { color: inherit; font: inherit; }
button,
input,
textarea,
label[for] { touch-action: manipulation; }
button { border: 0; }
a { color: inherit; }
[hidden] { display: none !important; }

svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

::selection { background: #cfe6ff; color: var(--text); }

:focus-visible {
  border-radius: 8px;
  outline: none;
  box-shadow: var(--focus-ring);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 200;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 140ms ease;
}
.skip-link:focus-visible { transform: translateY(0); }

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

.brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 17px;
  font-weight: 720;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.brand--large { font-size: 18px; }

.brand-mark {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 6px;
  border-radius: 10px;
  background: var(--accent);
}
.brand-mark i { display: block; width: 3px; border-radius: 2px; background: #fff; }
.brand-mark i:nth-child(1) { height: 7px; opacity: .72; }
.brand-mark i:nth-child(2) { height: 16px; }
.brand-mark i:nth-child(3) { height: 11px; opacity: .85; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.button:disabled { cursor: not-allowed; opacity: .5; }
.button--wide { width: 100%; }
.button--small { min-height: 38px; padding: 7px 12px; font-size: 13px; }
.button--primary { background: var(--accent); color: #fff; }
.button--primary:hover:not(:disabled) { background: var(--accent-pressed); }
.button--telegram { border-color: var(--border); background: var(--surface); color: var(--text); }
.button--telegram:hover:not(:disabled) { border-color: rgba(60,60,67,.3); background: #f5f5f7; }
.button--ghost { border-color: var(--border); background: var(--surface); color: var(--text); }
.button--ghost:hover:not(:disabled) { background: #f5f5f7; }
.button--danger { border-color: #f2c8c4; background: var(--danger-soft); color: var(--danger); }

.icon-button {
  display: inline-flex;
  width: 44px;
  min-width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-button:hover { background: rgba(60,60,67,.08); color: var(--text); }

/* Authentication */
.auth-view {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-columns: minmax(330px, 38%) minmax(440px, 62%);
  background: var(--canvas);
}

.auth-identity {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(28px, 4vw, 56px);
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.auth-identity::before,
.auth-identity::after { display: none; }

.auth-thesis { max-width: 440px; margin: auto 0; }
.auth-thesis h1 {
  margin: 0 0 18px;
  font-size: clamp(32px, 3.3vw, 44px);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1.04;
}
.auth-thesis > p:last-child {
  max-width: 410px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.auth-capabilities {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.auth-capabilities li {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 12px;
}

.auth-panel {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: clamp(24px, 5vw, 72px);
  background: var(--canvas);
}
.auth-card {
  position: relative;
  width: min(100%, 430px);
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(29,29,31,.04);
}
.auth-back { display: inline-flex; min-height: 44px; align-items: center; margin: -12px 0 10px; }
.signal-glyph { display: none; }
.auth-card h2 {
  margin: 0 0 10px;
  font-size: 25px;
  font-weight: 680;
  letter-spacing: -0.03em;
}
.auth-copy { margin: 0 0 24px; color: var(--muted); }
.auth-copy strong { color: var(--text); }

.auth-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  margin-bottom: 18px;
  border-radius: 11px;
  background: var(--canvas);
}
.auth-mode-tab {
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.auth-mode-tab.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(29,29,31,.08); }
.auth-form .field { margin-top: 0; }
.auth-card .button + .button,
.auth-form .button + .button { margin-top: 8px; }

.code-destination { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.code-destination strong { color: var(--text); overflow-wrap: anywhere; }
.field .code-input { font-size: 20px; font-weight: 700; letter-spacing: .32em; text-align: center; font-variant-numeric: tabular-nums; }
.field-help { margin: -7px 0 14px; color: var(--muted); font-size: 12px; }

.text-button {
  min-height: 44px;
  padding: 5px 3px;
  background: transparent;
  color: var(--accent-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.text-button.is-active { color: var(--text); }
.password-mode-switch { display: flex; align-items: center; gap: 8px; margin: -4px 0 14px; color: var(--muted); }
.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.password-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,122,255,.18); }
.field .password-field input { min-width: 0; border: 0; background: transparent; box-shadow: none; }
.password-field .text-button { min-height: 44px; padding: 6px 11px; }

.auth-separator { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 18px 0 10px; color: var(--muted); font-size: 12px; }
.auth-separator::before,
.auth-separator::after { height: 1px; background: var(--border); content: ""; }
.auth-status { min-height: 44px; padding-top: 16px; color: var(--muted); font-size: 13px; }
.auth-status.is-error { color: var(--danger); }

/* Application shell */
.app-shell {
  display: grid;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  overflow: hidden;
  background: var(--canvas);
}

.sidebar {
  position: relative;
  z-index: 20;
  display: grid;
  min-width: 0;
  height: 100%;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 16px 12px 12px;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.sidebar-close { display: none; }

.new-chat-button {
  display: grid;
  min-height: 48px;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
  text-align: left;
}
.new-chat-button:hover { border-color: rgba(60,60,67,.3); background: #f5f5f7; }
.new-chat-button svg { color: var(--accent); }
.new-chat-button kbd { color: var(--muted); font-family: var(--font); font-size: 11px; font-weight: 500; }

.chat-navigation { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-color: #c7c7cc transparent; }
.chat-list { padding: 2px 0 16px; }
.guest-history-preview { display: grid; gap: 8px; padding: 16px 12px; margin: 2px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.guest-history-preview strong { font-size: 13px; }
.guest-history-preview span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.guest-history-preview .text-button { width: max-content; padding: 0; }
.chat-group + .chat-group { margin-top: 20px; }
.chat-group-title { padding: 0 10px; margin: 0 0 5px; color: var(--muted); font-size: 12px; font-weight: 600; }

.chat-row { position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; border-radius: 9px; }
.chat-row:hover,
.chat-row:focus-within { background: rgba(60,60,67,.08); }
.chat-row.is-active { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.chat-row.is-active::before { position: absolute; left: 0; width: 2px; height: 22px; border-radius: 2px; background: var(--accent); content: ""; }
.chat-select { min-width: 0; min-height: 44px; padding: 9px 6px 9px 12px; overflow: hidden; background: transparent; color: #3a3a3c; cursor: pointer; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.chat-row.is-active .chat-select { color: var(--text); font-weight: 620; }
.chat-actions { position: relative; }
.chat-actions summary { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 8px; color: var(--muted); cursor: pointer; list-style: none; opacity: 0; }
.chat-actions summary::-webkit-details-marker { display: none; }
.chat-row:hover .chat-actions summary,
.chat-row:focus-within .chat-actions summary,
.chat-actions[open] summary { opacity: 1; }
.chat-actions summary::before { content: "•••"; font-size: 11px; letter-spacing: 1px; }
.chat-action-menu { position: fixed; z-index: 60; width: 164px; padding: 6px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); box-shadow: 0 10px 30px rgba(31,35,33,.12); }
.chat-action-menu button { width: 100%; min-height: 44px; padding: 8px 10px; border-radius: 8px; background: transparent; cursor: pointer; text-align: left; }
.chat-action-menu button:hover { background: var(--sidebar); }
.chat-action-menu .danger-action { color: var(--danger); }

.account-button {
  display: grid;
  min-height: 60px;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  text-align: left;
}
.account-button:hover { background: rgba(60,60,67,.08); }
.account-button.is-open { background: #ededf0; }
.account-button > svg { width: 18px; color: var(--muted); }
.avatar { display: inline-grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 720; }
.avatar--small { width: 34px; height: 34px; border-radius: 10px; }
.account-copy { display: flex; min-width: 0; flex-direction: column; }
.account-copy strong,
.account-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: 14px; }
.account-copy span { color: var(--muted); font-size: 12px; }
.account-menu {
  position: absolute;
  z-index: 75;
  right: 12px;
  bottom: 80px;
  left: 12px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 18px 50px rgba(29,29,31,.16);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  animation: account-menu-in 120ms ease-out;
}
@keyframes account-menu-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.account-menu-identity { display: grid; min-height: 64px; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 10px; padding: 10px 12px; }
.account-menu-identity .avatar { width: 36px; height: 36px; }
.account-menu-group { padding: 6px 0; border-top: 1px solid var(--border); }
.account-menu-group button { display: flex; width: 100%; min-height: 44px; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; background: transparent; color: var(--text); cursor: pointer; font-size: 14px; text-align: left; }
.menu-icon { width: 20px; height: 20px; flex: 0 0 auto; opacity: .7; }
.account-menu-group button:hover,
.account-menu-group button:focus-visible { background: #f2f2f7; }
.guest-account-actions button { justify-content: center; }
.guest-account-actions button:last-child { background: var(--accent); color: #fff; }
.guest-account-actions button:last-child:hover,
.guest-account-actions button:last-child:focus-visible { background: var(--accent-pressed); }

.workspace {
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: var(--surface);
}
.chat-view {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-rows: auto auto minmax(0,1fr) auto;
  overflow: hidden;
}
.workspace-header {
  position: relative;
  z-index: 5;
  display: grid;
  grid-row: 1;
  min-height: 64px;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.sidebar-open { display: none; grid-column: 1; }
.chat-heading { min-width: 0; grid-column: 2; }
.chat-heading h1 { margin: 0; overflow: hidden; font-size: 15px; font-weight: 650; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.chat-heading .eyebrow { margin-bottom: 1px; font-size: 11px; }
.profile-pill { display: inline-flex; min-height: 44px; grid-column: 3; justify-self: end; align-items: center; gap: 8px; padding: 4px 4px 4px 11px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 12px; text-decoration: none; }
.profile-pill:hover { border-color: rgba(60,60,67,.3); color: var(--text); }
.guest-header-actions { display: flex; min-width: 0; grid-column: 3; justify-self: end; align-items: center; gap: 5px; }
.guest-header-actions .text-button { padding: 4px 8px; }
.guest-register-button { min-height: 40px; padding: 7px 13px; border-radius: 11px; font-size: 13px; }
.guest-register-short { display: none; }
.network-banner { z-index: 6; grid-row: 2; padding: 8px 20px; border-bottom: 1px solid #f0d1ce; background: var(--danger-soft); color: var(--danger); font-size: 13px; text-align: center; }

.message-feed { min-height: 0; grid-row: 3; overflow: auto; overscroll-behavior: contain; scroll-behavior: smooth; scrollbar-color: #c7c7cc transparent; background: var(--surface); }
.messages-loading { display: grid; width: min(calc(100% - 40px), var(--message-max)); gap: 16px; margin: 40px auto; }
.messages-loading span { height: 64px; border-radius: 12px; background: #f2f2f7; animation: skeleton 1.4s ease-in-out infinite alternate; }
.messages-loading span:nth-child(2) { width: 72%; }
.messages-loading span:nth-child(3) { width: 88%; }
@keyframes skeleton { from { opacity: .55; } to { opacity: 1; } }

.empty-state {
  display: flex;
  width: min(calc(100% - 40px), 720px);
  min-height: 100%;
  flex-direction: column;
  justify-content: center;
  padding: 56px 0 40px;
  margin: 0 auto;
}
.empty-signal { display: none; }
.empty-state h2 { max-width: 540px; margin: 0 0 10px; font-size: clamp(28px, 3vw, 36px); font-weight: 680; letter-spacing: -0.04em; line-height: 1.12; text-wrap: balance; }
.empty-state > p:not(.eyebrow) { max-width: 540px; margin: 0; color: var(--muted); font-size: 15px; }
.continue-chat { display: flex; width: min(100%,540px); min-height: 54px; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 14px; margin-top: 22px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); color: var(--text); cursor: pointer; text-align: left; transition: border-color 120ms ease, background-color 120ms ease; }
.continue-chat:hover { border-color: rgba(60,60,67,.3); background: #fafafa; }
.continue-chat span { color: var(--muted); font-size: 12px; }
.continue-chat strong { min-width: 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.starter-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); margin-top: 30px; overflow: hidden; border: 1px solid var(--border); border-radius: 18px; background: var(--canvas); }
.starter-grid.has-two-items { grid-template-columns: repeat(2,minmax(0,1fr)); }
.starter-grid.has-two-items .starter:nth-child(2) { border-right: 0; }
.starter { min-height: 104px; padding: 15px; border-right: 1px solid var(--border); background: transparent; cursor: pointer; text-align: left; transition: background-color 120ms ease, color 120ms ease; }
.starter:last-child { border-right: 0; }
.starter:hover { background: var(--surface); }
.starter span,
.starter strong { display: block; }
.starter span { margin-bottom: 14px; color: var(--accent-text); font-size: 11px; font-weight: 680; }
.starter strong { font-size: 14px; line-height: 1.35; }

.message-list { width: min(calc(100% - 40px), var(--message-max)); padding: 28px 0 44px; margin: 0 auto; }
.load-older { display: flex; margin: 0 auto 26px; }
.message { position: relative; margin-bottom: 26px; content-visibility: auto; contain-intrinsic-size: auto 132px; }
.message--user { display: flex; justify-content: flex-end; padding-left: 25%; }
.user-message-card { max-width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 18px 18px 6px 18px; background: #f5f5f7; color: var(--text); overflow-wrap: anywhere; white-space: pre-wrap; }
.message-attachment { display: flex; min-width: 0; align-items: center; gap: 8px; padding: 8px 9px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 12px; }
.message-attachment::before { color: var(--accent); content: "↗"; }
.message-attachment span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-media { width: min(100%,680px); margin: 10px 0 0; overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: var(--canvas); }
.message-media img,
.message-media video { display: block; width: 100%; height: auto; max-height: 640px; background: #f2f2f7; object-fit: contain; }
.message-media img { aspect-ratio: 1 / 1; }
.message-media video { aspect-ratio: 16 / 9; }
.message-media-footer { display: flex; min-width: 0; min-height: 48px; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px 8px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.message-media-footer span { min-width: 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.media-download { display: inline-flex; min-height: 36px; flex: 0 0 auto; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 12px; font-weight: 620; text-decoration: none; }
.media-download:hover { border-color: rgba(0,122,255,.42); background: #f8fbff; }

.message--assistant,
.message--run { padding-left: 24px; }
.message--assistant::before,
.message--run::before { position: absolute; top: 4px; bottom: 4px; left: 5px; width: 1px; border-radius: 1px; background: var(--border); content: ""; }
.message--assistant::after,
.message--run::after { position: absolute; top: 7px; left: 1px; width: 7px; height: 7px; border: 1.5px solid #8e8e93; border-radius: 50%; background: var(--surface); content: ""; }
.message--assistant.is-completed::after { border-color: var(--accent); background: var(--accent); }
.message--run.is-processing::before { background: var(--accent); }
.message--run.is-processing::after { border-color: var(--accent); background: var(--accent); animation: node-pulse 1.2s ease-in-out infinite; }
.message--run.is-failed::before { background: var(--danger); }
.message--run.is-failed::after { border-color: var(--danger); }
@keyframes node-pulse { 0%,100% { opacity: .45; } 50% { opacity: 1; } }

.assistant-content { color: var(--text); font-size: 16px; line-height: 1.72; overflow-wrap: anywhere; }
.assistant-content > :first-child { margin-top: 0; }
.assistant-content > :last-child { margin-bottom: 0; }
.assistant-content p { margin: 0 0 1em; }
.assistant-content ul,
.assistant-content ol { padding-left: 1.4em; }
.assistant-content code { padding: .1em .3em; border-radius: 5px; background: #f2f2f7; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .87em; }
.assistant-content pre { max-width: 100%; padding: 14px; overflow: auto; border: 1px solid var(--border); border-radius: 11px; background: #f7f7f9; white-space: pre; }
.assistant-content pre code { padding: 0; background: transparent; }
.message-meta,
.run-message-copy { color: var(--muted); font-size: 13px; }
.message-actions { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.message-action { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; gap: 6px; padding: 7px 9px; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.message-action:hover { background: var(--sidebar); color: var(--text); }
.message-action svg { width: 18px; height: 18px; }
.message-follow-up { padding-right: 11px; padding-left: 11px; border: 1px solid var(--border); color: var(--text); }
.message-follow-up:hover { border-color: rgba(60,60,67,.28); background: var(--surface); }
.run-error { padding: 12px 14px; border: 1px solid #f0ccc8; border-radius: 11px; background: var(--danger-soft); }
.run-error strong,
.run-error span { display: block; }
.run-error strong { color: var(--danger); }
.run-error span { margin-top: 4px; color: #72534f; font-size: 13px; }
.run-error .button { margin-top: 11px; }

/* Composer: one anchored lower work zone rather than a floating object. */
.composer-dock { position: relative; z-index: 4; grid-row: 4; padding: 10px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--control-surface); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.composer,
.run-status,
.disclaimer { width: min(100%, var(--composer-max)); margin-right: auto; margin-left: auto; }
.run-status { display: flex; min-height: 28px; align-items: center; gap: 8px; padding: 0 10px; color: var(--muted); font-size: 12px; }
.run-node { width: 7px; height: 7px; border: 1.5px solid #8e8e93; border-radius: 50%; }
.run-status.is-processing .run-node { border-color: var(--accent); background: var(--accent); animation: node-pulse 1.2s ease-in-out infinite; }
.run-status.is-error { color: var(--danger); }
.run-status.is-error .run-node { border-color: var(--danger); }

.guest-limit-callout {
  display: flex;
  width: min(100%, var(--composer-max));
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 10px 9px 14px;
  margin: 0 auto 8px;
  border: 1px solid rgba(0,122,255,.28);
  border-radius: 14px;
  background: var(--accent-soft);
}
.guest-limit-callout > span { display: grid; min-width: 0; gap: 1px; }
.guest-limit-callout strong { font-size: 13px; }
.guest-limit-callout small { color: #4d6782; font-size: 11px; line-height: 1.4; }
.guest-limit-callout .button { min-width: max-content; }

.composer {
  position: relative;
  display: grid;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(29,29,31,.04);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,122,255,.16); }
.composer.is-dragging { border-color: var(--accent); background: #f6faff; box-shadow: inset 0 0 0 1px var(--accent); }
.composer.is-busy { opacity: .78; }
.media-compose { padding: 4px 5px 10px; margin-bottom: 3px; border-bottom: 1px solid var(--border); }
.media-compose-header { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; }
.media-compose-header > div { display: grid; min-width: 0; gap: 1px; }
.media-compose-header span { color: var(--accent-text); font-size: 11px; font-weight: 680; }
.media-compose-header strong { overflow: hidden; font-size: 15px; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.media-compose-header .icon-button { width: 38px; min-width: 38px; height: 38px; background: #f2f2f7; }
.media-options { margin-top: 10px; }
.resolution-fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
.resolution-fieldset legend { padding: 0; margin-bottom: 6px; color: var(--muted); font-size: 11px; }
.resolution-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
.resolution-option { min-width: 0; min-height: 48px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); cursor: pointer; text-align: left; transition: border-color 120ms ease, background-color 120ms ease; }
.resolution-option:hover:not(:disabled) { border-color: rgba(0,122,255,.42); background: #f8fbff; }
.resolution-option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.resolution-option:disabled { cursor: not-allowed; opacity: .45; }
.resolution-option strong,
.resolution-option small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resolution-option strong { font-size: 13px; }
.resolution-option small { margin-top: 1px; color: var(--muted); font-size: 10px; }
.reference-control { margin-top: 8px; }
.reference-pick { display: flex; width: 100%; min-height: 48px; align-items: center; gap: 10px; padding: 7px 10px; border: 1px dashed rgba(60,60,67,.28); border-radius: 11px; background: #fafafa; cursor: pointer; text-align: left; transition: border-color 120ms ease, background-color 120ms ease; }
.reference-pick:hover { border-color: rgba(0,122,255,.42); background: #f8fbff; }
.reference-pick > span:first-child { display: grid; width: 28px; height: 28px; flex: 0 0 auto; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent-text); font-size: 17px; }
.reference-pick strong,
.reference-pick small,
.reference-preview strong,
.reference-preview small { display: block; }
.reference-pick strong { font-size: 12px; }
.reference-pick small,
.reference-preview small { color: var(--muted); font-size: 10px; }
.reference-preview { display: grid; min-width: 0; min-height: 48px; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 6px 7px 6px 10px; border: 1px solid var(--border); border-radius: 11px; background: #fafafa; }
.reference-preview > span { min-width: 0; }
.reference-preview strong,
.reference-preview small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-estimate { min-height: 18px; margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.media-estimate.is-unavailable { color: var(--danger); }
.composer textarea { width: 100%; min-height: 44px; max-height: 208px; padding: 9px; overflow-y: auto; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); line-height: 1.55; }
.composer textarea::placeholder { color: var(--muted); }
.composer textarea:focus-visible { box-shadow: none; }
.composer-actions { display: flex; min-width: 0; align-items: center; gap: 6px; }
.create-picker { position: relative; flex: 0 0 auto; }
.create-menu-toggle { transition: color 120ms ease, background-color 120ms ease, transform 120ms ease; }
.create-menu-toggle[aria-expanded="true"] { background: #e8e8ed; color: var(--text); transform: rotate(45deg); }
.create-menu { position: absolute; z-index: 10; bottom: calc(100% + 8px); left: 0; width: 248px; padding: 6px; border: 1px solid var(--border); border-radius: 15px; background: rgba(255,255,255,.96); box-shadow: 0 16px 44px rgba(0,0,0,.14); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.create-menu button { display: grid; width: 100%; min-height: 52px; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; background: transparent; cursor: pointer; text-align: left; }
.create-menu button:hover:not(:disabled),
.create-menu button:focus-visible { background: #f2f2f7; }
.create-menu button:disabled { cursor: not-allowed; opacity: .48; }
.create-menu-icon { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--accent-text); font-size: 15px; }
.create-menu strong,
.create-menu small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.create-menu strong { font-size: 13px; }
.create-menu small { color: var(--muted); font-size: 10px; }
.deep-control { display: inline-flex; min-height: 44px; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); cursor: pointer; font-size: 12px; }
.deep-control:has(input:checked) { border-color: rgba(0,122,255,.42); background: var(--accent-soft); color: var(--accent-text); }
.deep-control input { accent-color: var(--accent); }
.guest-usage-pill { display: inline-flex; min-height: 34px; flex: 0 0 auto; align-items: center; gap: 5px; padding: 5px 9px; border: 1px solid rgba(0,122,255,.25); border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); cursor: pointer; font-size: 11px; line-height: 1; }
.guest-usage-pill:hover { border-color: rgba(0,122,255,.45); background: #deedff; }
.guest-usage-pill span:first-child { font-weight: 720; font-variant-numeric: tabular-nums; }
.guest-usage-pill span:last-child { color: #4d6782; }
.composer-hint { min-width: 0; flex: 1; overflow: hidden; color: var(--muted); font-size: 12px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.send-button { display: inline-grid; width: 44px; min-width: 44px; height: 44px; margin-left: auto; place-items: center; border-radius: 11px; background: var(--accent); color: #fff; cursor: pointer; }
.send-button:hover:not(:disabled) { background: var(--accent-pressed); }
.send-button:disabled { cursor: not-allowed; opacity: .35; }

.attachment-preview { display: grid; min-width: 0; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 9px; padding: 8px 8px 9px; margin: 0 0 3px; border-bottom: 1px solid var(--border); }
.operation-estimate { padding: 8px 10px; margin: 0 0 3px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.attachment-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); }
.attachment-copy { display: flex; min-width: 0; flex-direction: column; }
.attachment-copy strong,
.attachment-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-copy strong { font-size: 13px; }
.attachment-copy span { color: var(--muted); font-size: 11px; }
.field-error { padding: 8px 10px; border: 1px solid #f2d0cd; border-radius: 9px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.disclaimer { padding-top: 6px; margin-bottom: 0; color: var(--muted); font-size: 12px; text-align: center; }

/* Account settings and subscription picker */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(29,29,31,.38); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.settings-dialog {
  width: min(calc(100% - 32px),680px);
  max-width: none;
  height: min(calc(100dvh - 32px),600px);
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0,0,0,.18);
}
.settings-dialog[open] { animation: dialog-in 140ms ease-out; }
.settings-shell { display: grid; width: 100%; height: 100%; grid-template-columns: 210px minmax(0,1fr); }
.settings-sidebar { position: relative; min-width: 0; padding: 70px 10px 12px; border-right: 1px solid var(--border); background: var(--canvas); }
.settings-close { position: absolute; top: 12px; left: 12px; width: 44px; height: 44px; background: rgba(60,60,67,.08); }
.settings-nav { display: grid; gap: 3px; }
.settings-tab { display: flex; width: 100%; min-height: 44px; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: transparent; color: #48484a; cursor: pointer; font-size: 14px; font-weight: 520; text-align: left; }
.settings-tab:hover { background: rgba(60,60,67,.06); }
.settings-tab.is-active { background: #e8e8ed; color: var(--text); font-weight: 640; }
.settings-panel { min-width: 0; overflow: auto; overscroll-behavior: contain; background: var(--surface); }
.settings-panel-header { position: sticky; z-index: 2; top: 0; display: flex; min-height: 88px; align-items: center; padding: 20px 24px 14px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.92); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.settings-panel-header h1 { margin: 1px 0 0; font-size: 22px; font-weight: 680; letter-spacing: -0.025em; }
.settings-content { padding: 22px 24px 34px; }
.settings-content .usage-stack { grid-template-columns: 1fr; }
.settings-lead { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.settings-primary-action { margin-top: 20px; }

.profile-identity { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 16px; padding: 8px 2px 22px; border-bottom: 1px solid var(--border); }
.profile-identity .avatar { width: 56px; height: 56px; border-radius: 16px; font-size: 15px; }
.profile-identity h2,
.profile-identity p { margin: 0; }
.profile-identity h2 { font-size: 19px; letter-spacing: -0.02em; }
.profile-identity p { color: var(--muted); font-size: 13px; }
.profile-section-title { margin: 26px 2px 10px; font-size: 14px; font-weight: 680; letter-spacing: -0.01em; }
.plan-badge { display: inline-flex; min-height: 28px; align-items: center; padding: 4px 8px; border: 1px solid rgba(0,122,255,.28); border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 650; }
.usage-stack { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 18px; background: var(--border); }
.usage-stack > .profile-meta-row { min-height: 50px; grid-column: 1/-1; padding: 11px 16px; border-bottom: 0; background: var(--surface); }
.usage-stack > .usage-card:only-of-type { grid-column: 1/-1; }
.usage-card { padding: 20px; border: 0; border-radius: 0; background: var(--surface); }
.usage-card.is-unavailable { border-style: dashed; }
.usage-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.usage-heading h3,
.usage-heading p { margin: 0; }
.usage-heading h3 { font-size: 14px; }
.usage-number { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.usage-rail { position: relative; height: 7px; margin: 13px 0 9px; overflow: hidden; border-radius: 5px; background: #e5e5ea; }
.usage-rail span { display: block; width: var(--usage,0%); height: 100%; border-radius: inherit; background: var(--accent); }
.usage-card[data-low="true"] .usage-rail span { background: var(--danger); }
.usage-reset,
.profile-note { margin: 0; color: var(--muted); font-size: 12px; }
.profile-meta { display: grid; gap: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); }
.profile-meta-row { display: flex; min-height: 52px; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.profile-meta-row:last-child { border-bottom: 0; }
.profile-meta-row strong { max-width: 58%; color: var(--text); text-align: right; }
.profile-telegram { padding: 16px; }
.profile-telegram .profile-meta-row { min-height: 0; padding: 0 0 12px; }
.profile-telegram .usage-reset { margin: 0 0 14px; }
.profile-telegram .usage-reset.is-error { color: var(--danger); }

.plan-picker-dialog { position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; padding: 0; margin: 0; overflow: hidden; border: 0; border-radius: 0; background: var(--canvas); }
.plan-picker-dialog::backdrop { background: var(--canvas); -webkit-backdrop-filter: none; backdrop-filter: none; }
.plan-picker-dialog[open] { animation: plan-picker-in 150ms ease-out; }
@keyframes plan-picker-in { from { opacity: 0; } to { opacity: 1; } }
.plan-picker-close { position: fixed; z-index: 3; top: 20px; right: 20px; width: 44px; height: 44px; background: rgba(60,60,67,.08); }
.plan-picker-scroll { width: 100%; height: 100%; padding: 54px 32px 48px; overflow: auto; overscroll-behavior: contain; }
.plan-picker-heading { width: min(100%,720px); margin: 0 auto 34px; text-align: center; }
.plan-picker-heading h1 { margin: 4px 0 10px; font-size: 32px; font-weight: 700; letter-spacing: -0.04em; }
.plan-picker-heading > p:last-child { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.plans-grid { display: grid; width: min(100%,1320px); grid-template-columns: repeat(4,minmax(0,1fr)); align-content: start; gap: 20px; margin: 0 auto; }
.plan-card { position: relative; display: flex; min-width: 0; flex-direction: column; padding: 24px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); transition: border-color 140ms ease-out, transform 140ms ease-out; }
.plan-card:hover { border-color: rgba(60,60,67,.32); transform: translateY(-1px); }
.plan-card:focus-within { box-shadow: var(--focus-ring); }
.plan-card.is-recommended { border-color: rgba(0,122,255,.5); box-shadow: 0 8px 26px rgba(0,122,255,.08); }
.plan-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.plan-card h2 { margin: 0; font-size: 23px; font-weight: 680; letter-spacing: -0.025em; }
.plan-recommended { display: inline-flex; min-height: 26px; align-items: center; padding: 4px 8px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 680; }
.plan-fit { min-height: 40px; margin: 13px 0 0; color: #48484a; font-size: 14px; font-weight: 620; line-height: 1.4; }
.plan-summary { min-height: 38px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.plan-price { margin: 22px 0 2px; font-size: 42px; font-weight: 720; font-variant-numeric: tabular-nums; letter-spacing: -0.045em; }
.plan-period,
.plan-note { margin: 0; color: var(--muted); font-size: 13px; }
.plan-actions { display: grid; gap: 8px; margin: 20px 0 0; }
.plan-resource { display: grid; gap: 12px; padding: 16px 0; margin: 18px 0 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.plan-resource div { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.plan-resource dt { color: var(--muted); font-size: 12px; line-height: 1.25; }
.plan-resource dt small { display: block; margin-top: 3px; color: #98989d; font-size: 10px; }
.plan-resource dd { margin: 0; color: var(--text); font-size: 15px; font-weight: 680; font-variant-numeric: tabular-nums; }
.plan-features { display: grid; gap: 12px; padding: 0; margin: 20px 0 0; list-style: none; }
.plan-features li { position: relative; padding-left: 19px; color: #48484a; font-size: 14px; line-height: 1.45; }
.plan-features li::before { position: absolute; top: .05em; left: 0; color: var(--muted); content: "✓"; font-size: 12px; }
.plans-footer { display: grid; width: min(100%,1320px); gap: 10px; justify-items: center; margin: 20px auto 0; }
.plans-footnote { max-width: 760px; margin: 0; color: var(--muted); font-size: 12px; text-align: center; }
.plans-legal-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; font-size: 12px; }
.plans-legal-links a { color: var(--muted); text-underline-offset: 3px; }
.plans-legal-links a:hover { color: var(--text); }
.billing-pending { grid-column: 1/-1; padding: 14px; border: 1px solid rgba(0,122,255,.28); border-radius: 14px; background: var(--accent-soft); }
.billing-pending p { margin: 0 0 10px; color: #365f8b; font-size: 13px; }

.confirm-dialog { width: min(calc(100% - 32px), 440px); max-width: none; padding: 0; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: 0 20px 54px rgba(29,29,31,.17); }
.confirm-dialog[open] { animation: dialog-in 140ms ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.confirm-dialog form { padding: 22px; }
.confirm-dialog h2 { margin: 0 0 8px; font-size: 20px; font-weight: 680; }
.confirm-dialog p { margin: 0 0 17px; color: var(--muted); font-size: 13px; }
.field { display: grid; gap: 7px; margin: 13px 0; color: #48484a; font-size: 13px; }
.field input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.field input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,122,255,.18); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 19px; }

.toast-region { position: fixed; z-index: 110; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); display: grid; width: min(calc(100% - 36px),360px); gap: 8px; pointer-events: none; }
.toast { padding: 11px 14px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); box-shadow: 0 10px 28px rgba(31,35,33,.13); color: var(--text); font-size: 13px; animation: toast-in 150ms ease-out; }
.toast.is-error { border-color: #f0cbc7; color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1050px) {
  :root { --sidebar-width: 248px; }
  .starter-grid { grid-template-columns: 1fr; }
  .starter-grid.has-two-items { grid-template-columns: 1fr; }
  .starter { min-height: 68px; border-right: 0; border-bottom: 1px solid var(--border); }
  .starter-grid.has-two-items .starter:nth-child(2) { border-bottom: 0; }
  .starter:last-child { border-bottom: 0; }
  .starter span { margin-bottom: 6px; }
  .plans-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 767px) {
  .button--small { min-height: 44px; }
  .auth-view { display: block; overflow: auto; }
  .auth-identity { min-height: 240px; padding: 22px; border-right: 0; border-bottom: 1px solid var(--border); }
  .auth-thesis { margin: 28px 0 12px; }
  .auth-thesis h1 { margin-bottom: 10px; font-size: 30px; }
  .auth-thesis > p:last-child { max-width: 100%; font-size: 15px; }
  .auth-capabilities { display: none; }
  .auth-panel { min-height: calc(100dvh - 240px); padding: 18px 14px calc(22px + env(safe-area-inset-bottom)); }
  .auth-card { padding: 22px; border-radius: 15px; box-shadow: none; }

  .app-shell { display: block; }
  .drawer-backdrop { position: fixed; z-index: 19; inset: 0; display: block; background: rgba(31,35,33,.32); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(88vw,340px); max-width: 100%; padding-top: calc(12px + env(safe-area-inset-top)); background: rgba(250,250,252,.94); transform: translateX(-102%); transition: transform 160ms ease-out; }
  .sidebar.is-open { transform: translateX(0); box-shadow: 14px 0 36px rgba(31,35,33,.13); }
  .sidebar-close,
  .sidebar-open { display: inline-flex; }
  .new-chat-button kbd { display: none; }
  .chat-actions summary { opacity: 1; }

  .workspace,
  .chat-view { width: 100%; height: 100vh; height: 100dvh; }
  .workspace-header { display: flex; min-height: 60px; padding: calc(5px + env(safe-area-inset-top)) 9px 5px; }
  .chat-heading { flex: 1 1 auto; }
  .chat-heading .eyebrow,
  .profile-pill > span:first-child { display: none; }
  .profile-pill { min-width: 44px; padding: 4px; border-color: transparent; }
  .guest-header-actions { flex: 0 0 auto; gap: 1px; }
  .guest-header-actions .text-button { padding-right: 6px; padding-left: 6px; }
  .guest-register-button { min-height: 44px; padding: 6px 9px; font-size: 12px; }
  .guest-register-full { display: none; }
  .guest-register-short { display: inline; }
  .network-banner { padding: 8px 13px; text-align: left; }

  .empty-state,
  .message-list { width: calc(100% - 30px); }
  .empty-state { justify-content: flex-start; padding-top: clamp(48px,11vh,88px); }
  .empty-state h2 { font-size: 28px; }
  .starter-grid { margin-top: 24px; }
  .starter { min-height: 62px; padding: 11px 12px; }
  .message-list { padding-top: 21px; }
  .message { margin-bottom: 23px; }
  .message--user { padding-left: 12%; }
  .message--assistant,
  .message--run { padding-left: 22px; }
  .assistant-content { font-size: 15px; line-height: 1.68; }

  .composer-dock { padding: 8px 9px calc(8px + env(safe-area-inset-bottom)); }
  .composer { border-radius: 14px; box-shadow: 0 1px 2px rgba(29,29,31,.04); }
  .composer-hint { display: none; }
  .guest-usage-pill { min-height: 44px; }
  .guest-usage-pill span:last-child { display: none; }
  .guest-limit-callout { align-items: stretch; flex-direction: column; gap: 8px; }
  .guest-limit-callout .button { width: 100%; }
  .deep-control span { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .disclaimer { padding-top: 5px; font-size: 12px; }

  .settings-dialog { width: calc(100% - 24px); height: calc(100dvh - 24px); }
  .settings-shell { grid-template-columns: 176px minmax(0,1fr); }
  .settings-sidebar { padding-right: 8px; padding-left: 8px; }
  .settings-tab { padding-right: 9px; padding-left: 9px; font-size: 13px; }
  .settings-panel-header { padding-right: 18px; padding-left: 18px; }
  .settings-content { padding: 20px 18px 30px; }
  .plan-picker-close { top: 10px; right: 10px; }
  .plan-picker-scroll { padding: calc(56px + env(safe-area-inset-top)) 15px calc(30px + env(safe-area-inset-bottom)); }
  .plan-picker-heading { margin-bottom: 24px; }
  .plan-picker-heading h1 { font-size: 27px; }
  .plans-grid { grid-template-columns: 1fr; }
  .plan-card { min-height: 0; padding: 22px; }
  .dialog-actions .button { flex: 1; }
  .toast-region { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }
}

@media (max-width: 390px) {
  .auth-card { padding: 19px; }
  .profile-identity,
  .usage-card,
  .plan-card { padding: 16px; }
  .message-action span { display: none; }
  .chat-heading { max-width: 82px; }
  .guest-header-actions .text-button { font-size: 12px; }
}

@media (max-width: 599px) {
  .settings-dialog { width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .settings-shell { display: grid; grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr); }
  .settings-sidebar { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .settings-close { position: static; grid-column: 1; }
  .settings-nav { display: flex; min-width: 0; grid-column: 2; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-tab { width: auto; min-width: max-content; min-height: 44px; padding: 8px 10px; }
  .settings-panel-header { min-height: 76px; padding: 14px 16px 12px; }
  .settings-content { padding: 18px 16px calc(32px + env(safe-area-inset-bottom)); }
}

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

@media (prefers-contrast: more) {
  :root { --muted: #48484a; --border: #8e8e93; }
  .composer,
  .plan-card,
  .usage-card,
  .starter,
  .profile-pill { border-color: #aeb5af; }
}
