:root {
  --bg: #f3efe6;
  --ink: #1a1f1c;
  --muted: #5c665e;
  --line: #ddd4c6;
  --card: #fffdf8;
  --deep: #17211d;
  --deep-soft: #24312b;
  --accent: #146b52;
  --accent-dark: #0e5340;
  --danger: #9c3418;
  --shadow: 0 18px 50px rgba(28, 32, 27, 0.08);
  color-scheme: light;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body, #app { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

button, input, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.auth {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(320px, 0.9fr);
}

.auth-story {
  background:
    radial-gradient(circle at top left, rgba(116, 176, 148, 0.28), transparent 36%),
    var(--deep);
  color: #f6f3ec;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 48px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #e7f3ec;
  color: var(--deep);
  font-weight: 750;
}

.auth-story h1 {
  margin: 0 0 12px;
  font-size: clamp(36px, 4vw, 58px);
  line-height: 1.02;
  font-weight: 650;
  letter-spacing: -0.035em;
  max-width: 11ch;
}

.auth-story p {
  margin: 0;
  max-width: 38ch;
  color: #d5ddd6;
  font-size: 18px;
  line-height: 1.5;
}

.steps {
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #c9d5cc;
  font-size: 14px;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.steps span {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 12px;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 32px 24px;
}

.panel {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.lede {
  margin: 0 0 22px;
  color: var(--muted);
}

form { display: grid; gap: 14px; }

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 12px 12px;
}

textarea {
  min-height: 74px;
  resize: vertical;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--accent);
  color: white;
  font-weight: 650;
}

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

.btn:disabled { opacity: 0.65; cursor: wait; }

.btn.secondary, .btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.ghost { border-color: transparent; color: var(--muted); }

.switch {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.linkish {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.error {
  margin: 0;
  color: var(--danger);
  background: #fde8e1;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.app-frame {
  min-height: 100%;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidenav {
  background:
    radial-gradient(circle at top left, rgba(116, 176, 148, 0.22), transparent 42%),
    var(--deep);
  color: #f6f3ec;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidenav .brand { color: #f6f3ec; }

.sidenav-links { display: grid; gap: 4px; }

a.nav-link { display: block; text-decoration: none; }

.nav-link, .account-chip, .signout {
  width: 100%;
  text-align: left;
  border-radius: 12px;
}

.nav-link {
  border: 0;
  background: transparent;
  color: #d5ddd6;
  padding: 10px 12px;
  font-weight: 650;
}

.nav-link.active, .nav-link:hover { background: rgba(255, 255, 255, 0.1); color: white; }

.sidenav-foot { margin-top: auto; display: grid; gap: 10px; }

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  padding: 10px;
}

.account-meta { display: grid; min-width: 0; }
.account-meta strong, .account-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-meta small { color: #c9d5cc; font-size: 12px; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #e7f3ec;
  color: var(--deep);
  font-weight: 750;
  flex: none;
}

.avatar.large { width: 72px; height: 72px; font-size: 24px; }

.sidenav .signout {
  background: transparent;
  color: #f6f3ec;
  border-color: rgba(255, 255, 255, 0.18);
}

.stage {
  min-width: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.stage-page {
  width: min(1040px, calc(100% - 48px));
  margin: 28px auto 48px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head h1, .panel-block h2, .profile-card h2 {
  margin: 0;
  letter-spacing: -0.04em;
}

.page-head h1 { font-size: clamp(32px, 4vw, 44px); }

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 14px;
  margin: 18px 0 22px;
}

.stat, .panel-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.stat { padding: 18px 20px; }

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat strong { font-size: 34px; letter-spacing: -0.04em; }

.identity-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.identity-card div { flex: 1; min-width: 0; }
.identity-card strong, .identity-card small { display: block; }
.identity-card strong { font-size: 16px; }
.identity-card small { color: var(--muted); margin-top: 2px; }

.panel-block { padding: 18px; }

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.block-head span, .profile-card .email { color: var(--muted); }

.profile-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.profile-card { text-align: left; }
.profile-card h2 { margin: 14px 0 4px; }

.chat-list { display: grid; gap: 8px; }

.chat-row, .side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 8px 8px 8px 14px;
}

.chat-open, .side-chat {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 6px 0;
}

.chat-open { display: flex; justify-content: space-between; gap: 16px; align-items: center; }

.side-chat { display: flex; flex-direction: column; gap: 4px; }

.chat-row small, .side-chat small { color: var(--muted); }

.chat-row:hover, .side-item:hover { border-color: #b7c6b8; }

.side-item.active { border-color: var(--accent); background: #eef6f2; }

.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #f0c7bb;
  padding: 8px 10px;
}

.btn.danger:hover { background: #fde8e1; }

.notice {
  margin: 12px 0 0;
  color: var(--accent-dark);
  background: #e7f3ec;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.account-panel { margin-top: 12px; }

.form-actions, .confirm-delete { display: flex; gap: 8px; align-items: center; }

.empty {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 28px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.55);
}

.chat-screen {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  background: #f7f4ed;
}

.side-list {
  overflow: auto;
  display: grid;
  gap: 8px;
  align-content: start;
}

.side-chat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.thread {
  flex: 1;
  overflow: auto;
  padding: 28px 8vw 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bubble {
  max-width: 720px;
  border-radius: 16px;
  padding: 12px 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: var(--deep);
  color: #f6f3ec;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
}

.bubble header {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
  opacity: 0.7;
}

.composer {
  padding: 12px 8vw 22px;
}

.composer form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
}

.composer textarea {
  border: 0;
  min-height: 52px;
  padding: 8px;
  resize: none;
}

.composer textarea:focus { outline: none; }

@media (max-width: 980px) {
  .auth, .app-frame, .stat-grid, .profile-grid, .chat-screen, .composer form { grid-template-columns: 1fr; }
  .auth-story { padding: 28px 22px; gap: 24px; }
  .auth-story h1 { max-width: none; font-size: 40px; }
  .app-frame { display: flex; flex-direction: column; }
  .sidenav { flex-direction: row; align-items: center; gap: 12px; padding: 12px 14px; }
  .sidenav-links, .sidenav-foot { display: flex; align-items: center; gap: 6px; }
  .sidenav-foot { margin-top: 0; margin-left: auto; }
  .account-meta, .signout { display: none; }
  .nav-link { width: auto; padding: 8px 10px; }
  .stage-page { width: min(1040px, calc(100% - 28px)); margin-top: 20px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .identity-card { grid-column: 1 / -1; }
  .chat-screen { display: flex; flex-direction: column; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .side-list { max-height: 180px; }
  .thread, .composer { padding-left: 16px; padding-right: 16px; }
}
