:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", sans-serif;
  color: #ececf1;
  background: #101114;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --surface: #18191d;
  --surface-hover: #222328;
  --muted: #9698a3;
  --line: #292a30;
  --accent: #c9a7ff;
  --accent-strong: #a879f5;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 68% 0%, rgba(94, 58, 143, .12), transparent 34rem),
    #101114;
}

button, textarea, input { font: inherit; }
button { color: inherit; }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px 13px 12px;
  background: rgba(18, 19, 22, .97);
  border-right: 1px solid #25262b;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin: 1px 5px 24px;
  color: #f3f0f8;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.4px;
  text-decoration: none;
}

.brand strong { color: #c5a1ff; font-weight: 650; }

.brand-mark, .welcome-mark {
  display: grid;
  place-items: center;
  color: #1b1424;
  background: linear-gradient(145deg, #eadbff, #b78af2);
  box-shadow: 0 3px 14px rgba(183, 138, 242, .2);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 800;
}

.new-chat-button, .search-box {
  display: flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid #34353c;
  border-radius: 10px;
  background: transparent;
  color: #e8e7ed;
}

.new-chat-button {
  justify-content: flex-start;
  gap: 10px;
  padding: 0 12px;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}

.new-chat-button:hover { background: var(--surface-hover); border-color: #484951; }
.new-chat-button > span { color: var(--accent); font-size: 21px; line-height: 1; }

.search-box {
  gap: 8px;
  margin-top: 15px;
  padding: 0 10px;
  color: var(--muted);
}

.search-box > span { font-size: 20px; }
.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #e8e7ed;
  font-size: 12px;
}

.search-box input::placeholder { color: #898b95; }
.search-box input:focus-visible { outline: 0; }
.search-box kbd {
  flex: 0 0 auto;
  color: #777984;
  font-size: 10px;
  white-space: nowrap;
}

.history-heading {
  margin: 27px 9px 9px;
  color: #858791;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  min-height: 0;
}

.conversation-item {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 37px;
  border-radius: 8px;
  color: #c7c7cf;
}

.conversation-item:hover, .conversation-item.active { background: #25262b; }
.conversation-open {
  flex: 1;
  min-width: 0;
  padding: 9px 9px;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 12px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.conversation-actions {
  display: flex;
  padding-right: 4px;
  opacity: 0;
}

.conversation-item:hover .conversation-actions,
.conversation-item:focus-within .conversation-actions,
.conversation-item.active .conversation-actions { opacity: 1; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #a8a9b2;
  cursor: pointer;
}

.icon-button:hover { background: #32333a; color: #fff; }
.history-action { width: 24px; height: 25px; font-size: 15px; }

.empty-history {
  margin: 4px 9px;
  color: #777984;
  font-size: 12px;
  line-height: 1.5;
}

.sidebar-bottom { margin-top: auto; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 9px 13px;
  color: #b7b8c0;
  font-size: 12px;
  text-decoration: none;
}

.sidebar-link:hover { color: white; }
.sidebar-link span { color: var(--accent); }

.account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 5px 3px;
  border-top: 1px solid #292a30;
}

.account-avatar, .message-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
}

.account-avatar {
  width: 31px;
  height: 31px;
  background: #36303e;
  color: #d7bcff;
  font-size: 13px;
  font-weight: 700;
}

.account-label { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.account-label strong { color: #e4e3e9; font-size: 11px; font-weight: 600; }
.account-label span { color: #8d8e98; font-size: 10px; }
.logout-button { font-size: 17px; }

.main-panel {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 27px;
  border-bottom: 1px solid rgba(47, 48, 55, .65);
}

.model-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #b7b8c1;
  font-size: 11px;
}

.status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #777984;
  box-shadow: 0 0 0 3px rgba(119, 121, 132, .1);
}

.status-indicator.online {
  background: #67d6a5;
  box-shadow: 0 0 0 3px rgba(103, 214, 165, .12);
}

.topbar-label { color: #777984; font-size: 11px; }
.mobile-menu { display: none; }

.chat-scroll {
  width: 100%;
  overflow-y: auto;
  padding: 24px 24px 32px;
  scroll-behavior: smooth;
}

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(660px, 100%);
  margin: clamp(42px, 12vh, 118px) auto 34px;
  text-align: center;
  animation: rise-in .45s ease both;
}

.welcome-mark {
  width: 48px;
  height: 48px;
  margin-bottom: 22px;
  border-radius: 16px;
  font-size: 25px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #b59cda;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
}

.welcome h1, .login-card h1 {
  margin: 0;
  color: #f0eef4;
  font-size: clamp(25px, 3.2vw, 35px);
  font-weight: 590;
  letter-spacing: -1.2px;
}

.welcome-copy {
  margin: 13px 0 28px;
  color: #a2a3ad;
  font-size: 13px;
  line-height: 1.6;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.suggestions button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 58px;
  padding: 12px;
  border: 1px solid #303138;
  border-radius: 12px;
  background: rgba(26, 27, 31, .75);
  color: #c9c8d0;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.suggestions button:hover {
  transform: translateY(-2px);
  border-color: #5e4d73;
  background: #222127;
}

.suggestions button span { color: var(--accent); font-size: 17px; }

.message-row {
  display: flex;
  gap: 13px;
  width: min(780px, 100%);
  margin: 0 auto 28px;
  animation: rise-in .22s ease both;
}

.message-avatar {
  width: 29px;
  height: 29px;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
}

.message-avatar.assistant { background: #372d44; color: #d7baff; font-size: 14px; }
.message-avatar.user { background: #303138; color: #dedee4; font-size: 9px; }
.message-content { flex: 1; min-width: 0; }
.message-label { margin: 2px 0 7px; color: #e3e1e9; font-size: 12px; font-weight: 650; }
.message-text {
  color: #d0cfd6;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-row.user .message-text {
  display: inline-block;
  max-width: 100%;
  padding: 10px 13px;
  border: 1px solid #37343e;
  border-radius: 13px;
  background: #242328;
  color: #e7e5ec;
}

.composer-wrap {
  width: min(820px, calc(100% - 48px));
  margin: 0 auto;
  padding: 12px 0 17px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  min-height: 57px;
  padding: 8px 9px 8px 13px;
  border: 1px solid #393a42;
  border-radius: 17px;
  background: #1a1b20;
  box-shadow: 0 7px 28px rgba(0, 0, 0, .14);
  transition: border-color .18s ease, box-shadow .18s ease;
}

.composer:focus-within {
  border-color: #65527c;
  box-shadow: 0 0 0 3px rgba(185, 145, 239, .07);
}

.attach-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #b2b2bc;
  cursor: pointer;
  font-size: 22px;
  transition: background .15s ease;
}

.attach-button:hover { background: #2b2c33; color: white; }
.attach-button input { display: none; }

.composer textarea {
  flex: 1;
  min-width: 0;
  max-height: 180px;
  padding: 8px 2px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: #eeedf2;
  font-size: 13px;
  line-height: 1.5;
}

.composer textarea:focus-visible { outline: 0; }
.composer textarea::placeholder { color: #858691; }

.send-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(145deg, #d6bdff, #ad80ec);
  color: #211a2c;
  cursor: pointer;
  font-size: 22px;
  font-weight: 650;
  transition: opacity .16s ease, transform .16s ease;
}

.send-button:hover { transform: translateY(-1px); }
.send-button:disabled { opacity: .48; cursor: wait; }
.composer-hint { margin-top: 9px; color: #737580; font-size: 10px; text-align: center; }

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 25%, rgba(114, 75, 156, .19), transparent 35rem),
    #101114;
}

.login-card {
  width: min(420px, 100%);
  padding: 35px;
  border: 1px solid #303138;
  border-radius: 21px;
  background: rgba(24, 25, 29, .92);
  box-shadow: 0 20px 70px rgba(0, 0, 0, .3);
  animation: rise-in .4s ease both;
}

.login-brand { margin: 0 0 35px; }
.login-card .eyebrow { margin-bottom: 11px; }
.login-card h1 { font-size: 27px; letter-spacing: -.8px; }
.login-copy { margin: 10px 0 26px; color: #a2a3ad; font-size: 13px; line-height: 1.55; }

.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid #393a42;
  border-radius: 10px;
  color: #f0eef4;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background .18s ease, border-color .18s ease;
}

.google-button:hover { border-color: #676873; background: #222329; }
.google-mark { color: #a98be1; font-size: 17px; font-weight: 750; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 2px; color: #777984; font-size: 10px; }
.auth-divider::before, .auth-divider::after { height: 1px; flex: 1; background: #34353c; content: ""; }

.login-form { display: flex; flex-direction: column; }
.login-form label { margin: 14px 0 7px; color: #c6c5cc; font-size: 11px; font-weight: 600; }
.login-form input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #393a42;
  border-radius: 10px;
  background: #121317;
  color: #f0eef4;
  font-size: 13px;
}

.login-form input:focus { border-color: #8062a4; }
.login-form button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 45px;
  margin-top: 23px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(110deg, #d1b3ff, #a879e9);
  color: #21182c;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.login-form button:disabled { opacity: .6; cursor: wait; }
.login-form button span { font-size: 18px; }
.login-error { margin: 12px 0 0; color: #ff9a9a; font-size: 12px; line-height: 1.5; }
.login-error[hidden] { display: none; }
.form-message { margin: 13px 0 0; font-size: 12px; line-height: 1.55; }
.form-message.error { color: #ff9a9a; }
.form-message.success { color: #7ee0b6; }
.auth-switch {
  display: block;
  margin: 17px auto 0;
  padding: 4px;
  border: 0;
  background: transparent;
  color: #9c9da7;
  font-size: 11px;
  cursor: pointer;
}

.auth-switch strong { color: #d3b9fa; font-weight: 650; }
.auth-switch:hover strong { color: #eadbff; }
.login-footnote { margin: 22px 0 0; color: #777984; font-size: 10px; text-align: center; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    width: min(290px, calc(100vw - 56px));
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 20px 0 60px rgba(0, 0, 0, .35);
  }

  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .app-shell.sidebar-open::after {
    position: fixed;
    z-index: 10;
    inset: 0;
    background: rgba(0, 0, 0, .53);
    content: "";
  }

  .topbar { justify-content: flex-start; padding: 0 14px; }
  .mobile-menu { display: inline-grid; flex: 0 0 auto; }
  .topbar-label { margin-left: auto; }
  .chat-scroll { padding: 15px 17px 25px; }
  .welcome { margin-top: clamp(35px, 10vh, 85px); }
  .suggestions { grid-template-columns: 1fr; max-width: 420px; }
  .suggestions button { min-height: 46px; }
  .composer-wrap { width: calc(100% - 28px); padding-bottom: 11px; }
  .message-row { gap: 10px; margin-bottom: 22px; }
}

@media (max-width: 420px) {
  .login-card { padding: 27px 22px; }
  .topbar-label { display: none; }
  .welcome h1 { font-size: 27px; }
  .welcome-copy { max-width: 280px; }
  .message-text { font-size: 12px; }
}
