/* =====================================================================
   Paimon GPT — style.css
   Satu font lokal (zh-cn.ttf), tema terang & gelap, layout responsif.
   ===================================================================== */

@font-face {
  font-family: "PaimonFont";
  src: url("./zh-cn.ttf") format("truetype");
  font-style: normal;
  font-weight: normal;
  font-display: swap;
}

/* ---------------------------------------------------------------
   Token warna
   --------------------------------------------------------------- */
:root {
  --bg: #ffffff;
  --sidebar-bg: #f7f7f8;
  --surface: #f4f4f5;
  --surface-hover: #ececee;
  --surface-active: #e4e4e7;
  --field-bg: #ffffff;
  --bubble-user: #f1f1f3;
  --bubble-user-text: #1f2023;
  --text: #1f2023;
  --text-2: #6b7076;
  --text-3: #9aa0a6;
  --border: #e6e7ea;
  --border-strong: #d5d7db;
  --danger: #d64545;
  --danger-soft: #fdecec;
  --ok: #1a8f68;
  --focus: #2f6df6;
  --code-bg: #f4f4f5;
  --overlay: rgba(20, 20, 22, 0.42);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.10);
  --radius: 14px;
  --sidebar-w: 200px;
  --header-h: 54px;
  --content-max: 760px;
}

[data-theme="dark"] {
  --bg: #212121;
  --sidebar-bg: #171717;
  --surface: #2f2f2f;
  --surface-hover: #3a3a3a;
  --surface-active: #454545;
  --field-bg: #2a2a2a;
  --bubble-user: #303030;
  --bubble-user-text: #f0f0f0;
  --text: #ececec;
  --text-2: #a6a6a6;
  --text-3: #7d7d7d;
  --border: #383838;
  --border-strong: #4a4a4a;
  --danger: #ff6b6b;
  --danger-soft: #3a2222;
  --ok: #4ecb9c;
  --focus: #6f9dff;
  --code-bg: #1b1b1b;
  --overlay: rgba(0, 0, 0, 0.62);
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
}

/* ---------------------------------------------------------------
   Dasar
   --------------------------------------------------------------- */
* { box-sizing: border-box; }

/* Elemen dengan atribut hidden harus benar-benar disembunyikan,
   termasuk elemen yang punya display sendiri (flex/inline-flex). */
[hidden] { display: none !important; }

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

body {
  font-family: "PaimonFont", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

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

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.ic {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: block;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------------------------------------------------------------
   Layar boot
   --------------------------------------------------------------- */
.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
}

.boot-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  object-fit: cover;
  background: var(--surface);
}

.boot-text { font-size: 14px; color: var(--text-2); }

/* ---------------------------------------------------------------
   Login PIN
   --------------------------------------------------------------- */
.login {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 16px;
  background: var(--bg);
  overflow-y: auto;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 30px 26px 22px;
  text-align: center;
}

.login-logo {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  object-fit: cover;
  background: var(--surface);
  margin-bottom: 14px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin: 0 0 4px;
}

.login-subtitle {
  font-size: 13.5px;
  color: var(--text-2);
  margin: 0 0 22px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.login-field { margin-bottom: 0; }

.login-field { margin-bottom: 0; }

.pin-input {
  letter-spacing: 8px;
  text-align: center;
  font-size: 20px;
  padding: 11px 12px;
}

.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  text-align: center;
}

.login-btn { width: 100%; padding: 11px 15px; font-size: 15px; }
.login-btn:disabled { opacity: .45; cursor: not-allowed; }

.login-foot {
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--text-3);
}

/* ---------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 8px 10px;
  overflow: hidden;
  z-index: 30;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 12px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface);
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  transition: background .12s ease;
}
.btn-new-chat:hover { background: var(--surface-hover); }
.btn-new-chat:active { background: var(--surface-active); }

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 16px 8px 6px;
}

.history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-bottom: 6px;
}

.history-empty {
  font-size: 12.5px;
  color: var(--text-3);
  padding: 4px 8px 10px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 9px;
  padding: 2px 4px 2px 8px;
  min-height: 34px;
}
.history-item:hover { background: var(--surface-hover); }
.history-item.active { background: var(--surface-active); }

.history-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: none;
  border: 0;
  padding: 6px 0;
  text-align: left;
}

.history-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .12s ease;
}
.history-item:hover .history-actions,
.history-item:focus-within .history-actions { opacity: 1; }

.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
}
.mini-btn:hover { background: var(--surface-active); color: var(--text); }
.mini-btn.danger:hover { color: var(--danger); }
.mini-btn .ic { width: 15px; height: 15px; }

.history-edit {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
}
.history-edit input {
  flex: 1;
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--field-bg);
  font-size: 13.5px;
}

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

.btn-side {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}
.btn-side:hover { background: var(--surface-hover); }
.btn-side .ic { width: 17px; height: 17px; color: var(--text-2); }
#resetBtn:hover { color: var(--danger); }
#resetBtn:hover .ic { color: var(--danger); }
#logoutBtn:hover .ic { color: var(--text); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 29;
}

/* ---------------------------------------------------------------
   Area utama
   --------------------------------------------------------------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.main-header {
  height: var(--header-h);
  flex: 0 0 var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.header-left, .header-right { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
}
.icon-btn:hover { background: var(--surface); color: var(--text); }

.header-menu-btn { display: none; }

.ic-sun, .ic-moon { display: none; }
[data-theme="light"] .theme-toggle .ic-moon { display: block; }
[data-theme="dark"] .theme-toggle .ic-sun { display: block; }

/* ---------------------------------------------------------------
   Halaman awal
   --------------------------------------------------------------- */
.chat-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.home {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.home-inner {
  /* margin:auto menjaga konten tetap terpusat dan tetap bisa di-scroll. */
  margin: auto;
  width: 100%;
  max-width: var(--content-max);
  padding: 16px 20px 8px;
  text-align: center;
}

.home-avatar {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  object-fit: cover;
  background: var(--surface);
  margin-bottom: 18px;
}

.home-title {
  font-size: 30px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0 0 8px;
  color: var(--text);
}

.home-subtitle {
  font-size: 15px;
  color: var(--text-2);
  margin: 0 0 30px;
}

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

.suggest-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  text-align: left;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text);
  transition: background .12s ease, border-color .12s ease;
}
.suggest-card:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.suggest-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .6px;
  color: var(--text-3);
}

.suggest-text {
  font-size: 14px;
  font-weight: 500;
}

/* ---------------------------------------------------------------
   Tampilan percakapan
   --------------------------------------------------------------- */
.messages-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.messages {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 18px 20px 10px;
}

.loader-batch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  font-size: 12.5px;
  color: var(--text-2);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--text-2);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.msg {
  display: flex;
  margin-bottom: 20px;
}
.msg-user { justify-content: flex-end; }
.msg-assistant { justify-content: flex-start; }

.msg-body {
  min-width: 0;
  font-size: 15px;
  font-weight: 400; /* teks biasa percakapan: tidak bold */
  line-height: 1.62;
}

.msg-user .msg-body {
  max-width: 78%;
  background: var(--bubble-user);
  color: var(--bubble-user-text);
  border-radius: 16px;
  padding: 9px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-assistant .msg-body {
  width: 100%;
  max-width: 100%;
  color: var(--text);
  overflow-wrap: anywhere;
}

.msg-assistant .msg-body p { margin: 0 0 10px; }
.msg-assistant .msg-body p:last-child { margin-bottom: 0; }
.msg-assistant .msg-body ul,
.msg-assistant .msg-body ol { margin: 0 0 10px; padding-left: 22px; }
.msg-assistant .msg-body li { margin: 2px 0; }
.msg-assistant .msg-body h1,
.msg-assistant .msg-body h2,
.msg-assistant .msg-body h3,
.msg-assistant .msg-body h4 { margin: 14px 0 8px; line-height: 1.3; font-weight: 700; }
.msg-assistant .msg-body h1 { font-size: 20px; }
.msg-assistant .msg-body h2 { font-size: 18px; }
.msg-assistant .msg-body h3 { font-size: 16.5px; }
.msg-assistant .msg-body h4 { font-size: 15.5px; }
.msg-assistant .msg-body blockquote {
  margin: 0 0 10px;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-2);
}
.msg-assistant .msg-body code {
  font-family: "PaimonFont", Consolas, monospace;
  font-size: 0.92em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}
.msg-assistant .msg-body pre {
  margin: 0 0 10px;
  padding: 11px 13px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}
.msg-assistant .msg-body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.55;
}
.msg-assistant .msg-body a { color: var(--focus); }

.msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity .12s ease;
}
.msg:hover .msg-actions,
.msg:focus-within .msg-actions { opacity: 1; }
.msg-user .msg-actions { justify-content: flex-end; }
.msg-assistant .msg-actions { justify-content: flex-start; }

.msg-edit-box { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.msg-edit-box textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--field-bg);
  line-height: 1.5;
}
.msg-edit-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
}

.thinking {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-2);
  font-size: 14.5px;
}
.thinking .dots { display: inline-flex; gap: 3px; }
.thinking .dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1.2s infinite ease-in-out;
}
.thinking .dots i:nth-child(2) { animation-delay: .18s; }
.thinking .dots i:nth-child(3) { animation-delay: .36s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .25; }
  40% { opacity: 1; }
}

.msg-note {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-3);
}

.msg-error {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
  border-radius: 12px;
  padding: 11px 13px;
  color: var(--danger);
  font-size: 13.5px;
}
.msg-error .ic { width: 16px; height: 16px; margin-top: 2px; }
.msg-error .err-text { flex: 1; min-width: 0; color: var(--text); }
.msg-error .err-text b { display: block; color: var(--danger); margin-bottom: 2px; }

.inline-btn {
  border: 1px solid var(--border-strong);
  background: var(--field-bg);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 500;
}
.inline-btn:hover { background: var(--surface-hover); }
.inline-btn.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.inline-btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* ---------------------------------------------------------------
   Composer
   --------------------------------------------------------------- */
.composer-wrap {
  flex: 0 0 auto;
  padding: 0 14px 12px;
  background: linear-gradient(to bottom, transparent, var(--bg) 40%);
}

.composer-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  margin: 0 0 6px;
  padding: 0 6px;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--field-bg);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 8px 8px 6px 12px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.composer:focus-within {
  border-color: var(--text-3);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}

.msg-input {
  width: 100%;
  border: 0;
  background: transparent;
  resize: none;
  outline: none;
  padding: 4px 2px;
  line-height: 1.5;
  max-height: 180px;
  overflow-y: auto;
  color: var(--text);
}
.msg-input::placeholder { color: var(--text-3); }

.composer-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
}

.char-counter {
  font-size: 11px;
  color: var(--text-3);
  padding-left: 2px;
  white-space: nowrap;
}
.char-counter.warn { color: var(--danger); }

.composer-spacer { flex: 1; }

.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
}
.send-btn:hover:not(:disabled) { opacity: .85; }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.send-btn .ic { width: 17px; height: 17px; }
#stopBtn { background: var(--surface-active); color: var(--text); }

/* ---------------------------------------------------------------
   Modal
   --------------------------------------------------------------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 60;
}
.modal-root[hidden] { display: none; }

.modal-layer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  background: var(--overlay);
  overflow-y: auto;
}

.modal {
  /* margin:auto -> terpusat saat ada ruang, tetap bisa di-scroll saat tinggi. */
  margin: auto;
  width: 100%;
  max-width: 460px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  animation: pop .13s ease-out;
}
.modal.wide { max-width: 580px; }
@keyframes pop {
  from { transform: translateY(6px) scale(.99); opacity: .6; }
  to { transform: none; opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; margin: 0; }

.modal-body {
  padding: 16px;
  overflow-y: auto;
  font-size: 14px;
}
.modal-body p { margin: 0 0 10px; }
.modal-body p:last-child { margin-bottom: 0; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 16px;
  border-top: 1px solid var(--border);
}

.btn {
  border: 1px solid var(--border-strong);
  background: var(--field-bg);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 15px;
  font-size: 13.5px;
  font-weight: 600;
}
.btn:hover { background: var(--surface-hover); }
.btn.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn.primary:hover { opacity: .88; background: var(--text); }
.btn.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn.danger:hover { opacity: .9; background: var(--danger); }
.btn.small { padding: 6px 11px; font-size: 12.5px; }

/* Form pengaturan */
.field { margin-bottom: 16px; }
.field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
}
.field .hint {
  font-size: 11.5px;
  color: var(--text-2);
  margin-top: 5px;
  line-height: 1.5;
}
.hint {
  font-size: 11.5px;
  color: var(--text-2);
  margin-top: 5px;
  line-height: 1.5;
}
.input, .textarea, .select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--field-bg);
  outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--focus); }
.textarea { resize: vertical; min-height: 150px; line-height: 1.5; }

.input-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.input-row .input { flex: 1; min-width: 0; }

.notice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.notice .ic { width: 15px; height: 15px; margin-top: 2px; flex: 0 0 auto; }

.settings-section {
  border-top: 1px solid var(--border);
  margin-top: 20px;
  padding-top: 18px;
}
.settings-section:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.section-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  margin: 0 0 12px;
}
.settings-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.test-result {
  font-size: 12.5px;
  margin-top: 8px;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: none;
}
.test-result.show { display: block; }
.test-result.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.test-result.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* ---------------------------------------------------------------
   Toast
   --------------------------------------------------------------- */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 460px);
}

.toast {
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  padding: 9px 15px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  animation: rise .16s ease-out;
  text-align: center;
  max-width: 100%;
}
.toast.err { background: var(--danger); color: #fff; }
@keyframes rise {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------------------------------------------------------------
   Scrollbar
   --------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------
   Responsif
   --------------------------------------------------------------- */
@media (max-width: 860px) {
  .home-title { font-size: 26px; }
  .home-avatar { width: 84px; height: 84px; }
}

@media (max-width: 760px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 82%;
    max-width: 300px;
    transform: translateX(-102%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; }
  .sidebar-backdrop[hidden] { display: none; }
  .header-menu-btn { display: inline-flex; }
  .suggest-grid { grid-template-columns: 1fr; }
  .msg-user .msg-body { max-width: 88%; }
  .msg-actions { opacity: 1; }
  .history-actions { opacity: 1; }
  .home-title { font-size: 23px; }
  .home-subtitle { font-size: 14px; margin-bottom: 22px; }
  .messages { padding: 14px 14px 8px; }
  .composer-wrap { padding: 0 10px 10px; }
}

@media (max-width: 420px) {
  .home-avatar { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 14px; }
  .home-title { font-size: 20px; }
  .modal { max-height: calc(100dvh - 24px); }
  .login-card { padding: 24px 18px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}