@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root,
[data-theme="ram"] {
  --bg: #0f0a0e;
  --bg-elevated: #161018;
  --bg-surface: #1c141f;
  --bg-input: #231a28;
  --line: rgba(255, 220, 235, 0.08);
  --line-strong: rgba(255, 200, 225, 0.14);
  --text: #faf0f5;
  --text-soft: #b8a0ad;
  --text-muted: #7a6672;
  --accent: #ec4899;
  --accent-strong: #f9a8d4;
  --accent-dim: #9d4468;
  --accent-glow: rgba(236, 72, 153, 0.22);
  --user-bg: #2a1824;
  --assistant-bg: transparent;
  --assistant-surface: #1e141c;
  --sidebar-bg: #141018;
  --danger: #f08080;
  --danger-bg: #221818;
  --ok: #7eb892;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-compose: 0 0 0 1px var(--line), 0 16px 48px rgba(0, 0, 0, 0.5);
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --thread-max: 46rem;
  --bar-h: 3.25rem;
  --msg-gap: 1.5rem;
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

[data-theme="ram"] body {
  background-image:
    radial-gradient(ellipse 100% 70% at 50% -20%, rgba(236, 72, 153, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 50% at 100% 50%, rgba(120, 40, 80, 0.12), transparent 45%),
    radial-gradient(ellipse 50% 40% at 0% 80%, rgba(50, 20, 40, 0.22), transparent 50%);
}

kbd {
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--text-soft);
}

.hidden {
  display: none !important;
}

/* —— Auth gate —— */
.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.gate-panel {
  width: 100%;
  max-width: 440px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.gate-brand {
  padding: 32px 32px 0;
}

.gate-logo {
  display: block;
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  border-radius: 14px;
  object-fit: contain;
  box-shadow: var(--shadow-sm);
}

.gate-brand .mark {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
}

.gate-brand h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.gate-brand p {
  margin: 12px 0 0;
  color: var(--text-soft);
  font-size: 0.94rem;
  line-height: 1.6;
}

.gate-tabs {
  display: flex;
  margin: 24px 32px 0;
  gap: 4px;
  padding: 4px;
  background: var(--bg-input);
  border-radius: 10px;
}

.gate-tabs button {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.gate-tabs button.active {
  color: var(--text);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.gate-form {
  padding: 24px 32px 32px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.gate-form .submit {
  width: 100%;
  margin-top: 10px;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: #1a1510;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.gate-form .submit:hover {
  filter: brightness(1.06);
}

.gate-form .submit:active {
  transform: scale(0.99);
}

.gate-note {
  margin: 16px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.55;
  text-align: center;
}

.gate-error {
  min-height: 1.2em;
  margin-top: 12px;
  font-size: 0.86rem;
  color: var(--danger);
}

.field .optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}

.field-check {
  margin-bottom: 12px;
}

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-soft);
  cursor: pointer;
  line-height: 1.45;
}

.check-label input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.btn-text {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  border: none;
  background: none;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

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

.twofa-head {
  text-align: center;
  margin-bottom: 20px;
}

.twofa-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--accent-glow);
  border: 1px solid var(--line-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
}

.twofa-title {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.twofa-hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-soft);
  line-height: 1.55;
}

.twofa-step-label {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

#btn2faResend:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.twofa-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.twofa-tab {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg-input);
  color: var(--text-soft);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.twofa-tab.active {
  border-color: var(--accent-dim);
  color: var(--accent-strong);
  background: var(--accent-glow);
}

.twofa-tab:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.twofa-code-input {
  text-align: center;
  font-size: 1.35rem !important;
  letter-spacing: 0.35em;
  font-family: var(--mono);
}

.btn-passkey {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-passkey:hover {
  border-color: var(--accent-dim);
  background: var(--bg-input);
}

.security-status {
  font-size: 0.86rem;
  color: var(--text-soft);
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg-input);
  border: 1px solid var(--line);
}

.security-block {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.security-block:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.security-block-title {
  margin: 0 0 6px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent-strong);
}

.totp-qr {
  display: block;
  margin: 8px auto 12px;
  border-radius: 10px;
  background: #fff;
  padding: 8px;
}

.settings-passkey-btn {
  width: 100%;
  margin-top: 4px;
}

#inCode {
  font-family: var(--mono);
  font-size: 1.35rem;
  letter-spacing: 0.35em;
  text-align: center;
}

/* —— App shell —— */
.shell {
  height: 100%;
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 0;
}

.main-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg, var(--bg-elevated));
  border-right: 1px solid var(--line);
  min-height: 0;
}

.sidebar-head {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.sidebar-btn {
  width: 100%;
  justify-content: center;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-list-empty {
  margin: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chat-item:hover {
  background: var(--bg-input);
  color: var(--text);
}

.chat-item.active {
  background: var(--accent-glow);
  color: var(--text);
  border: 1px solid rgba(236, 72, 153, 0.28);
}

.chat-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-del {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
}

.chat-item-del:hover {
  background: rgba(240, 128, 128, 0.15);
  color: var(--danger);
}

.btn-primary {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: #1a1510;
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-menu {
  display: none;
  margin-right: 4px;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--bar-h);
  padding: 0 clamp(16px, 4vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgba(12, 11, 10, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.bar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
}

.logo-text {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
}

.logo-text > span {
  color: var(--accent-strong);
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.model-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-picker-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.model-picker select {
  padding: 8px 32px 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239a9188' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  min-width: 7.5rem;
  max-width: min(100%, 16rem);
}

.compose-foot .compose-model-picker {
  flex-shrink: 0;
  margin-right: 2px;
}

.compose-foot .compose-model-picker select {
  min-width: 10rem;
  max-width: min(42vw, 18rem);
  background-color: var(--bg-elevated);
}

.compose-foot .image-size-picker select {
  min-width: 11rem;
  max-width: min(48vw, 18rem);
  background-color: var(--bg-elevated);
}

.model-picker select:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.user-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-soft);
  font-family: var(--mono);
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  max-width: 11rem;
  overflow: hidden;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--line-strong);
}

#userTagName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-tag:has(#userTagName:empty) {
  display: none;
}

.avatar-editor {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.avatar-preview-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line-strong);
}

.avatar-preview.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  color: var(--accent-strong);
  font-size: 1.75rem;
  font-weight: 700;
}

.avatar-editor-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 160px;
}

.avatar-file-label {
  cursor: pointer;
  text-align: center;
}


.bar .btn,
.bar a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.bar .btn:hover,
.bar a.btn:hover {
  border-color: var(--line-strong);
  background: var(--bg-surface);
}

.bar .btn-ghost,
.bar a.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
}

.bar .btn-ghost:hover,
.bar a.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-input);
  border-color: var(--line);
}

.bar .btn-stop {
  border-color: rgba(240, 128, 128, 0.35);
  color: #f0a0a0;
  background: rgba(240, 128, 128, 0.08);
}

.queue-strip {
  padding: 10px clamp(16px, 4vw, 28px);
  font-size: 0.82rem;
  font-weight: 500;
  background: linear-gradient(90deg, rgba(236, 72, 153, 0.14), rgba(236, 72, 153, 0.04));
  border-bottom: 1px solid rgba(236, 72, 153, 0.22);
  color: var(--accent-strong);
  text-align: center;
}

.thread {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 24px clamp(16px, 4vw, 28px) 8px;
  scroll-behavior: smooth;
}

.thread-inner {
  max-width: var(--thread-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Welcome hero */
.welcome {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: min(52vh, 420px);
  padding: 24px 0 48px;
}

.welcome-inner {
  max-width: 36rem;
  text-align: center;
  padding: 0 12px;
}

.welcome-logo {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 24px;
  border-radius: 18px;
  object-fit: contain;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--line);
}

.welcome h2 {
  margin: 0 0 12px;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.welcome-lead {
  margin: 0 0 12px;
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.5;
}

.welcome-lead-sub {
  margin: 0 0 28px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.welcome-hints {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}

.welcome-hints li {
  font-size: 0.86rem;
  color: var(--text-soft);
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  line-height: 1.45;
}

.welcome-hints strong {
  display: block;
  color: var(--accent-strong);
  font-weight: 700;
  margin: 0 0 4px;
  font-size: 0.9rem;
}

.welcome-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.welcome-suggestions .suggestion {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--text-soft);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.1s;
}

.welcome-suggestions .suggestion:hover {
  color: var(--text);
  border-color: var(--accent-dim);
  background: var(--bg-surface);
  transform: translateY(-1px);
}

/* Messages — ChatGPT-style rows */
.thread-inner {
  padding-top: 8px;
  padding-bottom: 24px;
}

.bubble {
  max-width: var(--thread-max);
  width: 100%;
  margin: 0 auto var(--msg-gap);
  padding: 0;
  border: none;
  background: transparent;
  line-height: 1.65;
  font-size: 0.95rem;
  animation: bubble-in 0.2s ease-out;
}

.bubble-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.bubble-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.01em;
}

.bubble-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--line);
}

.bubble .body {
  min-height: 1.25em;
  overflow-wrap: anywhere;
  border-radius: var(--radius-lg);
  padding: 14px 18px;
}

.bubble.ram.typing .body {
  contain: layout style;
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.thread-inner .bubble.ram:not(:last-child) {
  animation: none;
}

.bubble.you .body {
  background: var(--user-bg);
  border: 1px solid var(--line);
  max-width: 92%;
  margin-left: auto;
}

.bubble.you .bubble-name {
  color: var(--text);
}

.bubble.ram .body {
  background: var(--assistant-surface);
  border: 1px solid var(--line);
}

.bubble.ram .bubble-name {
  color: var(--accent-strong);
}

[data-theme="ram"] .bubble.ram .body {
  border-left: 3px solid var(--accent-dim);
}

.bubble.ram.typing .body::after {
  content: " ▍";
  animation: caret 0.9s step-end infinite;
  color: var(--accent);
}

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

.bubble.fail .body {
  border-color: rgba(240, 128, 128, 0.35);
  background: var(--danger-bg);
  color: var(--danger);
}

.bubble pre {
  margin: 12px 0 0;
  padding: 14px 16px;
  background: #080807;
  border-radius: 10px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  border: 1px solid var(--line);
}

.bubble code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 5px;
}

/* Composer */
.compose {
  flex-shrink: 0;
  padding: 0 clamp(16px, 4vw, 28px) 20px;
  position: relative;
  z-index: 10;
}

.compose::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -56px;
  height: 56px;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}

.compose-wrap {
  max-width: var(--thread-max);
  margin: 0 auto;
}

.compose-box {
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  background: var(--bg-input);
  padding: 6px 8px;
  box-shadow: var(--shadow-compose);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.compose-box:focus-within {
  border-color: var(--accent-dim);
  box-shadow: var(--shadow-compose), 0 0 0 3px var(--accent-glow);
}

.compose textarea {
  width: 100%;
  min-height: 52px;
  max-height: 200px;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.98rem;
  line-height: 1.5;
  padding: 14px 16px 8px;
}

.compose textarea::placeholder {
  color: var(--text-muted);
}

.compose textarea:focus {
  outline: none;
}

.compose-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 10px;
  flex-wrap: wrap;
}

.compose-foot .tip {
  flex: 1;
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 0;
}

.compose-foot button {
  border: none;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.compose-foot .attach {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--line);
  padding: 8px 12px;
}

.compose-foot .attach:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.compose-foot .image-mode.active {
  color: var(--accent-strong);
  border-color: var(--accent-dim);
  background: var(--accent-glow);
}

.generated-image {
  display: block;
  width: min(512px, 100%);
  height: auto;
  margin-top: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.compose-foot .send {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: #1a1510;
  border-radius: 999px;
}

.compose-foot .send:hover:not(:disabled) {
  filter: brightness(1.08);
}

.compose-foot .send:active:not(:disabled) {
  transform: scale(0.98);
}

.compose-foot .send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.send-icon {
  display: none;
}

.compose-disclaimer {
  margin: 10px 0 0;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.attach-preview {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-soft);
  text-align: center;
}

.attach-preview img {
  display: block;
  max-height: 80px;
  margin: 8px auto 0;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
}

/* Settings modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: min(90vh, 720px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-soft);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  overflow-y: auto;
  padding: 18px 22px 24px;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section h3 {
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.settings-hint {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--text-soft);
  line-height: 1.55;
}

.settings-hint code {
  font-family: var(--mono);
  font-size: 0.8em;
  background: var(--bg-input);
  padding: 2px 5px;
  border-radius: 4px;
}

.settings-hint a {
  color: var(--accent-strong);
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.settings-section .field input[type="color"] {
  padding: 4px;
  height: 42px;
  cursor: pointer;
}

.settings-section .field input,
.settings-section .field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
}

.field-suffix {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.api-key-status {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  font-size: 0.86rem;
  color: var(--text-soft);
  line-height: 1.5;
}

.api-key-row {
  display: flex;
  gap: 8px;
}

.api-key-row input {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.settings-msg {
  min-height: 1.2em;
  margin-top: 8px;
  font-size: 0.86rem;
  color: var(--ok);
}

body.modal-open {
  overflow: hidden;
}

/* Classic — ChatGPT-style neutral dark */
[data-theme="classic"] {
  --bg: #212121;
  --bg-elevated: #171717;
  --bg-surface: #2f2f2f;
  --bg-input: #2f2f2f;
  --sidebar-bg: #171717;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #ececec;
  --text-soft: #b4b4b4;
  --text-muted: #8e8e8e;
  --accent: #10a37f;
  --accent-strong: #19c37d;
  --accent-dim: #0d8a6a;
  --accent-glow: rgba(16, 163, 127, 0.2);
  --user-bg: #303030;
  --assistant-surface: #2f2f2f;
  --shadow-compose: 0 0 0 1px var(--line), 0 8px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="classic"] body {
  background-image: none;
}

[data-theme="classic"] .bar {
  background: var(--bg);
  border-bottom-color: var(--line);
}

[data-theme="classic"] .bubble.ram .body {
  border-left: none;
}

/* Neutral dark */
[data-theme="dark"] {
  --bg: #0d0d0f;
  --bg-elevated: #161618;
  --bg-surface: #1c1c1f;
  --bg-input: #242428;
  --sidebar-bg: #121214;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4f5;
  --text-soft: #a1a1aa;
  --text-muted: #71717a;
  --accent: #8b5cf6;
  --accent-strong: #a78bfa;
  --accent-dim: #6d28d9;
  --accent-glow: rgba(139, 92, 246, 0.2);
  --user-bg: #27272a;
  --assistant-surface: #1c1c1f;
}

[data-theme="dark"] body {
  background-image: none;
}

[data-theme="dark"] .bubble.ram .body {
  border-left: none;
}

/* Light theme */
[data-theme="light"] {
  --bg: #f6f4f1;
  --bg-elevated: #ffffff;
  --bg-surface: #f0ece6;
  --bg-input: #ffffff;
  --sidebar-bg: #f0f0f0;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.12);
  --text: #1a1714;
  --text-soft: #5c564e;
  --text-muted: #8a837a;
  --accent: #a67c3d;
  --accent-strong: #c49a52;
  --accent-dim: #8a6530;
  --accent-glow: rgba(166, 124, 61, 0.15);
  --user-bg: #ebe6df;
  --assistant-surface: #ffffff;
  --danger: #c44;
  --danger-bg: #fdeeee;
  --shadow-compose: 0 0 0 1px var(--line), 0 12px 32px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 100% 70% at 50% -20%, rgba(166, 124, 61, 0.08), transparent 55%),
    radial-gradient(ellipse 60% 50% at 100% 50%, rgba(0, 0, 0, 0.03), transparent 45%);
}

[data-theme="light"] .bar {
  background: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .compose::before {
  background: linear-gradient(to bottom, transparent, var(--bg));
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(280px, 88vw);
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .btn-menu {
    display: inline-flex;
  }
}

@media (max-width: 720px) {
  .compose-foot .compose-model-picker .model-picker-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .compose-foot .compose-model-picker select {
    min-width: 8.5rem;
    max-width: 100%;
  }

  .bar {
    flex-wrap: wrap;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .bar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .user-tag {
    max-width: 6rem;
  }

  .compose-foot .compose-model-picker {
    order: 0;
    width: 100%;
  }

  .compose-foot .compose-model-picker select {
    width: 100%;
    max-width: 100%;
  }

  .compose-foot .attach {
    order: 1;
  }

  .compose-foot .tip {
    order: 3;
    width: 100%;
    text-align: center;
  }

  .compose-foot .send {
    order: 2;
    margin-left: auto;
  }

  .send-label {
    display: none;
  }

  .send-icon {
    display: block;
  }
}

@media (max-width: 480px) {
  .bar .btn-ghost:not(#btnOut) {
    padding: 8px 10px;
    font-size: 0.78rem;
  }
}
