:root {
  --panel: #f8f2e7;
  --panel-strong: #fffaf1;
  --ink: #2a241d;
  --muted: #7a6c5b;
  --line: rgba(67, 49, 32, .13);
  --red: #8d1e28;
  --red-dark: #64131a;
  --red-soft: #b94a52;
  --gold: #c7952e;
  --shadow: 0 18px 60px rgba(71, 47, 29, .14);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--red); }

.brand__mark {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #f0c449;
  color: #7c1a21;
  box-shadow: inset 0 0 0 2px rgba(93, 22, 27, .18);
}

.flash-stack {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 1000;
  width: min(460px, calc(100vw - 28px));
  transform: translateX(-50%);
}
.flash {
  padding: 11px 14px;
  border: 1px solid rgba(69, 45, 27, .14);
  border-radius: 12px;
  background: #fff8ec;
  box-shadow: 0 10px 32px rgba(57, 39, 27, .16);
  color: #554739;
  font-size: 13px;
}

.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% 12%, rgba(255,255,255,.44), transparent 24%),
    radial-gradient(circle at 88% 84%, rgba(141,30,40,.09), transparent 28%),
    linear-gradient(145deg, #d2c2aa, #ece2d3 52%, #c9bba6);
}
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}
.auth-card {
  width: min(100%, 430px);
  padding: 30px;
  border: 1px solid rgba(94, 63, 34, .16);
  border-radius: 22px;
  background: rgba(255,250,241,.96);
  box-shadow: var(--shadow);
}
.auth-card--wide { width: min(100%, 470px); }
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--red-dark);
  text-decoration: none;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .09em;
}
.auth-heading { margin: 27px 0 22px; }
.auth-heading h1 { margin: 4px 0 8px; font-size: clamp(28px, 5vw, 36px); line-height: 1.05; }
.auth-heading p { margin: 0; color: var(--muted); line-height: 1.5; font-size: 14px; }
.eyebrow { color: var(--red) !important; font-size: 11px !important; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.auth-form { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; }
.field > span { color: #594b3d; font-size: 12px; font-weight: 750; }
.field input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid rgba(84, 58, 35, .17);
  border-radius: 12px;
  outline: 0;
  background: #f3eadd;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.field input:focus {
  border-color: rgba(141,30,40,.55);
  background: #fffaf1;
  box-shadow: 0 0 0 3px rgba(141,30,40,.09);
}
.field-error { color: #a11d28; font-size: 11px; line-height: 1.35; }
.form-alert {
  padding: 10px 12px;
  border: 1px solid rgba(161,29,40,.16);
  border-radius: 10px;
  background: rgba(161,29,40,.07);
  color: #8c1b25;
  font-size: 12px;
  line-height: 1.4;
}
.primary-button {
  min-height: 46px;
  margin-top: 2px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #a12732, #801922);
  color: #fff8eb;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 7px 18px rgba(126,28,37,.22);
  transition: transform .15s ease, box-shadow .15s ease;
}
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 9px 22px rgba(126,28,37,.27); }
.auth-switch { margin: 22px 0 0; text-align: center; color: #756552; font-size: 13px; }
.auth-switch a { font-weight: 800; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.micro-copy { margin: 13px 0 0; text-align: center; color: #a08f79; font-size: 10px; }

.app-body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #d7c8b2;
}
.app-shell {
  display: grid;
  grid-template-columns: clamp(300px, 27vw, 420px) minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
}
.sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.sidebar__topbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: linear-gradient(180deg, #97252f, #7f1922);
  color: #fff7e9;
  border-bottom: 1px solid rgba(59, 9, 13, .28);
}
.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  cursor: pointer;
  transition: .16s ease;
}
.icon-button:hover:not(:disabled) { background: rgba(255,255,255,.1); }
.icon-button:disabled { opacity: .38; cursor: default; }
.menu-button span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 2px 0;
  border-radius: 999px;
  background: currentColor;
}
.brand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
  letter-spacing: .08em;
}
.brand__word { overflow: hidden; text-overflow: ellipsis; font-size: 16px; font-weight: 800; }
.compose-button { font-size: 21px; }
.search-wrap { padding: 12px 14px 9px; }
.search {
  height: 42px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(92, 64, 38, .1);
  border-radius: 12px;
  background: #e9dece;
  color: var(--muted);
}
.search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search--disabled { opacity: .72; }
.chat-list { min-height: 0; overflow-y: auto; }
.chat-list--empty { display: grid; place-items: center; padding: 24px; }
.chat-empty { max-width: 240px; text-align: center; color: #8a7964; }
.chat-empty__icon { width: 46px; height: 46px; display: grid; place-items: center; margin: 0 auto 13px; border-radius: 50%; background: #eadfce; color: #9c8870; font-size: 19px; }
.chat-empty strong { display: block; color: #675746; font-size: 14px; }
.chat-empty p { margin: 7px 0 0; line-height: 1.45; font-size: 12px; }
.sidebar__footer {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  color: #8a7964;
  font-size: 11px;
}
.account-mini { min-width: 0; display: flex; align-items: center; gap: 8px; }
.account-mini__avatar { width: 29px; height: 29px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--red-soft); color: white; font-size: 11px; font-weight: 800; }
.account-mini__name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #665746; font-weight: 700; }
.logout-form { margin-left: auto; }
.logout-form button, .footer-star { border: 0; background: transparent; cursor: pointer; }
.logout-form button { padding: 6px; color: #897561; font-size: 11px; }
.logout-form button:hover { color: var(--red); }
.footer-star { padding: 6px; color: #c79831; font-size: 14px; }
.conversation {
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #e7dbc9;
}
.wallpaper {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .15;
  background-image:
    radial-gradient(circle at 24px 24px, rgba(112,57,46,.55) 0 1px, transparent 1.5px),
    radial-gradient(circle at 74px 54px, rgba(112,57,46,.35) 0 1px, transparent 1.5px);
  background-size: 96px 86px;
}
.conversation--empty { display: grid; place-items: center; }
.conversation-empty {
  position: relative;
  z-index: 1;
  width: min(460px, calc(100% - 40px));
  padding: 30px;
  border: 1px solid rgba(94,63,34,.1);
  border-radius: 20px;
  background: rgba(255,250,241,.86);
  box-shadow: 0 10px 34px rgba(75,50,31,.07);
  text-align: center;
}
.conversation-empty__star { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 50%; background: #efc24a; color: var(--red-dark); font-size: 29px; box-shadow: inset 0 0 0 3px rgba(100,19,26,.1); }
.conversation-empty h1 { margin: 0; font-size: 25px; letter-spacing: .025em; }
.conversation-empty p { margin: 9px 0 0; color: #756552; font-size: 13px; line-height: 1.5; }
.conversation-empty small { display: block; margin-top: 18px; color: #a19079; font-size: 10px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 1000;
  transform: translate(-50%, 18px);
  max-width: min(90vw, 440px);
  padding: 10px 14px;
  border-radius: 12px;
  background: #3c332a;
  color: #fff5e6;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  font-size: 13px;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }


/* Stable sidebar footer */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.sidebar__footer {
  flex: 0 0 52px;
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 6px 10px 6px 12px;
  border-top: 1px solid var(--line);
  background: #191614;
  box-sizing: border-box;
}

.account-mini {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}

.account-mini__avatar {
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  min-height: 30px !important;
  max-width: 30px !important;
  max-height: 30px !important;
  object-fit: cover;
}

.account-mini__name {
  max-width: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer-star {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  flex: 0 0 auto;
}

.footer-star:hover {
  background: rgba(199, 152, 49, .08);
}

body:not([data-theme="dark"]) .sidebar__footer {
  background: #f7efe4;
}


/* Auth theme and multi-account mode controls. */
.auth-card {
  position: relative;
}

.auth-theme-toggle {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(84, 58, 35, .12);
  border-radius: 50%;
  background: rgba(255, 250, 241, .66);
  color: var(--muted);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.auth-theme-toggle:hover {
  border-color: rgba(141, 30, 40, .24);
  background: #fffaf1;
  color: var(--red);
}

.auth-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: -4px 0 18px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(86, 63, 42, .08);
}

.auth-mode-switch a {
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.auth-mode-switch a:hover {
  color: var(--ink);
}

.auth-mode-switch a.is-active {
  background: var(--panel-strong);
  color: var(--red);
  box-shadow: 0 2px 8px rgba(57, 39, 27, .08);
}
