:root {
  color-scheme: dark;

  --bg: #0b0b0c;
  --bg-sidebar: #0d0d0f;
  --bg-panel: #121214;
  --bg-panel-2: #17171a;
  --bg-hover: #1b1b1f;
  --border: #26262b;
  --border-soft: #1c1c20;

  --text: #e9e9e6;
  --text-dim: #a4a4a1;
  --text-faint: #74747a;

  --accent: #fab283;
  --accent-strong: #ffcba6;
  --accent-dim: rgba(250, 178, 131, 0.13);

  --green: #8fd694;
  --red: #ff7b72;
  --yellow: #e3b341;
  --blue: #8cbcf5;

  --radius: 10px;
  --mono: "Cascadia Code", "Cascadia Mono", "JetBrains Mono", "SFMono-Regular",
    Consolas, "Liberation Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(1100px 520px at 72% -12%, rgba(250, 178, 131, 0.055), transparent 62%),
    radial-gradient(800px 400px at 8% 108%, rgba(140, 188, 245, 0.035), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(250, 178, 131, 0.28);
  color: #fff;
}

button,
input,
textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid rgba(250, 178, 131, 0.6);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
  pointer-events: none !important;
}

/* ---------- scrollbars ---------- */

* {
  scrollbar-width: thin;
  scrollbar-color: #2c2c31 transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #2a2a2f;
  border: 3px solid transparent;
  border-radius: 10px;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #3a3a41;
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ---------- layout ---------- */

.app {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

/* ---------- sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 14px 14px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 3px 6px 16px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid #302b27;
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(250, 178, 131, 0.16), rgba(250, 178, 131, 0.02)),
    #111113;
  color: var(--accent);
  font-size: 17px;
  line-height: 1;
}

.brand-title {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #f0f0ed;
}

.brand-sub {
  margin-top: 3px;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--text-faint);
}

.new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.new-chat span {
  color: var(--accent);
  font-size: 15px;
  line-height: 1;
}

.new-chat:hover {
  border-color: #463a32;
  background: var(--accent-dim);
  color: var(--text);
}

.sidebar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 6px 8px;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.18em;
}

.sidebar-label span {
  padding: 1px 5px;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  color: #77777c;
  letter-spacing: 0.06em;
}

.session-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px 8px;
}

.session-empty {
  padding: 14px 10px;
  color: var(--text-faint);
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

.session-item {
  position: relative;
  margin-bottom: 2px;
  padding: 9px 10px 8px 9px;
  border-left: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.session-item:hover {
  background: var(--bg-hover);
}

.session-item.active {
  background: var(--bg-panel-2);
  border-left-color: var(--accent);
}

.session-title {
  overflow: hidden;
  padding-right: 20px;
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-item.active .session-title {
  color: var(--text);
}

.session-meta {
  overflow: hidden;
  margin-top: 4px;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-delete {
  position: absolute;
  top: 6px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-faint);
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
}

.session-item:hover .session-delete,
.session-delete:focus-visible {
  opacity: 1;
}

.session-delete:hover {
  background: rgba(255, 123, 114, 0.12);
  color: var(--red);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

.ghost-btn {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.11em;
  text-align: left;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

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

.ghost-btn.danger:hover {
  border-color: rgba(255, 123, 114, 0.25);
  background: rgba(255, 123, 114, 0.08);
  color: var(--red);
}

/* ---------- main ---------- */

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

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 58px;
  padding: 0 18px 0 20px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 11, 12, 0.82);
  backdrop-filter: blur(10px);
}

.model-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 520px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}

.model-picker:hover,
.model-picker.open {
  border-color: var(--border);
  background: var(--bg-panel);
}

.model-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 9px rgba(143, 214, 148, 0.55);
}

.model-picker-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

#model-label {
  overflow: hidden;
  color: #f0f0ed;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-id {
  overflow: hidden;
  max-width: 400px;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.03em;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  margin-left: 2px;
  color: var(--text-faint);
  font-size: 9px;
}

.topbar-right {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
}

.balance-warning {
  padding: 4px 8px;
  border: 1px solid rgba(255, 123, 114, 0.4);
  border-radius: 999px;
  background: rgba(255, 123, 114, 0.08);
  color: #ffb4ad;
  font-size: 9px;
  letter-spacing: 0.1em;
  cursor: help;
  animation: softPulse 2.4s ease-in-out infinite;
}

.status-pill {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #101012;
  color: var(--text-faint);
  font-size: 8.5px;
  letter-spacing: 0.15em;
  transition: color 0.15s, border-color 0.15s;
}

.status-pill.ready {
  border-color: rgba(143, 214, 148, 0.28);
  color: var(--green);
}

.status-pill.working {
  border-color: rgba(250, 178, 131, 0.42);
  color: var(--accent);
  animation: softPulse 1.4s ease-in-out infinite;
}

.status-pill.error {
  border-color: rgba(255, 123, 114, 0.42);
  color: var(--red);
}

.key-status {
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.08em;
}

/* ---------- model menu ---------- */

.model-menu {
  position: absolute;
  top: 62px;
  left: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 330px));
  max-height: min(68vh, 600px);
  overflow: hidden;
  border: 1px solid #2d2d33;
  border-radius: 12px;
  background: #111113;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(18px);
  animation: menuIn 0.13s ease-out;
}

.model-menu-head {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
}

.model-search {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #0b0b0c;
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: border-color 0.12s;
}

.model-search::placeholder {
  color: #55555a;
}

.model-search:focus {
  border-color: #4b3d33;
}

.model-menu-count {
  flex: none;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.model-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
}

.model-group-label {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 10px 5px;
  background: #111113;
  color: var(--text-faint);
  font-size: 8.5px;
  letter-spacing: 0.18em;
}

.model-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 0.1s, border-color 0.1s;
}

.model-item:hover {
  background: var(--bg-hover);
}

.model-item.selected {
  border-color: rgba(250, 178, 131, 0.22);
  background: var(--accent-dim);
}

.model-item-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.model-item-name {
  overflow: hidden;
  color: #dededb;
  font-size: 12px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-item-id {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-badge {
  flex: none;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-faint);
  font-size: 8px;
  letter-spacing: 0.09em;
}

.model-badge.free {
  border-color: rgba(143, 214, 148, 0.28);
  color: var(--green);
}

.model-star {
  flex: none;
  color: var(--accent);
  font-size: 10px;
}

.model-check {
  flex: none;
  width: 12px;
  color: var(--accent);
  font-size: 11px;
  text-align: right;
}

.model-menu-empty {
  padding: 22px 14px;
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
}

/* ---------- chat ---------- */

.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 30px 24px 26px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px 20px 90px;
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}

.empty-logo {
  color: #d8d8d4;
  font-size: clamp(17px, 2vw, 22px);
  font-weight: 700;
  letter-spacing: 0.2em;
}

.empty-sub {
  margin-top: 7px;
  color: var(--text-faint);
  font-size: 10px;
  letter-spacing: 0.14em;
}

.empty-lines {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 34px;
  color: var(--text-dim);
  font-size: 11.5px;
  text-align: left;
}

.prompt {
  margin-right: 7px;
  color: var(--accent);
}

.empty-lines kbd {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-panel);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 10px;
}

.empty-hint {
  margin-top: 32px;
  color: #56565b;
  font-size: 9.5px;
  letter-spacing: 0.05em;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
}

.message {
  animation: fadeUp 0.18s ease-out;
}

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

.role {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.17em;
}

.role::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #55555a;
  content: "";
}

.message.user .role::before {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(250, 178, 131, 0.4);
}

.message.assistant .role::before {
  background: var(--green);
  box-shadow: 0 0 8px rgba(143, 214, 148, 0.35);
}

.message.error .role::before {
  background: var(--red);
}

.msg-model {
  padding: 1px 5px;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  color: #66666b;
  font-size: 8.5px;
  letter-spacing: 0.05em;
}

.msg-time {
  margin-left: auto;
  color: #66666c;
  font-size: 8.5px;
  letter-spacing: 0.05em;
}

.message.user .bubble {
  padding: 12px 14px;
  border: 1px solid #25252a;
  border-radius: 9px;
  background: #141416;
}

.user-text {
  color: #dededb;
  font-size: 12.5px;
  line-height: 1.68;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.attached-image {
  display: block;
  max-width: min(360px, 100%);
  max-height: 190px;
  border: 1px solid var(--border);
  border-radius: 7px;
  object-fit: cover;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #111113;
  color: var(--text-dim);
  font-size: 9.5px;
  letter-spacing: 0.03em;
}

.file-chip .chip-icon {
  color: var(--accent);
  font-size: 10px;
}

.file-chip .chip-name {
  overflow: hidden;
  max-width: 260px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip .chip-size {
  color: var(--text-faint);
  font-size: 8.5px;
}

.file-chip button {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1;
}

.file-chip button:hover {
  background: rgba(255, 123, 114, 0.12);
  color: var(--red);
}

/* ---------- file browser ---------- */

.file-browser-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.file-browser-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.file-browser-item:hover {
  background: var(--bg-hover);
}

.file-browser-item.selected {
  border-color: rgba(250, 178, 131, 0.22);
  background: var(--accent-dim);
}

.file-browser-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.file-browser-icon {
  flex: none;
  font-size: 14px;
  width: 20px;
  text-align: center;
}

.file-browser-item.is_dir .file-browser-icon {
  color: var(--accent);
}

.file-browser-item.is_file .file-browser-icon {
  color: #8c8c92;
}

.file-browser-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 11.5px;
}

.file-browser-item.selected .file-browser-name {
  color: var(--text);
}

.file-browser-size {
  flex: none;
  color: var(--text-faint);
  font-size: 9px;
  white-space: nowrap;
}

.file-browser-item.disabled .file-browser-name,
.file-browser-item.disabled .file-browser-size {
  color: #55555a;
}

/* ---------- api key form ---------- */

.api-key-form {
  margin-bottom: 10px;
}

.api-key-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.api-key-input-wrapper {
  display: flex;
  gap: 4px;
}

.api-key-input-wrapper input {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #0b0b0c;
  color: var(--text);
  font-size: 11.5px;
  outline: none;
  transition: border-color 0.12s;
}

.api-key-input-wrapper input:focus {
  border-color: #4b3d33;
}

.api-key-input-wrapper button {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #0b0b0c;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.api-key-input-wrapper button:hover {
  border-color: #4b3d33;
  color: var(--accent);
}

.api-key-hint {
  color: var(--text-faint);
  font-size: 9px;
}

.api-key-hint a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dotted;
}

.api-key-hint a:hover {
  color: var(--accent-strong);
}

/* ---------- markdown ---------- */

.md {
  color: #d6d6d3;
  font-size: 12.8px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.md > :first-child {
  margin-top: 0;
}

.md > :last-child {
  margin-bottom: 0;
}

.md p {
  margin: 0 0 12px;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  margin: 22px 0 10px;
  color: #f2f2ef;
  font-weight: 650;
  line-height: 1.35;
}

.md h1 {
  font-size: 17px;
}

.md h2 {
  font-size: 15.5px;
}

.md h3 {
  font-size: 14px;
}

.md h4 {
  font-size: 13px;
}

.md ul,
.md ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.md li {
  margin: 4px 0;
}

.md li::marker {
  color: #77777c;
}

.md strong {
  color: #f3f3f0;
  font-weight: 650;
}

.md em {
  color: #e2e2de;
}

.md a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.md a:hover {
  color: var(--accent-strong);
}

.md code {
  padding: 1px 5px;
  border: 1px solid #2a2a2f;
  border-radius: 4px;
  background: #1a1a1e;
  color: #f0c8a8;
  font-family: inherit;
  font-size: 11.4px;
}

.md pre {
  position: relative;
  margin: 0 0 14px;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid #232328;
  border-radius: 8px;
  background: #0d0d0f;
}

.md pre code {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  color: #cfcfcc;
  font-size: 11.4px;
  line-height: 1.65;
  white-space: pre;
}

.md pre .copy-code {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #17171a;
  color: var(--text-faint);
  font-family: inherit;
  font-size: 8.5px;
  letter-spacing: 0.08em;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s, border-color 0.12s;
}

.md pre:hover .copy-code,
.md pre .copy-code:focus-visible {
  opacity: 1;
}

.md pre .copy-code:hover {
  border-color: #453a32;
  color: var(--accent);
}

.md blockquote {
  margin: 0 0 12px;
  padding: 2px 0 2px 13px;
  border-left: 2px solid var(--accent);
  color: var(--text-dim);
}

.md hr {
  margin: 18px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.md table {
  width: 100%;
  margin: 0 0 14px;
  border-collapse: collapse;
  font-size: 11.3px;
}

.md th,
.md td {
  padding: 6px 9px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.md th {
  background: #17171a;
  color: #ecece9;
  font-weight: 600;
}

.md img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.reasoning {
  margin: 0 0 11px;
  padding: 7px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  background: #0e0e10;
}

.reasoning summary {
  color: var(--text-faint);
  font-size: 8.5px;
  letter-spacing: 0.15em;
  cursor: pointer;
  user-select: none;
}

.reasoning[open] summary {
  margin-bottom: 8px;
}

.reasoning-body {
  max-height: 260px;
  overflow-y: auto;
  color: #8c8c92;
  font-size: 11px;
  line-height: 1.62;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-error {
  margin-top: 9px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 123, 114, 0.28);
  border-radius: 7px;
  background: rgba(255, 123, 114, 0.06);
  color: #ffb4ad;
  font-size: 11.5px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.cursor {
  display: inline-block;
  width: 7px;
  height: 13px;
  margin-left: 3px;
  border-radius: 1px;
  background: var(--accent);
  vertical-align: -2px;
  animation: blink 1.05s steps(2, start) infinite;
}

/* ---------- composer ---------- */

.composer {
  flex: none;
  padding: 10px 24px 11px;
  border-top: 1px solid var(--border-soft);
  background: linear-gradient(to bottom, rgba(11, 11, 12, 0.55), #0b0b0c 38%);
}

.composer-box,
.composer-meta,
.attachments {
  width: 100%;
  max-width: 880px;
  margin-right: auto;
  margin-left: auto;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 7px;
  border: 1px solid #2a2a2f;
  border-radius: 10px;
  background: #121214;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer-box:focus-within {
  border-color: #4b3c31;
  box-shadow: 0 0 0 3px rgba(250, 178, 131, 0.07);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

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

#input {
  flex: 1;
  min-width: 0;
  min-height: 33px;
  max-height: 200px;
  padding: 7px 4px;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.55;
  outline: none;
}

#input::placeholder {
  color: #56565b;
}

.send-btn,
.stop-btn {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  transition: background 0.12s, color 0.12s, opacity 0.12s;
}

.send-btn {
  background: var(--accent);
  color: #241810;
}

.send-btn:hover {
  background: var(--accent-strong);
}

.send-btn:disabled {
  cursor: default;
  opacity: 0.4;
}

.stop-btn {
  border-color: rgba(255, 123, 114, 0.4);
  background: rgba(255, 123, 114, 0.12);
  color: var(--red);
}

.stop-btn:hover {
  background: rgba(255, 123, 114, 0.2);
}

.composer-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 7px 2px 0;
  color: #5d5d62;
  font-size: 8.5px;
  letter-spacing: 0.1em;
}

.composer-meta .api-label {
  margin-left: auto;
  color: #4a4a4f;
}

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 4, 5, 0.62);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.14s ease-out;
}

.modal-card {
  width: min(540px, 100%);
  padding: 18px;
  border: 1px solid #2d2d33;
  border-radius: 14px;
  background: #111113;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.65);
  animation: menuIn 0.15s ease-out;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 17px;
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.18em;
}

.modal-head .icon-btn {
  width: 28px;
  height: 28px;
  font-size: 17px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--text-faint);
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.field textarea,
.field input {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #0b0b0c;
  color: var(--text);
  font-size: 11.5px;
  letter-spacing: 0;
  text-transform: none;
  outline: none;
  transition: border-color 0.12s;
}

.field textarea {
  resize: vertical;
  line-height: 1.6;
}

.field textarea:focus,
.field input:focus {
  border-color: #4b3d33;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.modal-actions .ghost-btn {
  width: auto;
  padding: 8px 15px;
  border-color: var(--border);
  font-size: 9.5px;
  text-align: center;
}

.primary-btn {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--accent);
  color: #241810;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

/* ---------- toast / overlay ---------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  z-index: 300;
  max-width: min(620px, calc(100vw - 40px));
  padding: 10px 15px;
  border: 1px solid #33333a;
  border-radius: 8px;
  background: #17171a;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
  color: var(--text);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  transform: translateX(-50%);
  animation: toastIn 0.16s ease-out;
}

.toast.error {
  border-color: rgba(255, 123, 114, 0.4);
  color: #ffb4ad;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  background: rgba(5, 5, 6, 0.93);
  backdrop-filter: blur(5px);
}

.overlay-card {
  text-align: center;
}

.overlay-title {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.overlay-sub {
  margin-top: 9px;
  color: var(--text-faint);
  font-size: 10.5px;
  letter-spacing: 0.06em;
}

/* ---------- animations ---------- */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes blink {
  0%,
  45% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes softPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .app {
    grid-template-columns: 232px minmax(0, 1fr);
  }

  .model-id {
    max-width: 280px;
  }

  .chat {
    padding-right: 18px;
    padding-left: 18px;
  }

  .composer {
    padding-right: 18px;
    padding-left: 18px;
  }
}

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

  .sidebar {
    display: none;
  }

  .model-menu {
    left: 12px;
    width: calc(100vw - 24px);
  }

  .model-id,
  .key-status {
    display: none;
  }
}

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