:root {
  --bg: #1c1a19;
  --bg-2: #262321;
  --bg-3: #322d2a;
  --text: #ece6df;
  --muted: #a39b92;
  --accent: #f2a65a;
  --accent-2: #e07a3f;
  --user-bubble: #3a342f;
  --border: #3b3632;
  --radius: 14px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf6f1;
    --bg-2: #ffffff;
    --bg-3: #f0e9e1;
    --text: #241f1b;
    --muted: #6f665e;
    --user-bubble: #efe6dc;
    --border: #e2d9cf;
  }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
a { color: var(--accent); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Banner */
.typo-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 16px; background: var(--accent); color: #1c1a19;
  text-decoration: none; font-weight: 500; flex: none; text-align: center;
}
.typo-banner strong { font-weight: 700; }
.typo-banner:hover { background: #f6b76f; }
.typo-banner__arrow { font-weight: 700; }

/* Layout */
.app { display: flex; flex: 1; min-height: 0; }
.sidebar {
  display: none; width: 260px; flex: none; background: var(--bg-2);
  border-right: 1px solid var(--border); padding: 12px;
  flex-direction: column; overflow: auto;
}
@media (min-width: 900px) { .sidebar { display: flex; } }
.sidebar__section {
  color: var(--muted); font-size: 11px; margin: 16px 8px 4px;
  text-transform: uppercase; letter-spacing: .06em;
}
.sidebar__list { list-style: none; margin: 0; padding: 0; }
.sidebar__foot { margin-top: auto; padding-top: 12px; }

.btn {
  font: inherit; border: 1px solid var(--border); background: transparent;
  color: var(--text); border-radius: 10px; padding: 8px 12px; cursor: pointer;
  text-decoration: none; display: inline-block;
}
.btn:hover { background: var(--bg-3); }
.btn--ghost { width: 100%; text-align: left; }
.btn--plus {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1c1a19; border: 0; font-weight: 600; width: 100%;
}
.btn--plus:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); flex: none;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.model select {
  font: inherit; font-size: 14px; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; cursor: pointer;
}
.topbar__plus { width: auto; margin-left: auto; padding: 6px 12px; }

/* Chat */
.chat { flex: 1; overflow: auto; padding: 24px 16px; }
.empty { max-width: 760px; margin: 8vh auto 0; text-align: center; }
.empty__logo { font-size: 56px; line-height: 1; }
.empty__title { font-size: 26px; font-weight: 600; margin: 12px 0 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  font: inherit; font-size: 14px; background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text); padding: 10px 14px; border-radius: 999px; cursor: pointer;
}
.chip:hover { background: var(--bg-3); }

.messages { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg--user { justify-content: flex-end; }
.msg__avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--bg-3);
  display: grid; place-items: center; flex: none; font-size: 18px;
}
.msg__body { max-width: 85%; min-width: 0; }
.msg--user .msg__body {
  background: var(--user-bubble); padding: 10px 16px; border-radius: 18px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg__text { white-space: pre-wrap; overflow-wrap: anywhere; padding-top: 4px; }
.msg__img {
  display: block; max-width: 100%; height: auto; border-radius: 12px; margin-top: 10px;
  border: 1px solid var(--border); background: var(--bg-2);
}
.msg__caption { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.dym { margin: 8px 0 0; font-size: 14px; }
.actions { display: flex; gap: 2px; margin-top: 6px; }
.actions button {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 13px; padding: 4px 8px; border-radius: 6px;
}
.actions button:hover { background: var(--bg-3); color: var(--text); }
.thinking {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; margin: 4px 0 10px; font-size: 14px; color: var(--muted);
}
.thinking summary { cursor: pointer; color: var(--text); }
.thinking p { margin: 8px 0 0; white-space: pre-wrap; }
.typing { display: inline-flex; gap: 5px; padding: 12px 4px; }
.typing span {
  width: 7px; height: 7px; background: var(--muted); border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Composer */
.composer-wrap { padding: 8px 16px 0; flex: none; }
.composer {
  max-width: 760px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 24px;
  padding: 8px 8px 8px 18px;
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  flex: 1; background: none; border: 0; color: var(--text); font: inherit;
  resize: none; max-height: 160px; outline: none; padding: 8px 0; line-height: 1.4;
}
.composer textarea::placeholder { color: var(--muted); }
.composer__send {
  width: 36px; height: 36px; border-radius: 50%; border: 0; flex: none;
  background: var(--accent); color: #1c1a19; font-size: 18px; font-weight: 700; cursor: pointer;
}
.composer__send:disabled { opacity: .4; cursor: default; }
.disclaimer {
  text-align: center; color: var(--muted); font-size: 12px; margin: 8px auto 12px; max-width: 760px;
}

/* Modal */
.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 10; padding: 16px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.modal__card {
  position: relative; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px; width: 100%; max-width: 420px;
}
.modal__close {
  position: absolute; top: 10px; right: 12px; background: none; border: 0;
  color: var(--muted); font-size: 24px; cursor: pointer; line-height: 1;
}
.modal__card h2 { margin: 0 0 4px; }
.modal__price { font-size: 28px; font-weight: 700; margin: 0 0 16px; }
.modal__price span { font-size: 14px; color: var(--muted); font-weight: 400; }
.modal__features { margin: 0 0 20px; padding-left: 20px; }
.modal__features li { margin: 6px 0; }
.modal__result { margin: 12px 0 0; color: var(--accent); text-align: center; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--bg-3); color: var(--text); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; z-index: 20;
  pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* 404 */
.notfound { margin: auto; text-align: center; padding: 32px 16px; }
.notfound h1 { font-size: 32px; margin: 12px 0 8px; }

/* Sidebar history + mobile drawer */
.sidebar__nav { flex: 1; }
.sidebar__list button {
  all: unset; box-sizing: border-box; display: block; width: 100%;
  padding: 8px 10px; border-radius: 8px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; font-size: 14px; cursor: pointer;
}
.sidebar__list button:hover, .sidebar__list button:focus-visible { background: var(--bg-3); }
.sidebar__list button.is-active { background: var(--bg-3); font-weight: 600; }
.menu-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border: 1px solid var(--border); background: transparent; color: var(--text);
  border-radius: 8px; font-size: 18px; cursor: pointer; flex: none;
}
@media (min-width: 900px) { .menu-btn { display: none; } }
@media (max-width: 899px) {
  body.sidebar-open .sidebar {
    display: flex; position: fixed; top: 0; bottom: 0; left: 0; z-index: 30;
    width: min(300px, 85vw); box-shadow: 0 0 40px rgba(0, 0, 0, .5);
  }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 25; }
}
