/* ==========================================================================
   ArtificialFriend — design system
   ========================================================================== */

:root {
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;

  --accent: #7c5cff;
  --accent-2: #ff5c8a;
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #a35cff 45%, #ff5c8a 100%);
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 60, 0.08);
  --shadow: 0 8px 24px rgba(20, 20, 60, 0.12);
  --shadow-lg: 0 18px 48px rgba(20, 20, 60, 0.22);

  --topbar-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ------------------------------- themes ------------------------------- */

html[data-theme='light'] {
  --bg: #eef0fa;
  --bg-grad: radial-gradient(1200px 600px at 85% -10%, #ffe4ee 0%, transparent 55%),
    radial-gradient(900px 520px at -10% 110%, #e6e2ff 0%, transparent 55%), var(--bg);
  --surface: #ffffff;
  --surface-2: #f6f6fc;
  --text: #191a2e;
  --muted: #6a6d8c;
  --line: rgba(25, 26, 46, 0.09);
  --bubble: #ffffff;
  --bubble-shadow: 0 2px 10px rgba(30, 30, 80, 0.07);
  --user-bubble: var(--accent-grad);
  --user-text: #ffffff;
  --hover: rgba(124, 92, 255, 0.09);
}

html[data-theme='dark'] {
  --bg: #0e0e20;
  --bg-grad: radial-gradient(1200px 600px at 85% -10%, #2a1650 0%, transparent 55%),
    radial-gradient(900px 520px at -10% 110%, #10265c 0%, transparent 55%), var(--bg);
  --surface: #191932;
  --surface-2: #20203e;
  --text: #eceafd;
  --muted: #9d9cc4;
  --line: rgba(236, 234, 253, 0.1);
  --bubble: #1f1f3c;
  --bubble-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  --user-bubble: var(--accent-grad);
  --user-text: #ffffff;
  --hover: rgba(124, 92, 255, 0.16);
}

/* -------------------------------- base --------------------------------- */

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body.modal-open {
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}

textarea {
  resize: none;
  line-height: 1.45;
}

::selection {
  background: rgba(124, 92, 255, 0.35);
}

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

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

#chatMain {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}

/* ------------------------------- topbar -------------------------------- */

#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  height: calc(var(--topbar-h) + var(--safe-top));
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-spacer {
  flex: 1;
}

.char-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  cursor: default;
  max-width: 46vw;
}

.chip-text {
  min-width: 0;
}

.chip-name {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cost-chip {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  transition: all 0.15s ease;
  font-variant-numeric: tabular-nums;
}

.cost-chip.has-cost {
  color: var(--accent);
  border-color: rgba(124, 92, 255, 0.4);
}

.cost-chip:hover {
  transform: translateY(-1px);
}

/* -------------------------------- icons -------------------------------- */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 19px;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
  flex: none;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
  transform: translateY(-1px);
}

.icon-btn.tiny {
  width: 26px;
  height: 26px;
  font-size: 13px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.msg:hover .icon-btn.tiny {
  opacity: 0.75;
}

.icon-btn.danger:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
}

/* ------------------------------- buttons ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 650;
  border-radius: 14px;
  padding: 11px 18px;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 10px 26px rgba(124, 92, 255, 0.45);
  transform: translateY(-1px);
}

.btn-soft {
  background: var(--hover);
  color: var(--accent);
}

.btn-soft:hover {
  background: rgba(124, 92, 255, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--line);
}

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

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.32);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 11px;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* -------------------------------- drawer ------------------------------- */

#drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(320px, 86vw);
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(-102%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 60;
  padding-top: var(--safe-top);
}

#drawer.open {
  transform: translateX(0);
}

#drawerScrim {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 24, 0.5);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 55;
}

#drawerScrim.show {
  opacity: 1;
  pointer-events: auto;
}

.drawer-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 18px 14px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.drawer-head h2 {
  font-size: 12.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.drawer-char-name {
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}

.drawer-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 2px;
}

.drawer-footnote {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  margin: 4px 2px 0;
}

.character-list,
.thread-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.char-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 14px;
  text-align: left;
  transition: background 0.15s ease;
  width: 100%;
}

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

.char-item.active {
  background: rgba(124, 92, 255, 0.16);
  box-shadow: inset 0 0 0 1.5px rgba(124, 92, 255, 0.4);
}

.char-item-name {
  font-weight: 650;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.char-item-badge {
  font-size: 13px;
  opacity: 0.85;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 13px;
  transition: background 0.15s ease;
}

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

.thread-item.active {
  background: rgba(124, 92, 255, 0.16);
}

.thread-item-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: 13px;
}

.thread-item-title {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item .icon-btn.tiny {
  opacity: 0.55;
}

/* ------------------------------- messages ------------------------------ */

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 6px 0;
  animation: msg-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.msg.user {
  flex-direction: row-reverse;
}

.avatar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.bubble-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(82%, 640px);
  min-width: 0;
}

.msg.user .bubble-col {
  align-items: flex-end;
}

.bubble {
  padding: 11px 15px;
  border-radius: var(--radius);
  background: var(--bubble);
  box-shadow: var(--bubble-shadow);
  line-height: 1.55;
  font-size: 15.5px;
  overflow-wrap: break-word;
  white-space: normal;
}

.msg.assistant .bubble {
  border-bottom-left-radius: 6px;
}

.msg.user .bubble {
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 6px;
}

.bubble p {
  margin: 0 0 8px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble pre {
  background: rgba(0, 0, 0, 0.28);
  padding: 10px 12px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13px;
  margin: 8px 0;
}

.msg.user .bubble pre {
  background: rgba(0, 0, 0, 0.22);
}

.bubble code {
  background: rgba(124, 92, 255, 0.16);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.88em;
}

.msg.user .bubble code {
  background: rgba(255, 255, 255, 0.2);
}

.bubble blockquote {
  margin: 8px 0;
  padding-left: 12px;
  border-left: 3px solid rgba(124, 92, 255, 0.6);
  opacity: 0.92;
}

.bubble ul {
  margin: 6px 0;
  padding-left: 20px;
}

.bubble .action {
  font-style: italic;
  opacity: 0.85;
}

.msg.user .bubble .action {
  opacity: 0.95;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: var(--muted);
  padding: 0 6px;
}

.msg-meta .badge {
  background: rgba(245, 158, 11, 0.18);
  color: var(--warn);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 700;
}

.msg-image {
  margin: 6px 0 0;
  max-width: min(82%, 480px);
}

.msg-image img {
  width: 100%;
  border-radius: var(--radius);
  border-bottom-right-radius: 6px;
  box-shadow: var(--bubble-shadow);
  display: block;
}

.msg-image figcaption {
  font-size: 11px;
  color: var(--muted);
  padding: 5px 6px 0;
}

.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  height: 18px;
}

.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing 1.2s infinite ease-in-out;
}

.typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing i:nth-child(3) {
  animation-delay: 0.3s;
}

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

.image-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.memory-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 11.5px;
  margin: 10px 0 14px;
}

.memory-divider::before,
.memory-divider::after {
  content: '';
  height: 1px;
  flex: 1;
  background: var(--line);
}

/* ------------------------------ empty states --------------------------- */

.empty-chat {
  margin: auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 22px;
  color: var(--muted);
  max-width: 420px;
}

.empty-chat h2 {
  margin: 0;
  color: var(--text);
  font-size: 21px;
}

.empty-chat p {
  margin: 0;
  line-height: 1.6;
  font-size: 14.5px;
}

.empty-emoji {
  font-size: 44px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 26px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

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

#composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 auto;
  width: 100%;
  max-width: 860px;
  padding: 10px 14px calc(12px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 65%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

#composerInput {
  flex: 1;
  min-height: 46px;
  max-height: 160px;
  border-radius: 23px;
  padding: 12px 18px;
  background: var(--surface-2);
  line-height: 1.45;
}

.art-btn {
  font-size: 21px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
}

.art-btn:hover {
  border-color: var(--accent-2);
  background: rgba(255, 92, 138, 0.12);
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(124, 92, 255, 0.4);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
  flex: none;
}

.send-btn:hover {
  transform: translateY(-1px) scale(1.04);
}

.send-btn.stop {
  background: var(--danger);
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.status-pill {
  align-self: center;
  margin: 0 auto 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 6px 14px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.status-pill.show {
  opacity: 1;
  transform: none;
}

/* -------------------------------- modals ------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 28, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.18s ease;
  padding: 0;
}

.modal-backdrop.open {
  opacity: 1;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 24px;
  }
}

.modal-panel {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(24px);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-backdrop.open .modal-panel {
  transform: none;
}

@media (min-width: 640px) {
  .modal-panel {
    border-radius: 24px;
    max-height: 86dvh;
  }
  .modal-sm {
    max-width: 420px;
  }
  .modal-md {
    max-width: 620px;
  }
  .modal-lg {
    max-width: 820px;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 10px;
}

.modal-header h2 {
  margin: 0;
  font-size: 19px;
}

.modal-body {
  padding: 6px 20px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px calc(18px + var(--safe-bottom));
  border-top: 1px solid var(--line);
}

.confirm-message {
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
  font-size: 14.5px;
}

/* --------------------------------- forms ------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-transform: uppercase;
}

.field-hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}

.field-hint.ok {
  color: var(--ok);
}

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

.inline-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-input input {
  flex: 1;
}

.prompt-toolbar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.section-title {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
  margin: 16px 0 0;
}

/* character manager rows */

.char-manager-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.char-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
}

.char-row-main {
  flex: 1;
  min-width: 0;
}

.char-row-name {
  font-weight: 700;
  font-size: 15.5px;
}

.char-row-sub {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.char-row-actions {
  display: flex;
  gap: 4px;
}

/* menu list (thread options) */

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item {
  text-align: left;
  padding: 13px 14px;
  border-radius: 13px;
  font-size: 14.5px;
  font-weight: 600;
  transition: background 0.14s ease;
}

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

.menu-item.danger {
  color: var(--danger);
}

/* toggles */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  padding: 6px 2px;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.toggle-track {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
  flex: none;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), background 0.18s ease;
}

.toggle-input:checked + .toggle-track {
  background: var(--accent-grad);
  border-color: transparent;
}

.toggle-input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
  background: #fff;
}

.toggle-label {
  font-size: 14px;
  font-weight: 600;
}

/* locked safety rules */

.locked-rules {
  background: var(--surface-2);
  border: 1.5px dashed rgba(124, 92, 255, 0.4);
  border-radius: 14px;
  padding: 14px;
  position: relative;
}

.locked-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.locked-rules pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 11.8px;
  line-height: 1.65;
  color: var(--muted);
}

/* usage table */

.usage-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.usage-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
  padding: 7px 12px;
  background: var(--surface-2);
  border-radius: 11px;
  font-variant-numeric: tabular-nums;
}

.usage-usd {
  font-weight: 700;
  color: var(--text);
  min-width: 62px;
  text-align: right;
}

/* -------------------------------- toasts ------------------------------- */

#toastRoot {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  width: min(92vw, 460px);
  pointer-events: none;
}

.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 18px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast-ok {
  border-color: rgba(34, 197, 94, 0.5);
}

.toast-warn {
  border-color: rgba(245, 158, 11, 0.55);
}

.toast-error {
  border-color: rgba(239, 68, 68, 0.55);
}

/* ------------------------------ scrollbar ------------------------------ */

#messages::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.drawer-scroll::-webkit-scrollbar {
  width: 8px;
}

#messages::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.drawer-scroll::-webkit-scrollbar-thumb {
  background: rgba(124, 92, 255, 0.28);
  border-radius: 999px;
}

/* ------------------------------ animation ------------------------------ */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
