html[data-scheme="dark"] {
  --bg: #0f1419;
  --surface: #1a222c;
  --surface2: #243040;
  --line: #2c3846;
  --text: #e8eef5;
  --muted: #8b9aab;
  --accent: #5b8def;
  --danger: #e05b5b;
  --alert-bg: #3a1f22;
  --alert-text: #ffd4d4;
  --btn-text: #fff;
  --modal-dim: rgba(0, 0, 0, .55);
}
html[data-scheme="light"] {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface2: #eef1f6;
  --line: #d5dbe6;
  --text: #1a2332;
  --muted: #5c6b7a;
  --accent: #2b6de0;
  --danger: #c0392b;
  --alert-bg: #fdecea;
  --alert-text: #8a1f18;
  --btn-text: #fff;
  --modal-dim: rgba(20, 30, 45, .35);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .75rem 1.1rem; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { color: inherit; font-weight: 700; }
.top nav { display: flex; gap: .6rem; align-items: center; }
.wrap { max-width: 980px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
h1 { margin: .2rem 0 1rem; font-size: 1.45rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.4rem; }
.login-card { max-width: 420px; margin: 3rem auto; }
.login-card label { display: block; margin: 0 0 .9rem; color: var(--muted); font-size: .9rem; }
.login-card input {
  display: block; width: 100%; margin-top: .35rem;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: .55rem .7rem; font: inherit;
}
.alert { background: var(--alert-bg); color: var(--alert-text); padding: .7rem .9rem; border-radius: 8px; margin: .8rem 0; }
.modal {
  position: fixed; inset: 0; background: var(--modal-dim); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.modal.hidden { display: none; }
.modal-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 1.3rem;
}
.modal-card h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
.btn {
  display: inline-block; border: 1px solid var(--line); background: var(--surface2); color: var(--text);
  border-radius: 8px; padding: .45rem .8rem; font: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--btn-text); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; text-align: center; }
.btn.small { padding: .25rem .5rem; font-size: .8rem; }
.inline { display: inline; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .8rem; list-style: none; padding: 0; }
.tile {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.4rem .8rem; text-align: center; color: inherit; font-size: 1.3rem; font-weight: 700;
}
.tile:hover { border-color: var(--accent); text-decoration: none; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; }
.chip {
  display: block; min-width: 3.2rem; text-align: center; padding: .55rem .8rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; color: inherit;
}
.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; justify-content: space-between; align-items: center; gap: .8rem;
  padding: .7rem 0; border-bottom: 1px solid var(--line);
}
.chats .chat-link { display: flex; flex-direction: column; gap: .15rem; color: inherit; flex: 1; }
.row-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .8rem; align-items: center; }
.search { display: flex; gap: .5rem; margin: 0 0 1rem; }
.search input {
  flex: 1; background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: .55rem .7rem; font: inherit;
}
.crumb { color: var(--muted); }
.chat-frame {
  width: 100%; min-height: 75vh; border: 1px solid var(--line); border-radius: 12px;
  background: #cdd8e0;
}
.actions { display: flex; gap: .4rem; flex-shrink: 0; }
@media (max-width: 640px) {
  .list li { flex-direction: column; align-items: flex-start; }
}
