@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/Geist-400.woff2") format("woff2");
}

@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("assets/Geist-500.woff2") format("woff2");
}

@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("assets/Geist-600.woff2") format("woff2");
}

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/Fraunces-400.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #000;
  --surface: #0d0d0d;
  --surface-raised: #171717;
  --surface-hover: #202020;
  --text: #f5f5f5;
  --text-secondary: #b8b8b8;
  --text-tertiary: #8e8e8e;
  --border: #292929;
  --border-bright: #3a3a3a;
  --focus: #fff;
  --danger: #e36b6b;
  --sidebar-width: 300px;
  --content-width: 760px;
  --header-height: 64px;
  --ease-exhale: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  height: 100%;
  background: var(--bg);
  font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-width: 280px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 68% -20%, rgba(255, 255, 255, 0.055), transparent 38rem),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

::selection {
  background: #fff;
  color: #000;
}

.sr-only {
  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;
  top: 0;
  left: 50%;
  z-index: 1000;
  padding: 10px 16px;
  border-radius: 999px;
  background: #fff;
  color: #000;
  font-size: 14px;
  font-weight: 600;
  transform: translate(-50%, calc(-100% - 10px));
  transition: transform 180ms ease;
}

.skip-link:focus {
  top: max(10px, env(safe-area-inset-top));
  transform: translate(-50%, 0);
}

.network-banner {
  position: fixed;
  inset: max(8px, env(safe-area-inset-top)) 50% auto auto;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 8px 12px;
  border: 1px solid var(--border-bright);
  border-radius: 999px;
  background: rgba(23, 23, 23, 0.94);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);
  color: var(--text-secondary);
  font-size: 12px;
  transform: translateX(50%);
  backdrop-filter: blur(18px);
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.boot-view {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: var(--bg);
  color: var(--text-tertiary);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.boot-mark {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 21px;
  background: var(--surface);
  animation: settle 1.8s var(--ease-exhale) infinite alternate;
}

.boot-mark img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

@keyframes settle {
  from { transform: scale(0.97); opacity: 0.7; }
  to { transform: scale(1); opacity: 1; }
}

.eyebrow {
  margin: 0;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
}

/* Authentication */

.auth-view {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  padding:
    max(40px, calc(env(safe-area-inset-top) + 24px))
    clamp(20px, 5vw, 72px)
    max(32px, calc(env(safe-area-inset-bottom) + 24px));
}

.auth-shell {
  width: min(100%, 420px);
  min-height: calc(100vh - 96px);
  min-height: calc(100dvh - 96px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-brand,
.sidebar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: flex-start;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.auth-brand {
  margin-bottom: clamp(48px, 10vh, 96px);
}

.auth-brand img,
.sidebar-brand img {
  object-fit: contain;
}

.auth-intro h1,
.empty-state h2 {
  margin: 12px 0 14px;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 400;
  letter-spacing: -0.035em;
}

.auth-intro h1 {
  max-width: 9ch;
  font-size: clamp(44px, 12vw, 64px);
  line-height: 0.98;
}

.auth-intro > p:last-child {
  max-width: 38ch;
  margin: 0;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 18px;
  margin-top: 42px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

label {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  caret-color: #fff;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

input {
  min-height: 50px;
  padding: 0 15px;
}

input:hover,
textarea:hover {
  border-color: var(--border-bright);
}

input:focus,
textarea:focus {
  border-color: #626262;
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.07);
}

input::placeholder,
textarea::placeholder {
  color: #707070;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 48px;
  border-radius: 999px;
  padding: 0 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: transform 160ms var(--ease-exhale), background 160ms ease, opacity 160ms ease;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #fff;
  background: #fff;
  color: #000;
}

.primary-button.small {
  justify-content: center;
}

.secondary-button {
  border: 1px solid var(--border-bright);
  background: var(--surface-raised);
  color: var(--text);
}

.danger-button {
  border: 1px solid rgba(227, 107, 107, 0.5);
  background: rgba(227, 107, 107, 0.13);
  color: #f39a9a;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.primary-button:hover {
  background: #e9e9e9;
}

.secondary-button:hover {
  background: var(--surface-hover);
}

.primary-button:active,
.secondary-button:active,
.danger-button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none !important;
}

.text-button {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
  text-decoration-color: #555;
  text-underline-offset: 0.22em;
}

.text-button.compact {
  min-height: 24px;
  font-size: 11px;
}

.auth-help {
  margin-top: 18px;
}

.forgot-panel {
  margin-top: 10px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
}

.forgot-panel > p {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.forgot-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.forgot-form .secondary-button {
  min-height: 50px;
  white-space: nowrap;
}

.forgot-panel .microcopy {
  margin: 12px 0 0;
  color: var(--text-tertiary);
  font-size: 11px;
}

.inline-notice {
  margin-top: 24px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.inline-notice.is-error {
  border-color: rgba(227, 107, 107, 0.4);
  color: #efadad;
}

.auth-footnote {
  margin: 42px 0 0;
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1.5;
}

.auth-footnote a {
  color: var(--text-secondary);
}

/* App shell */

.app-view {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  position: relative;
  z-index: 40;
  display: flex;
  min-width: 0;
  flex-direction: column;
  height: 100%;
  padding:
    max(14px, env(safe-area-inset-top))
    12px
    max(14px, env(safe-area-inset-bottom));
  border-right: 1px solid var(--border);
  background: rgba(10, 10, 10, 0.94);
  backdrop-filter: blur(28px);
}

.sidebar-top {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
}

.sidebar-brand img {
  width: 24px;
  height: 24px;
}

.new-conversation-button {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 11px;
  margin: 20px 0 24px;
  padding: 0 14px;
  border: 1px solid var(--border-bright);
  border-radius: 15px;
  background: var(--surface-raised);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease;
}

.new-conversation-button:hover {
  border-color: #555;
  background: var(--surface-hover);
}

.new-icon {
  font-size: 21px;
  font-weight: 300;
  line-height: 1;
}

.history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 8px;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 13px;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 15px;
  transition: background 160ms ease, color 160ms ease;
}

.icon-button:hover,
.icon-button[aria-expanded="true"] {
  background: var(--surface-hover);
  color: var(--text);
}

.icon-button.subtle {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 16px;
}

.menu-lines,
.menu-lines::before,
.menu-lines::after {
  display: block;
  width: 17px;
  height: 1px;
  border-radius: 999px;
  background: currentColor;
}

.menu-lines {
  position: relative;
}

.menu-lines::before,
.menu-lines::after {
  position: absolute;
  left: 0;
  content: "";
}

.menu-lines::before {
  top: -5px;
}

.menu-lines::after {
  top: 5px;
}

.conversation-history {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #353535 transparent;
}

.history-group + .history-group {
  margin-top: 18px;
}

.history-group-label {
  display: block;
  margin: 0 8px 6px;
  color: #6f6f6f;
  font-size: 10px;
  font-weight: 500;
}

.history-item {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}

.history-item:hover {
  background: #151515;
  color: var(--text);
}

.history-item[aria-current="page"] {
  background: var(--surface-hover);
  color: var(--text);
}

.history-item-title {
  min-width: 0;
  overflow: hidden;
  flex: 1;
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-loading {
  display: grid;
  gap: 9px;
  padding: 4px 8px;
}

.skeleton {
  display: block;
  width: 92%;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #151515, #222, #151515);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease infinite;
}

.skeleton.short {
  width: 62%;
}

@keyframes skeleton {
  to { background-position: -200% 0; }
}

.history-empty {
  padding: 4px 8px;
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.45;
}

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

.settings-button {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 11px;
  text-align: left;
}

.settings-button:hover {
  border-color: var(--border-bright);
  background: var(--surface-raised);
  color: var(--text);
}

.connection-status {
  overflow: hidden;
  color: var(--text-tertiary);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-links {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
}

.sidebar-links a {
  color: var(--text-tertiary);
  font-size: 11px;
  text-decoration: none;
}

.sidebar-links a:hover {
  color: var(--text);
}

.sign-out-button {
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
}

.conversation-main {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: var(--header-height) minmax(0, 1fr) auto;
  background:
    radial-gradient(circle at 50% 115%, rgba(255, 255, 255, 0.025), transparent 35rem),
    transparent;
}

.conversation-header {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  min-height: var(--header-height);
  padding:
    env(safe-area-inset-top)
    clamp(20px, 3vw, 44px)
    0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(22px);
}

.conversation-heading {
  min-width: 0;
}

.conversation-heading h1 {
  max-width: min(65vw, 620px);
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-state {
  display: block;
  margin-top: 3px;
  color: var(--text-tertiary);
  font-size: 10px;
}

.conversation-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-link {
  min-height: 40px;
  padding: 0 12px;
  align-content: center;
  color: var(--text-secondary);
  font-size: 11px;
  text-decoration: none;
}

.app-link:hover {
  color: var(--text);
}

.menu-wrap {
  position: relative;
}

.conversation-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  min-width: 150px;
  padding: 5px;
  border: 1px solid var(--border-bright);
  border-radius: 14px;
  background: rgba(23, 23, 23, 0.98);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(22px);
}

.conversation-menu button {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}

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

.danger-text {
  color: var(--danger) !important;
}

.conversation-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 0 clamp(18px, 4vw, 52px);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #303030 transparent;
}

.empty-state {
  width: min(100%, 660px);
  margin: auto;
  padding: clamp(70px, 17vh, 180px) 0 64px;
  text-align: center;
}

.empty-state h2 {
  margin-top: 15px;
  font-size: clamp(38px, 6vw, 62px);
  line-height: 1.02;
}

.empty-copy {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.message-list {
  width: min(100%, var(--content-width));
  margin: 0 auto;
  padding: 36px 0 40px;
}

.message {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 14px;
  scroll-margin: 96px;
}

.message + .message {
  margin-top: 36px;
}

.message-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
}

.message.assistant .message-avatar img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.message-body {
  min-width: 0;
  padding-top: 4px;
}

.message-label {
  margin: 0 0 9px;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.message-copy {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 15px;
  line-height: 1.72;
  white-space: pre-wrap;
}

.message.user .message-copy {
  color: #e2e2e2;
}

.message-actions {
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  opacity: 0;
  transition: opacity 160ms ease;
}

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

.message-actions button {
  min-height: 32px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 11px;
}

.message-actions button:hover {
  color: var(--text);
}

.message-context {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 11px 0 0;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-tertiary);
  font-size: 9px;
  line-height: 1.3;
}

.message-context::before {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.message.is-streaming .message-copy::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 15px;
  margin-left: 3px;
  border-radius: 2px;
  background: #d7d7d7;
  vertical-align: -2px;
  animation: blink 0.95s steps(2, start) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.message-stopped {
  margin-top: 9px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-style: italic;
}

.message-loading {
  width: min(100%, var(--content-width));
  margin: 60px auto;
}

.message-loading span:not(.sr-only) {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: thinking 1.2s ease-in-out infinite;
}

.message-loading span:nth-child(2) { animation-delay: 120ms; }
.message-loading span:nth-child(3) { animation-delay: 240ms; }

@keyframes thinking {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.conversation-error {
  position: sticky;
  top: 18px;
  z-index: 10;
  display: flex;
  width: min(100%, var(--content-width));
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 18px auto 0;
  padding: 12px 14px;
  border: 1px solid rgba(227, 107, 107, 0.38);
  border-radius: 16px;
  background: rgba(30, 14, 14, 0.94);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(18px);
}

.conversation-error strong {
  font-size: 12px;
}

.conversation-error p {
  margin: 3px 0 0;
  color: #d4a4a4;
  font-size: 11px;
}

.compact-button {
  min-height: 38px;
  flex: 0 0 auto;
  padding: 0 13px;
  font-size: 11px;
}

.composer-region {
  position: relative;
  z-index: 12;
  padding:
    10px
    clamp(18px, 4vw, 52px)
    max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, #000 68%, rgba(0, 0, 0, 0));
}

.composer-form {
  width: min(100%, var(--content-width));
  margin: 0 auto;
  padding: 11px 11px 9px 17px;
  border: 1px solid var(--border-bright);
  border-radius: 22px;
  background: rgba(18, 18, 18, 0.96);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.45);
  transition: border-color 160ms ease, box-shadow 160ms ease;
  backdrop-filter: blur(24px);
}

.composer-form:focus-within {
  border-color: #555;
  box-shadow: 0 16px 55px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.035);
}

.composer-form textarea {
  display: block;
  max-height: 180px;
  min-height: 26px;
  resize: none;
  overflow-y: auto;
  padding: 1px 0 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 14px;
  line-height: 1.55;
}

.composer-form textarea:focus {
  border: 0;
  box-shadow: none;
}

.composer-controls {
  display: flex;
  min-height: 38px;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.composer-hint {
  align-self: center;
  margin-right: auto;
  color: #6f6f6f;
  font-size: 10px;
}

.send-button {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #fff;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  color: #000;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  transition: transform 160ms var(--ease-exhale), background 160ms ease;
}

.send-button:hover:not(:disabled) {
  background: #e8e8e8;
  transform: translateY(-1px);
}

.stop-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--border-bright);
  border-radius: 999px;
  background: var(--surface-hover);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 11px;
}

.stop-square {
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: currentColor;
}

.composer-note {
  width: min(100%, var(--content-width));
  margin: 7px auto 0;
  color: #696969;
  font-size: 10px;
  line-height: 1.45;
  text-align: center;
}

.rate-limit-notice {
  width: min(100%, var(--content-width));
  margin: 0 auto 8px;
  color: var(--text-secondary);
  font-size: 11px;
  text-align: center;
}

/* Dialogs and toast */

.dialog {
  width: min(calc(100vw - 32px), 430px);
  padding: 0;
  border: 1px solid var(--border-bright);
  border-radius: 24px;
  background: var(--surface-raised);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.72);
  color: var(--text);
}

.settings-dialog {
  max-height: min(760px, calc(100dvh - 32px));
  overflow: hidden;
}

.settings-dialog form {
  max-height: inherit;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(6px);
}

.dialog form {
  padding: 24px;
}

.dialog-heading {
  margin-bottom: 22px;
}

.dialog-heading h2 {
  margin: 9px 0 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.025em;
}

.dialog-heading p:last-child {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.settings-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.settings-heading .icon-button {
  margin: -8px -8px 0 0;
}

.dialog label {
  display: block;
  margin-bottom: 8px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.dialog-actions .primary-button {
  justify-content: center;
}

.form-error {
  margin-top: 10px;
  color: #efadad;
  font-size: 12px;
}

.settings-loading {
  display: grid;
  gap: 10px;
  padding: 4px 0 12px;
}

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

.settings-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.settings-section h3 {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.settings-section p {
  margin: 5px 0 0;
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1.5;
}

.setting-row,
.data-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 46px;
  height: 28px;
  flex: 0 0 auto;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border: 1px solid var(--border-bright);
  border-radius: 999px;
  background: #272727;
  transition: background 180ms ease, border-color 180ms ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #8a8a8a;
  content: "";
  transition: transform 220ms var(--ease-exhale), background 180ms ease;
}

.switch input:checked + .switch-track {
  border-color: #d4d4d4;
  background: #f2f2f2;
}

.switch input:checked + .switch-track::after {
  background: #111;
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.settings-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.settings-section-heading h3 {
  margin-top: 7px;
}

.state-pill {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-tertiary);
  font-size: 9px;
}

.state-pill.is-connected {
  border-color: #505050;
  color: var(--text-secondary);
}

.settings-description {
  max-width: 46ch;
}

.scope-list {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 16px 0 0;
  padding: 0;
  border: 0;
}

.scope-list legend {
  margin-bottom: 9px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 500;
}

.scope-option {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  min-height: 60px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
}

.scope-option:hover {
  border-color: var(--border-bright);
}

.scope-option input,
.consent-row input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 2px 0 0;
  padding: 0;
  accent-color: #fff;
}

.scope-option strong {
  display: block;
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
}

.scope-option span span {
  display: block;
  margin-top: 4px;
  color: var(--text-tertiary);
  font-size: 10px;
  line-height: 1.45;
}

.consent-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.45;
  cursor: pointer;
}

.integration-actions {
  display: flex;
  gap: 9px;
  margin-top: 16px;
}

.integration-actions .primary-button,
.integration-actions .secondary-button {
  min-height: 42px;
  flex: 1;
  font-size: 11px;
}

.settings-section .microcopy {
  margin-top: 10px;
  font-size: 9px;
}

.quiet-setting {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 11px;
}

.memory-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-tertiary);
}

.danger-outline-button {
  min-height: 40px;
  flex: 0 0 auto;
  padding: 0 13px;
  border: 1px solid rgba(227, 107, 107, 0.38);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  color: #e69191;
  font-size: 10px;
}

.danger-outline-button:hover {
  background: rgba(227, 107, 107, 0.09);
}

.toast-region {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 1000;
  width: min(calc(100vw - 32px), 340px);
  pointer-events: none;
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--border-bright);
  border-radius: 15px;
  background: rgba(28, 28, 28, 0.96);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.58);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  animation: toast-in 280ms var(--ease-exhale);
  backdrop-filter: blur(22px);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

.mobile-only {
  display: none;
}

@media (max-width: 780px) {
  :root {
    --header-height: calc(58px + env(safe-area-inset-top));
  }

  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: inline-grid;
  }

  .app-view {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 330px);
    max-width: 100%;
    border-right-color: var(--border-bright);
    box-shadow: 20px 0 70px rgba(0, 0, 0, 0.62);
    transform: translateX(-105%);
    transition: transform 340ms var(--ease-exhale);
    visibility: hidden;
  }

  .sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(0, 0, 0, 0.66);
    backdrop-filter: blur(4px);
  }

  .conversation-main {
    height: 100vh;
    height: 100dvh;
  }

  .conversation-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px;
    padding: env(safe-area-inset-top) 8px 0;
  }

  .conversation-heading h1 {
    max-width: none;
    font-size: 12px;
  }

  .conversation-actions {
    gap: 0;
  }

  .conversation-scroll {
    padding: 0 16px;
  }

  .empty-state {
    padding-top: clamp(64px, 15vh, 130px);
  }

  .empty-state h2 {
    font-size: clamp(38px, 12vw, 52px);
  }

  .message-list {
    padding-top: 28px;
  }

  .message {
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 11px;
  }

  .message-avatar {
    width: 26px;
    height: 26px;
    border-radius: 9px;
  }

  .message-copy {
    font-size: 14px;
    line-height: 1.67;
  }

  .message + .message {
    margin-top: 30px;
  }

  .message-actions {
    opacity: 1;
  }

  .composer-region {
    padding-right: 10px;
    padding-left: 10px;
  }

  .composer-hint {
    display: none;
  }

  .composer-form {
    border-radius: 20px;
  }

  .composer-note {
    max-width: 36ch;
  }

  .conversation-error {
    top: 10px;
  }
}

@media (max-width: 430px) {
  .auth-view {
    padding-right: 20px;
    padding-left: 20px;
  }

  .auth-shell {
    min-height: calc(100dvh - 72px);
  }

  .auth-brand {
    margin-bottom: 52px;
  }

  .auth-intro h1 {
    font-size: clamp(42px, 14vw, 56px);
  }

  .forgot-form {
    grid-template-columns: 1fr;
  }

  .forgot-form .secondary-button {
    min-height: 46px;
  }

  .conversation-error {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .conversation-error .compact-button {
    width: 100%;
  }

  .dialog form {
    padding: 21px;
  }

  .setting-row,
  .data-setting {
    align-items: flex-start;
  }
}

@media (max-height: 680px) and (min-width: 781px) {
  .empty-state {
    padding-top: 62px;
  }

}

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

@media (forced-colors: active) {
  .send-button,
  .primary-button,
  .secondary-button,
  .danger-button,
  input,
  textarea {
    border: 1px solid ButtonText;
  }
}
