:root {
  --bg: #f3f5f8;
  --sidebar: #f6f7fb;
  --surface: #ffffff;
  --ink: #1b2230;
  --muted: #6d7689;
  --faint: #98a1b3;
  --line: #e6e8ef;
  --brand: #2f6bff;
  --brand-dark: #1e56ea;
  --brand-soft: #e8efff;
  --gold: #f5b400;
  --danger: #e11d48;
  --shadow: 0 10px 30px rgba(22, 34, 66, 0.06);
  --brand-1: #6aa4ff;
  --brand-2: #2f6bff;
  --brand-3: #1a3fbe;
  --radius: 14px;
  --sidebar-w: 248px;
  --list-w: 340px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0e1116;
  --sidebar: #12161d;
  --surface: #181d27;
  --ink: #eef2f8;
  --muted: #a3adbf;
  --faint: #7f8aa0;
  --line: #2a3142;
  --brand: #5b8cff;
  --brand-dark: #3d74f5;
  --brand-soft: #1b2b4e;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --brand-1: #2450c8;
  --brand-2: #17368f;
  --brand-3: #0b1b4a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: Outfit, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: -0.011em;
}

button, input, textarea { font-family: inherit; }

button { cursor: pointer; }

a { color: var(--brand); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.logo-mark {
  width: 64px;
  height: 64px;
  display: block;
  filter: drop-shadow(0 10px 18px rgba(18, 52, 160, 0.28));
}

.logo-mark.sm { width: 34px; height: 34px; filter: none; }
.logo-mark.lg { width: 92px; height: 92px; }

.wordmark,
.auth-title {
  margin: 14px 0 0;
  font-size: 34px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.045em;
  text-align: center;
}

.auth-lead {
  margin: 12px auto 0;
  max-width: 360px;
  text-align: center;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
  font-weight: 500;
}

.product {
  margin: 8px 0 0;
  text-align: center;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.48em;
  padding-left: 0.48em;
  color: var(--faint);
}

.brand .wordmark { color: #fff; font-size: 44px; margin-top: 18px; }
.brand .product { color: rgba(255, 255, 255, 0.82); font-size: 13px; }

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(90% 60% at 0% 0%, rgba(255, 255, 255, 0.2), transparent 46%),
    radial-gradient(80% 70% at 100% 100%, rgba(7, 20, 80, 0.38), transparent 52%),
    linear-gradient(155deg, var(--brand-1), var(--brand-2) 48%, var(--brand-3));
  color: #fff;
}

.brand-waves {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.brand-lockup { position: relative; z-index: 1; text-align: center; }

.auth-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  padding: 72px 28px 40px;
}

.auth-tools {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang {
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.lang button,
.icon-btn,
.tool-btn,
.nav-item,
.star,
.check,
.row {
  border: 0;
  background: transparent;
  color: inherit;
}

.lang button {
  min-width: 34px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.lang button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.icon-btn:hover,
.tool-btn:hover { background: var(--bg); color: var(--ink); }

.auth-card { width: min(420px, 100%); }

.auth-card .logo-mark { margin: 0 auto; }
.stack { display: grid; gap: 14px; margin-top: 28px; }

.field { position: relative; display: block; }

.field > .bi {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 16px;
  pointer-events: none;
}

.field input {
  width: 100%;
  height: 52px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 46px;
  font-size: 15px;
  outline: none;
}

.field input::placeholder { color: var(--faint); }

.field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(47, 107, 255, 0.14);
}

.eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--faint);
}

.eye:hover { color: var(--ink); }

.forgot {
  justify-self: end;
  margin-top: -4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.forgot:hover { color: var(--brand); }

.btn-go {
  height: 52px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 650;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 18px rgba(47, 107, 255, 0.28);
}

.btn-go:hover { background: var(--brand-dark); }

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.done { text-align: center; margin-top: 8px; }
.done-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 28px;
}
.done h2 { margin: 0 0 8px; font-size: 28px; letter-spacing: -0.04em; }
.done p { margin: 0 0 22px; color: var(--muted); line-height: 1.5; }
.done a { font-weight: 700; text-decoration: none; }

body[data-page="inbox"] { overflow: hidden; }

.shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  overflow: hidden;
  max-width: 100%;
}

.sidebar {
  grid-column: 1;
  grid-row: 1 / span 2;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 16px 12px 18px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 14px;
  color: inherit;
  text-decoration: none;
}

.side-brand strong { font-size: 18px; letter-spacing: -0.04em; }
.side-brand span { display: block; color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: 0.14em; }

.compose {
  height: 44px;
  margin: 0 6px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 16px rgba(47, 107, 255, 0.25);
}

.compose:hover { background: var(--brand-dark); }

.nav-scroll { overflow: auto; padding-right: 2px; flex: 1; min-height: 0; }

.nav-item {
  width: 100%;
  height: 38px;
  border-radius: 10px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 560;
  font-size: 14.5px;
  text-align: left;
}

.nav-item .bi { font-size: 16px; color: var(--muted); width: 18px; }
.nav-item .count { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 700; }
.nav-item:hover { background: rgba(47, 107, 255, 0.06); }
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}
.nav-item.active .bi,
.nav-item.active .count { color: var(--brand); }

.folder-label {
  margin: 16px 10px 6px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.14em;
}

.folder-dot { font-size: 15px; }

.topbar {
  grid-column: 2 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 0 8px;
}

.search {
  flex: 1;
  max-width: 640px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  color: var(--faint);
  box-shadow: var(--shadow);
}

.search input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(180deg, #6aa4ff, #2457ea);
  color: #fff;
  font-weight: 750;
}

.dropdown-menu {
  border-radius: 12px;
  border-color: var(--line);
  box-shadow: var(--shadow);
  padding: 8px;
  min-width: 220px;
}

.who { padding: 8px 10px 10px; }
.who strong { display: block; }
.who span { color: var(--muted); font-size: 12px; }

.menu-signout {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  font-weight: 650;
}
.menu-signout:hover { background: var(--bg); }

.list,
.reader {
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.list {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  margin: 0 8px 16px 12px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.reader {
  grid-column: 3;
  grid-row: 2;
  min-width: 0;
  margin: 0 16px 16px 8px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-tools,
.read-tools {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.range { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 650; padding-right: 6px; }

.tool-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.rows { overflow: auto; }

.mail-row {
  width: 100%;
  display: grid;
  cursor: pointer;
  grid-template-columns: 22px 40px minmax(0, 1fr) 16px 18px;
  gap: 8px;
  align-items: center;
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.mail-row:hover { background: rgba(47, 107, 255, 0.04); }
.mail-row.active { background: var(--brand-soft); }

.check, .star { color: var(--faint); font-size: 16px; padding: 0; }
.star.on { color: var(--gold); }

.avatar, .mono {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 750;
  font-size: 13px;
}

.mono.square { border-radius: 12px; }

.row-main { min-width: 0; }
.row-top, .row-sub { display: flex; gap: 8px; min-width: 0; }
.row-top strong, .row-sub b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Read mail: regular weight, muted. Unread mail: bold, full ink, blue dot. */
.row-top strong { font-size: 14px; font-weight: 400; color: var(--muted); }
.row-top time { margin-left: auto; color: var(--faint); font-size: 12px; font-weight: 400; flex: none; }
.row-sub { margin-top: 2px; }
.row-sub b { font-weight: 400; font-size: 13.5px; color: var(--muted); }
.mail-row.unread { background: rgba(47, 107, 255, 0.05); }
.mail-row.unread .row-top strong,
.mail-row.unread .row-sub b { font-weight: 700; color: var(--ink); }
.mail-row.unread .row-top time { font-weight: 700; color: var(--brand); }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; align-self: center; justify-self: center; }
.mail-row.unread .unread-dot { background: var(--brand); }
.mail-row.active { background: var(--brand-soft); }
.snippet {
  display: block;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clip { color: var(--faint); font-size: 14px; }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

.read-tools .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  background: var(--bg);
  border-radius: 999px;
  padding: 4px 8px 4px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.read-tools .tag button {
  border: 0;
  background: transparent;
  color: var(--faint);
  padding: 0;
}

.read-body { overflow: auto; padding: 8px 28px 24px; }
.subject-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 0 8px;
}
.subject-row h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.04em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.list-title {
  font-size: 15px;
  letter-spacing: -0.03em;
  margin-left: 4px;
}
.subject-row .star { margin-left: auto; font-size: 20px; }

.sender {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 0 18px;
}
.sender .who-name { font-weight: 750; }
.sender .who-mail { color: var(--muted); font-size: 13px; }
.sender time { margin-left: auto; color: var(--muted); font-size: 13px; }

.letter p { margin: 0 0 14px; line-height: 1.6; font-size: 15.5px; }
.letter .sig { color: var(--ink); }

.file {
  margin-top: 8px;
  width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
}
.file i { font-size: 28px; color: #e11d48; }
.file b { display: block; font-size: 14px; }
.file span { color: var(--muted); font-size: 12px; }

.replies {
  display: flex;
  gap: 10px;
  padding: 18px 28px 22px;
  border-top: 1px solid var(--line);
}
.replies button {
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.replies button:hover { background: var(--bg); }

.banner {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.km-compose { border-radius: 16px; overflow: hidden; }
.km-compose .modal-header,
.km-compose .modal-footer { border-color: var(--line); }
.km-compose .form-control {
  border-radius: 10px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}
.km-compose textarea.form-control { min-height: 180px; resize: vertical; }

.toast-note {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  z-index: 1080;
}

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 24, 0.45);
  z-index: 20;
}

.menu-btn { display: none; }

.compose-screen {
  display: none;
  grid-column: 2 / -1;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  margin: 0 16px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.shell.composing .list,
.shell.composing .reader { display: none; }
.shell.composing .compose-screen { display: flex; }

.compose-form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.compose-head {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 22px;
  border-bottom: 1px solid var(--line);
}

.compose-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.03em;
}

.compose-line {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 0 22px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.compose-line input {
  height: 46px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  outline: none;
}

.compose-tools {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}

.compose-form textarea {
  flex: 1;
  min-height: 180px;
  border: 0;
  resize: none;
  padding: 18px 22px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15.5px;
  line-height: 1.55;
  outline: none;
}

.compose-form .form-error { padding: 0 22px; }

.compose-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--line);
}

.btn-quiet {
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.btn-quiet:hover { background: var(--bg); color: var(--ink); }

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: 60px minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    z-index: 30;
    width: min(300px, 86vw);
    height: 100%;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .backdrop { display: block; }
  .topbar, .list, .reader, .compose-screen { grid-column: 1; grid-row: auto; }
  .menu-btn { display: grid; }
  .list { margin: 0 10px 10px; }
  .reader {
    display: none;
    margin: 0 10px 10px;
  }
  .compose-screen { margin: 0 10px 10px; }
  .shell.reading .list { display: none; }
  .shell.reading .reader { display: flex; }
  .shell.composing .compose-screen { display: flex; }
  .back-read { display: grid !important; }
}

@media (max-width: 980px) {
  .auth { grid-template-columns: 1fr; }
  .brand { display: none; }
  .auth-panel { min-height: 100vh; }
}

@media (max-width: 720px) {
  .replies { flex-wrap: wrap; padding: 14px; }
  .read-body { padding: 8px 16px 18px; }
  .subject-row h2 { font-size: 22px; }
  .top-actions .lang { display: none; }
}

/* ---------- Shared app chrome (inbox, settings, legal) ---------- */
.side-account { margin: -6px 8px 14px; padding: 6px 10px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-bottom { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.side-bottom form { margin: 0; }
.side-bottom .nav-item { text-decoration: none; }

.greeting { font-size: 20px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.greeting span { color: var(--muted); font-weight: 500; font-size: 14px; margin-left: 10px; }
@media (min-width: 1101px) {
  .shell { grid-template-rows: auto minmax(0, 1fr) auto; }
  .topbar { flex-wrap: wrap; row-gap: 12px; padding: 14px 16px 14px 12px; }
  .topbar .greeting { order: 1; flex: 1; }
  .topbar .top-actions { order: 2; }
  .topbar .search { order: 3; flex: 1 0 100%; max-width: none; }
}
@media (max-width: 1100px) { .greeting { display: none; } }

.lang-btn { width: auto; padding: 0 10px; gap: 5px; display: inline-flex; align-items: center; border-radius: 999px; }
.lang-code { font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.lang-menu { min-width: 150px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); padding: 6px; }
.lang-menu .dropdown-item { border-radius: 8px; color: var(--ink); font-size: 14px; padding: 7px 12px; }
.lang-menu .dropdown-item:hover { background: var(--bg); }
.lang-menu .dropdown-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.avatar-btn { overflow: hidden; padding: 0; flex: none; }
.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-initial { display: grid; place-items: center; width: 100%; height: 100%; }
.menu-signout { text-decoration: none; display: flex; align-items: center; gap: 8px; }

.bell-badge { position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 17px; text-align: center; }
.bell-menu { width: 340px; max-width: 92vw; padding: 0; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.bell-head { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.bell-item { display: block; width: 100%; text-align: left; padding: 10px 16px; border: 0; background: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.bell-item:hover { background: var(--bg); }
.bell-item b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bell-item span { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bell-empty { padding: 18px 16px; color: var(--muted); font-size: 14px; }
.bell-foot { padding: 10px 16px; font-size: 13px; }
.bell-foot button { border: 0; background: none; color: var(--brand); padding: 0; font-weight: 600; }

.app-footer { grid-column: 2 / -1; grid-row: 3; display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 18px; padding: 0 16px 12px; font-size: 12.5px; color: var(--muted); }
.app-footer a { color: var(--muted); text-decoration: none; }
.app-footer a:hover { color: var(--brand); text-decoration: underline; }
.auth-panel .app-footer { position: absolute; left: 0; right: 0; bottom: 16px; padding: 0 16px; }

.impersonating-bar { position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; align-items: center; gap: 12px; background: #f5b400; color: #1b2230; padding: 8px 10px 8px 16px; border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 14px; font-weight: 600; max-width: calc(100vw - 24px); }
.impersonating-bar button { border: 0; border-radius: 999px; background: #1b2230; color: #fff; padding: 6px 14px; font-weight: 600; white-space: nowrap; }

/* ---------- Settings page ---------- */
.settings-title { font-size: 20px; font-weight: 600; margin: 0; flex: 1; min-width: 0; }
.settings-main { grid-column: 2 / -1; grid-row: 2; overflow-y: auto; padding: 0 16px 16px 12px; min-height: 0; }
.settings-card { max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; }
.settings-card .form-control { background: var(--surface); color: var(--ink); border-color: var(--line); border-radius: 10px; }
.settings-card .form-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.settings-card .btn-primary { background: var(--brand); border-color: var(--brand); border-radius: 10px; }
.settings-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin-bottom: 22px; border-radius: 12px; background: var(--bg); }
.settings-tab { flex: 1 1 auto; text-align: center; text-decoration: none; color: var(--muted); border-radius: 9px; padding: 8px 12px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.settings-tab:hover { color: var(--ink); }
.settings-tab.active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 4px rgba(22,34,66,.12); }
.settings-tab.danger.active, .settings-tab.danger:hover { color: var(--danger); }
.avatar-edit { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
.avatar-big { width: 84px; height: 84px; border-radius: 50%; overflow: hidden; background: var(--brand); color: #fff; font-size: 34px; font-weight: 700; flex: none; }

/* ---------- Legal pages ---------- */
.legal-wrap { max-width: 820px; margin: 0 auto; padding: 24px 16px 32px; min-height: 100vh; display: flex; flex-direction: column; }
.legal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.legal-body { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; margin-bottom: 20px; line-height: 1.65; }
.legal-body h1 { font-size: 30px; margin: 0 0 4px; }
.legal-body h2 { font-size: 19px; margin: 26px 0 8px; }
.legal-updated { color: var(--muted); font-size: 13px; }
.legal-wrap .app-footer { padding: 0; }

/* ---------- Phones ---------- */
@media (max-width: 1100px) {
  .app-footer, .settings-main { grid-column: 1; }
  .app-footer { grid-row: 3; padding-bottom: 10px; }
  .settings-main { grid-row: 2; padding: 0 10px 10px; }
  .topbar { gap: 6px; padding: 0 10px; }
  .search { min-width: 0; }
  .top-actions { gap: 2px; flex: none; }
  .lang-code { display: none; }
  .lang-btn { width: 36px; padding: 0; justify-content: center; }
}
@media (max-width: 520px) {
  .top-actions [data-action='theme'] { display: none; }
  .settings-card { padding: 16px; }
  .settings-tab span { display: none; }
}