/* Cosh Mail — дизайн-система: тёмная неоновая тема, стекло, свечения, плавные анимации */

:root {
  --bg: #05070f;
  --bg-2: #080b16;
  --panel: rgba(16, 20, 34, 0.72);
  --panel-solid: #101424;
  --panel-hi: rgba(255, 255, 255, 0.045);
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(255, 255, 255, 0.18);
  --text: #eaf0ff;
  --text-2: #a8b3cf;
  --text-3: #6d7997;
  --cyan: #00e5ff;
  --blue: #2f7cff;
  --green: #3ecf8e;
  --violet: #8b5cf6;
  --amber: #ffc861;
  --red: #ff5d73;
  --radius: 16px;
  --radius-sm: 11px;
  --radius-xs: 8px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, monospace;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 15px/1.55 var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---------- фон: аврора + сетка + свечение курсора ---------- */
.backdrop { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.backdrop__aurora {
  position: absolute; inset: -30%;
  background:
    radial-gradient(46% 38% at 18% 22%, rgba(0, 229, 255, 0.20), transparent 62%),
    radial-gradient(42% 36% at 82% 18%, rgba(139, 92, 246, 0.20), transparent 64%),
    radial-gradient(50% 44% at 62% 88%, rgba(62, 207, 142, 0.16), transparent 66%),
    radial-gradient(36% 30% at 12% 82%, rgba(47, 124, 255, 0.18), transparent 66%);
  filter: blur(28px) saturate(120%);
  animation: aurora 24s var(--ease) infinite alternate;
}
.backdrop__grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 58px 58px;
  mask-image: radial-gradient(circle at 50% 40%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 40%, #000 20%, transparent 78%);
  opacity: 0.5;
}
.backdrop__glow {
  position: absolute; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.14), transparent 65%);
  transform: translate(-50%, -50%);
  transition: opacity 0.4s ease;
  opacity: 0;
}
@keyframes aurora {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1.02) rotate(0deg); }
  50%  { transform: translate3d(2%, 1.5%, 0) scale(1.08) rotate(4deg); }
  100% { transform: translate3d(-1%, 2%, 0) scale(1.04) rotate(-3deg); }
}

/* ---------- каркас ---------- */
.shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  padding: 14px;
  display: grid;
  grid-template-columns: 256px minmax(320px, 420px) 1fr;
  gap: 14px;
  animation: shell-in 0.7s var(--ease-out) both;
}
@keyframes shell-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.pane {
  position: relative;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pane::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(160deg, rgba(0, 229, 255, 0.28), rgba(139, 92, 246, 0.16) 40%, transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.75;
}

/* ---------- левая панель ---------- */
.side { padding: 16px 14px; gap: 14px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 2px; }
.brand__mark {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--cyan), var(--blue) 70%, var(--violet));
  color: #04121a; font-weight: 800; font-size: 17px;
  box-shadow: 0 8px 26px rgba(0, 229, 255, 0.35);
  animation: mark-breathe 6s ease-in-out infinite;
}
@keyframes mark-breathe {
  0%, 100% { box-shadow: 0 8px 26px rgba(0, 229, 255, 0.30); }
  50%      { box-shadow: 0 10px 34px rgba(0, 229, 255, 0.55); }
}
.brand__text b { display: block; font-size: 15px; letter-spacing: -0.01em; }
.brand__text span { display: block; font-size: 12px; color: var(--text-3); font-family: var(--mono); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-hi);
  color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s var(--ease), box-shadow 0.25s var(--ease), background 0.2s ease, border-color 0.2s ease;
}
.btn:hover { border-color: var(--border-hi); background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn--primary {
  border: none; color: #04121a;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  box-shadow: 0 10px 30px rgba(0, 229, 255, 0.28);
}
.btn--primary:hover { box-shadow: 0 14px 40px rgba(0, 229, 255, 0.45); transform: translateY(-1px); }
.btn--primary:active { transform: translateY(0) scale(0.98); }
.btn--ghost { background: transparent; }
.btn--danger:hover { border-color: rgba(255, 93, 115, 0.5); color: var(--red); }
.btn--icon { padding: 9px 11px; border-radius: 10px; }
.btn--wide { width: 100%; }
.btn--sm { padding: 7px 11px; font-size: 13px; }

.side__compose { width: 100%; padding: 12px 14px; font-size: 15px; }

.folders { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.folders button {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-xs);
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  font: inherit; font-size: 14px; text-align: left; cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s var(--ease), border-color 0.2s ease;
}
.folders button:hover { background: var(--panel-hi); color: var(--text); transform: translateX(2px); }
.folders button .ico { width: 18px; text-align: center; opacity: 0.85; }
.folders button .count { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.folders li.is-active button {
  color: var(--text);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.16), rgba(0, 229, 255, 0.02));
  border-color: rgba(0, 229, 255, 0.28);
  box-shadow: inset 2px 0 0 var(--cyan), 0 6px 22px rgba(0, 229, 255, 0.12);
}
.side__foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.who {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel-hi);
  font-size: 13px; color: var(--text-2); overflow: hidden;
}
.who b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); animation: pulse 2.6s ease-in-out infinite; flex: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.side__hint { font-size: 11.5px; color: var(--text-3); line-height: 1.5; padding: 0 4px; }

/* ---------- список писем ---------- */
.list-pane__head {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
}
.list-pane__title { display: flex; align-items: baseline; gap: 10px; }
.list-pane__title h1 { font-size: 19px; margin: 0; letter-spacing: -0.02em; }
.list-pane__title span { font-size: 12.5px; color: var(--text-3); font-family: var(--mono); }

.search { position: relative; display: flex; align-items: center; }
.search input {
  width: 100%; padding: 10px 36px 10px 40px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: rgba(6, 9, 18, 0.75);
  color: var(--text); font: inherit; font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.25s var(--ease);
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { outline: none; border-color: rgba(0, 229, 255, 0.55); box-shadow: 0 0 0 4px rgba(0, 229, 255, 0.10); }
.search .search__ico { position: absolute; left: 11px; color: var(--text-3); font-size: 14px; pointer-events: none; }
.search .search__clear {
  position: absolute; right: 8px; border: none; background: transparent; color: var(--text-3);
  cursor: pointer; font-size: 16px; padding: 4px 6px; border-radius: 8px; display: none;
}
.search .search__clear:hover { color: var(--text); background: var(--panel-hi); }
.search.has-value .search__clear { display: block; }

.bulkbar {
  display: none; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: var(--radius-xs);
  border: 1px solid rgba(0, 229, 255, 0.28);
  background: rgba(0, 229, 255, 0.08);
  animation: drop-in 0.28s var(--ease-out);
}
.bulkbar.is-open { display: flex; }
.bulkbar span { font-size: 13px; color: var(--text-2); margin-right: auto; }
@keyframes drop-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.list { flex: 1; overflow-y: auto; padding: 6px; scroll-behavior: smooth; }
.list__empty, .pane__empty {
  height: 100%; display: grid; place-content: center; justify-items: center; gap: 12px;
  color: var(--text-3); text-align: center; padding: 30px;
}
.pane__empty .glyph { font-size: 46px; filter: drop-shadow(0 10px 26px rgba(0, 229, 255, 0.35)); animation: float 5s ease-in-out infinite; }
.pane__empty h2 { margin: 0; font-size: 19px; color: var(--text-2); font-weight: 650; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

.row {
  position: relative;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 11px;
  align-items: start;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  animation: row-in 0.42s var(--ease-out) both;
  transition: background 0.22s ease, border-color 0.22s ease, transform 0.22s var(--ease);
}
@keyframes row-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.row:hover { background: var(--panel-hi); border-color: var(--border); transform: translateX(2px); }
.row.is-active {
  background: linear-gradient(95deg, rgba(0, 229, 255, 0.14), rgba(139, 92, 246, 0.07) 60%, transparent);
  border-color: rgba(0, 229, 255, 0.30);
  box-shadow: inset 2px 0 0 var(--cyan);
}
.row.is-active::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.07) 45%, transparent 60%);
  animation: sheen 0.9s var(--ease-out);
}
@keyframes sheen { from { transform: translateX(-40%); opacity: 0.9; } to { transform: translateX(40%); opacity: 0; } }
.row.is-unread .row__subject { font-weight: 700; color: #fff; }
.row.is-unread .row__from { color: var(--text); }
.row.is-unread .row__dot { opacity: 1; }

.row__avatar {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #05101c; letter-spacing: -0.02em;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s var(--ease);
}
.row:hover .row__avatar { transform: scale(1.06) rotate(-2deg); }
.row__main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row__top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row__from { font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); opacity: 0; flex: none; }
.row__subject { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__preview { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.row__date { font-size: 11.5px; color: var(--text-3); font-family: var(--mono); white-space: nowrap; }
.row__marks { display: flex; gap: 5px; align-items: center; color: var(--text-3); font-size: 12px; }
.row__check { position: absolute; left: 4px; top: 50%; transform: translateY(-50%) scale(0.8); opacity: 0; transition: opacity 0.2s ease, transform 0.2s var(--ease); }
.row:hover .row__check, .row.is-checked .row__check { opacity: 1; transform: translateY(-50%) scale(1); }
.row.is-checked { background: rgba(0, 229, 255, 0.10); border-color: rgba(0, 229, 255, 0.28); }

input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 17px; height: 17px; border-radius: 6px;
  border: 1.5px solid var(--border-hi); background: rgba(6, 9, 18, 0.7);
  cursor: pointer; transition: all 0.18s ease; flex: none; position: relative;
}
input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-color: transparent;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.45);
}
input[type="checkbox"]:checked::after {
  content: "✓"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11px; color: #04121a; font-weight: 800;
}

/* скелетоны загрузки */
.skeleton { padding: 12px; display: flex; gap: 11px; align-items: center; }
.skeleton__box, .skeleton__line {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.11) 37%, rgba(255, 255, 255, 0.05) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 8px;
}
.skeleton__box { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.skeleton__col { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skeleton__line { height: 10px; }
.skeleton__line--short { width: 42%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.loader { display: flex; justify-content: center; padding: 14px; }
.loader i {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12); border-top-color: var(--cyan);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- мобильные элементы: на десктопе скрыты ---------- */
.mobilebar, .scrim, .side__close, .reader__bottombar, .toolbar-mobile { display: none; }
.toolbar-desktop { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; width: 100%; }
.toolbar-desktop .spacer { margin-left: auto; }

/* ---------- область чтения ---------- */
.reader { position: relative; }
.reader__toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
}
.reader__toolbar .spacer { margin-left: auto; }
.reader__scroll { flex: 1; overflow-y: auto; padding: 22px 26px 40px; }

.letter { animation: letter-in 0.42s var(--ease-out) both; }
@keyframes letter-in {
  from { opacity: 0; transform: translateY(16px) scale(0.994); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}
.letter__head { border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 20px; }
.letter__subject { font-size: clamp(20px, 2.3vw, 27px); font-weight: 750; letter-spacing: -0.025em; margin: 0 0 14px; line-height: 1.25; }
.letter__from { display: flex; align-items: center; gap: 13px; }
.letter__avatar {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-weight: 750; font-size: 17px; color: #05101c; flex: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.letter__meta { min-width: 0; }
.letter__meta b { display: block; font-size: 14.5px; }
.letter__meta span { display: block; font-size: 12.5px; color: var(--text-3); }
.letter__rows { margin-top: 14px; display: grid; gap: 4px; font-size: 12.5px; color: var(--text-3); }
.letter__rows b { color: var(--text-2); font-weight: 600; }
.letter__tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.tag {
  font-size: 11.5px; padding: 3px 9px; border-radius: 100px;
  border: 1px solid var(--border); color: var(--text-3); background: var(--panel-hi);
  font-family: var(--mono);
}
.tag--ok { color: var(--green); border-color: rgba(62, 207, 142, 0.35); background: rgba(62, 207, 142, 0.08); }
.tag--warn { color: var(--amber); border-color: rgba(255, 200, 97, 0.35); background: rgba(255, 200, 97, 0.08); }

.attach { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-wrap: wrap; gap: 9px; }
.attach a {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 13px; border-radius: var(--radius-xs);
  border: 1px solid var(--border); background: var(--panel-hi);
  color: var(--text); font-size: 13px; text-decoration: none;
  transition: transform 0.2s var(--ease), border-color 0.2s ease, box-shadow 0.25s var(--ease);
}
.attach a:hover { transform: translateY(-2px); border-color: rgba(0, 229, 255, 0.4); box-shadow: 0 10px 26px rgba(0, 229, 255, 0.14); }
.attach .size { color: var(--text-3); font-size: 11.5px; font-family: var(--mono); }

.letter__body { font-size: 15px; line-height: 1.72; color: #dfe6f7; overflow-wrap: anywhere; }
.letter__body img { max-width: 100%; height: auto; border-radius: 10px; }
.letter__body a { color: var(--cyan); }
.letter__body table { max-width: 100%; border-collapse: collapse; }
.letter__body td, .letter__body th { padding: 5px 9px; }
.letter__body blockquote { margin: 12px 0; padding: 6px 0 6px 14px; border-left: 2px solid rgba(0, 229, 255, 0.35); color: var(--text-2); }
.letter__body pre { white-space: pre-wrap; font-family: var(--mono); font-size: 13.5px; }
.letter__body hr { border: none; border-top: 1px solid var(--border); }
.letter__notice {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 10px 13px; border-radius: var(--radius-xs);
  border: 1px solid rgba(255, 200, 97, 0.3); background: rgba(255, 200, 97, 0.07);
  color: var(--amber); font-size: 13px;
}

/* быстрый ответ */
.reply { margin-top: 26px; animation: letter-in 0.4s var(--ease-out) both; }
.reply__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: var(--text-2); font-size: 13px; }
.reply textarea, .compose textarea, .compose input, .login input {
  width: 100%; padding: 12px 13px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: rgba(6, 9, 18, 0.75);
  color: var(--text); font: inherit;
  transition: border-color 0.2s ease, box-shadow 0.25s var(--ease);
  resize: vertical;
}
.reply textarea:focus, .compose textarea:focus, .compose input:focus, .login input:focus {
  outline: none; border-color: rgba(0, 229, 255, 0.55); box-shadow: 0 0 0 4px rgba(0, 229, 255, 0.10);
}
.reply__actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.reply__actions .hint { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-family: var(--mono); }

/* ---------- всплывающие уведомления ---------- */
.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 220px; max-width: 360px;
  padding: 12px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(16, 20, 34, 0.94);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  display: flex; align-items: center; gap: 10px;
  animation: toast-in 0.36s var(--ease-out) both;
}
.toast.is-out { animation: toast-out 0.3s var(--ease) both; }
.toast--ok { border-color: rgba(62, 207, 142, 0.4); box-shadow: 0 12px 40px rgba(62, 207, 142, 0.16); }
.toast--err { border-color: rgba(255, 93, 115, 0.4); }
.toast__ico { font-size: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(18px) scale(0.98); } }

/* ---------- вход ---------- */
.login-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  width: min(430px, 100%);
  padding: 30px 28px 26px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow);
  animation: letter-in 0.6s var(--ease-out) both;
}
.login__mark {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--cyan), var(--blue) 65%, var(--violet));
  color: #04121a; font-weight: 800; font-size: 22px; margin-bottom: 16px;
  box-shadow: 0 14px 40px rgba(0, 229, 255, 0.4);
}
.login h1 { font-size: 25px; margin: 0 0 6px; letter-spacing: -0.03em; }
.login p.lead { margin: 0 0 20px; color: var(--text-3); font-size: 13.5px; }
.login label { display: block; margin: 14px 0 0; font-size: 12.5px; color: var(--text-2); }
.login label input { margin-top: 7px; }
.login .btn { width: 100%; margin-top: 20px; padding: 13px; }
.login .note { margin-top: 16px; font-size: 12px; color: var(--text-3); line-height: 1.6; }
.alert {
  margin: 16px 0 0; padding: 11px 13px; border-radius: var(--radius-xs); font-size: 13px;
  border: 1px solid rgba(255, 93, 115, 0.35); background: rgba(255, 93, 115, 0.09); color: #ffc3cc;
  animation: drop-in 0.3s var(--ease-out);
}

/* ---------- страница написания письма ---------- */
.compose-page { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: start center; padding: 26px 16px 60px; overflow-y: auto; }
.compose-card {
  width: min(820px, 100%);
  padding: 24px 26px;
  border-radius: 20px; border: 1px solid var(--border);
  background: var(--panel); backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: letter-in 0.5s var(--ease-out) both;
}
.compose-card h1 { margin: 0 0 18px; font-size: 22px; letter-spacing: -0.02em; }
.compose-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.compose label { display: block; margin-bottom: 12px; font-size: 12.5px; color: var(--text-2); }
.compose label input, .compose label textarea { margin-top: 7px; }
.compose textarea { font-family: var(--mono); font-size: 14px; }
.compose-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.compose-actions .hint { margin-left: auto; color: var(--text-3); font-size: 12px; }
.file-drop {
  display: block; padding: 14px; text-align: center;
  border: 1px dashed var(--border-hi); border-radius: var(--radius-xs);
  color: var(--text-3); font-size: 13px; cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.file-drop:hover { border-color: rgba(0, 229, 255, 0.45); background: rgba(0, 229, 255, 0.05); }
.file-drop input { display: none; }

/* ---------- прокрутка ---------- */
.list::-webkit-scrollbar, .reader__scroll::-webkit-scrollbar, .compose-page::-webkit-scrollbar { width: 10px; }
.list::-webkit-scrollbar-thumb, .reader__scroll::-webkit-scrollbar-thumb, .compose-page::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12); border-radius: 8px; border: 3px solid transparent; background-clip: content-box;
}
.list::-webkit-scrollbar-thumb:hover, .reader__scroll::-webkit-scrollbar-thumb:hover { background: rgba(0, 229, 255, 0.35); background-clip: content-box; }

.fade-swap { animation: fade-swap 0.3s var(--ease-out); }
@keyframes fade-swap { from { opacity: 0.25; } to { opacity: 1; } }

/* ---------- адаптив: планшеты ---------- */
@media (max-width: 1180px) {
  .shell { grid-template-columns: 220px minmax(280px, 360px) 1fr; }
}

/* планшеты: теснее колонки, но всё ещё три панели */
@media (min-width: 901px) and (max-width: 1100px) {
  .shell { grid-template-columns: 210px minmax(260px, 330px) 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .backdrop__aurora { animation: none; }
}

/* =======================================================================
   Темы оформления
   ======================================================================= */
:root[data-theme="midnight"] {
  --bg: #06070f; --panel: rgba(20, 18, 40, 0.74); --panel-solid: #141228;
  --cyan: #a78bfa; --blue: #6366f1; --violet: #00d4ff; --green: #34d399;
}
:root[data-theme="neon"] {
  --bg: #040d09; --panel: rgba(12, 30, 24, 0.74); --panel-solid: #0c1e18;
  --cyan: #3ecf8e; --blue: #22c55e; --violet: #a6ff4d; --green: #7dffb0;
}
:root[data-theme="sunset"] {
  --bg: #0f0705; --panel: rgba(36, 20, 16, 0.74); --panel-solid: #241410;
  --cyan: #ffc861; --blue: #ff7a59; --violet: #ff5d8f; --green: #ffd08a;
}
:root[data-theme="mint"] {
  --bg: #050c10; --panel: rgba(14, 28, 34, 0.74); --panel-solid: #0e1c22;
  --cyan: #6ee7d0; --blue: #4fb3ff; --violet: #7c9cff; --green: #7ef0c8;
}
:root[data-theme="light"] {
  --bg: #eef2f8; --panel: rgba(255, 255, 255, 0.82); --panel-solid: #ffffff;
  --panel-hi: rgba(10, 20, 40, 0.04);
  --border: rgba(12, 24, 48, 0.12); --border-hi: rgba(12, 24, 48, 0.26);
  --text: #0d1728; --text-2: #41506b; --text-3: #6b7891;
  --cyan: #0ea5e9; --blue: #6366f1; --violet: #14b8a6; --green: #10b981;
  --shadow: 0 24px 60px rgba(20, 40, 80, 0.18);
  --shadow-soft: 0 10px 30px rgba(20, 40, 80, 0.12);
}
:root[data-theme="light"] .backdrop__aurora { opacity: 0.55; }
:root[data-theme="light"] .backdrop__grid { opacity: 0.35; }
:root[data-theme="light"] .row.is-unread .row__subject { color: #06111f; }
:root[data-theme="light"] .letter__body { color: #182338; }
:root[data-theme="light"] .toast { background: rgba(255, 255, 255, 0.96); }
:root[data-theme="light"] .folders li.is-active button { background: linear-gradient(90deg, rgba(14, 165, 233, 0.16), rgba(14, 165, 233, 0.02)); }
:root[data-theme="light"] .btn--primary { color: #ffffff; }
:root[data-theme="light"] .rail { background: rgba(255, 255, 255, 0.7); }

/* =======================================================================
   Плотность интерфейса
   ======================================================================= */
[data-density="compact"] { --radius: 13px; --radius-sm: 9px; --radius-xs: 7px; }
[data-density="compact"] .row { padding: 6px 10px; gap: 9px; }
[data-density="compact"] .row__avatar { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
[data-density="compact"] .row__subject { font-size: 13px; }
[data-density="compact"] .row__preview { display: none; }
[data-density="compact"] .folders button { padding: 7px 10px; font-size: 13.5px; }
[data-density="compact"] .list-pane__head { padding: 10px 12px 9px; gap: 9px; }
[data-density="compact"] .letter__body { font-size: 14px; }
[data-density="compact"] .reader__scroll { padding: 16px 20px 30px; }

[data-density="wide"] .row { padding: 15px 16px; gap: 14px; }
[data-density="wide"] .row__avatar { width: 46px; height: 46px; border-radius: 14px; font-size: 17px; }
[data-density="wide"] .row__subject { font-size: 15px; }
[data-density="wide"] .folders button { padding: 12px 14px; }
[data-density="wide"] .letter__body { font-size: 16px; line-height: 1.8; }
[data-density="wide"] .reader__scroll { padding: 28px 34px 50px; }

/* =======================================================================
   Каркас: рейл слева + рабочая область
   ======================================================================= */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: 74px 1fr; height: 100vh; }

.rail {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 8px;
  border-right: 1px solid var(--border);
  background: rgba(8, 11, 22, 0.6);
  backdrop-filter: blur(16px);
}
.rail__mark {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--cyan), var(--blue) 70%, var(--violet));
  color: #04121a; font-weight: 800; font-size: 18px; margin-bottom: 10px;
  box-shadow: 0 10px 30px rgba(0, 229, 255, 0.35);
}
.rail__btn {
  width: 58px; padding: 9px 0; border: 1px solid transparent; border-radius: 13px;
  background: transparent; color: var(--text-3); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font: inherit; transition: all 0.2s var(--ease);
}
.rail__btn span { font-size: 19px; line-height: 1; }
.rail__btn small { font-size: 10.5px; letter-spacing: 0.01em; }
.rail__btn:hover { color: var(--text); background: var(--panel-hi); transform: translateY(-1px); }
.rail__btn.is-active {
  color: var(--text);
  background: linear-gradient(160deg, rgba(0, 229, 255, 0.18), rgba(139, 92, 246, 0.10));
  border-color: rgba(0, 229, 255, 0.3);
  box-shadow: 0 8px 26px rgba(0, 229, 255, 0.16);
}
.rail__spacer { flex: 1; }
.rail__logout { width: 100%; }

.workspace { position: relative; min-width: 0; height: 100vh; overflow: hidden; }
.view { display: none; height: 100%; }
.view.is-active { display: block; animation: view-in 0.32s var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

#view-mail.is-active { display: block; }
#view-mail .shell { height: 100vh; }

.view__inner { height: 100%; overflow-y: auto; padding: 26px 30px 60px; max-width: 1080px; margin: 0 auto; }
.view__head { display: flex; align-items: flex-start; gap: 18px; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; }
.view__head h1 { margin: 0 0 6px; font-size: 27px; letter-spacing: -0.03em; }
.view__head p { margin: 0; max-width: 620px; font-size: 13.5px; line-height: 1.6; }
.view__loading { display: grid; place-items: center; height: 60vh; }

.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); backdrop-filter: blur(16px);
  box-shadow: var(--shadow-soft);
  padding: 20px 22px; margin-bottom: 18px;
  animation: letter-in 0.4s var(--ease-out) both;
}
.card h2 { margin: 0 0 14px; font-size: 16.5px; letter-spacing: -0.01em; }
.card__actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.card--about code { font-family: var(--mono); font-size: 12px; color: var(--cyan); }

.muted { color: var(--text-3); }
.small { font-size: 12px; }
.spacer { margin-left: auto; }

/* любое текстовое поле, включая <input> без атрибута type.
   :where() даёт нулевую специфичность, чтобы правила компонентов (.search input и т.п.) побеждали */
:where(.select, select,
  input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="file"]),
  textarea) {
  font: inherit; color: var(--text);
  background: rgba(6, 9, 18, 0.75);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 9px 11px;
  transition: border-color 0.2s ease, box-shadow 0.25s var(--ease);
}
textarea { resize: vertical; min-height: 90px; }
.select:focus, select:focus, input:focus, textarea:focus { outline: none; border-color: rgba(0, 229, 255, 0.55); box-shadow: 0 0 0 4px rgba(0, 229, 255, 0.10); }
.select--sm { padding: 7px 10px; font-size: 12.5px; min-width: 152px; }
:root[data-theme="light"] .select, :root[data-theme="light"] select,
:root[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]),
:root[data-theme="light"] textarea { background: rgba(255, 255, 255, 0.9); }

.icon-btn {
  border: 1px solid var(--border); background: var(--panel-hi); color: var(--text-2);
  width: 26px; height: 26px; border-radius: 8px; cursor: pointer; font-size: 14px; line-height: 1;
  display: grid; place-items: center; transition: all 0.18s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-hi); transform: scale(1.06); }

.check { display: flex; align-items: center; gap: 9px; margin: 9px 0; font-size: 13.5px; color: var(--text-2); }
.check input[type="checkbox"] { width: 17px; height: 17px; }

.folders-wrap { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
.folders-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 0; margin-top: 6px; border-top: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-3);
}
.folders--custom li { position: relative; display: flex; align-items: center; }
.folders--custom li > button:first-child { flex: 1; }
.folder-menu { opacity: 0; margin-right: 4px; transition: opacity 0.2s ease; }
.folders--custom li:hover .folder-menu { opacity: 1; }
.folders__empty { padding: 10px 12px; font-size: 12px; color: var(--text-3); }

/* =======================================================================
   Модальные окна
   ======================================================================= */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(3, 6, 14, 0.66); backdrop-filter: blur(6px); opacity: 0; transition: opacity 0.2s ease; }
.modal.is-open .modal__backdrop { opacity: 1; }
.modal__card {
  position: relative; width: min(520px, calc(100% - 32px));
  border: 1px solid var(--border); border-radius: 18px;
  background: var(--panel-solid); box-shadow: var(--shadow);
  transform: translateY(14px) scale(0.97); opacity: 0;
  transition: transform 0.24s var(--ease-out), opacity 0.24s ease;
  overflow: hidden;
}
.modal.is-open .modal__card { transform: none; opacity: 1; }
.modal__card--wide { width: min(760px, calc(100% - 32px)); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal__head h3 { margin: 0; font-size: 16px; }
.modal__body { padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.modal__body label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; }
.modal__body label input, .modal__body label select { width: 100%; margin-top: 6px; }
.modal__foot { display: flex; gap: 9px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--panel-hi); flex-wrap: wrap; }

/* =======================================================================
   Настройки: темы, плотность, переключатели
   ======================================================================= */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); grid-auto-rows: 1fr; gap: 12px; }
.theme {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; height: 100%;
  padding: 13px; border-radius: var(--radius-sm); cursor: pointer; font: inherit;
  border: 1px solid var(--border); background: var(--panel-hi); color: var(--text);
  transition: all 0.22s var(--ease);
}
.theme:hover { transform: translateY(-2px); border-color: var(--border-hi); }
.theme.is-active { border-color: rgba(0, 229, 255, 0.5); box-shadow: 0 10px 30px rgba(0, 229, 255, 0.18); }
.theme__swatch { display: flex; gap: 4px; margin-bottom: 4px; }
.theme__swatch i { width: 26px; height: 12px; border-radius: 4px; display: block; }
.theme b { font-size: 14px; }
.theme .small { text-align: left; }

.segmented { display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel-hi); }
.segmented button {
  border: none; background: transparent; color: var(--text-3); font: inherit; font-size: 13.5px;
  padding: 8px 16px; border-radius: 9px; cursor: pointer; transition: all 0.2s var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: linear-gradient(135deg, var(--cyan), var(--blue)); color: #04121a; font-weight: 600; }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 10px; }
.fields label { font-size: 12.5px; color: var(--text-2); display: block; }
.fields select { width: 100%; margin-top: 7px; }

#set-signature { width: 100%; font-family: var(--mono); font-size: 13.5px; }
.about { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13.5px; line-height: 1.9; }
.about b { color: var(--text); }

/* =======================================================================
   Правила
   ======================================================================= */
.rule-form { display: grid; grid-template-columns: minmax(150px, 210px) 1fr minmax(140px, 200px) auto; gap: 10px; }
.rule-form input, .rule-form select { width: 100%; }
@media (max-width: 900px) { .rule-form { grid-template-columns: 1fr; } }

.rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.rule {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel-hi);
  transition: all 0.2s var(--ease);
}
.rule:hover { border-color: var(--border-hi); transform: translateX(2px); }
.rule.is-off { opacity: 0.55; }
.rule__text { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 13.5px; color: var(--text-2); }
.rule__text b { color: var(--text); }
.rule__arrow { color: var(--cyan); font-weight: 700; }
.rule__hits { margin-left: auto; font-family: var(--mono); }

.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 100px; background: rgba(255, 255, 255, 0.14); transition: background 0.2s ease; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.22s var(--ease); }
.switch input:checked + span { background: linear-gradient(135deg, var(--cyan), var(--blue)); }
.switch input:checked + span::after { transform: translateX(18px); }

/* =======================================================================
   Контакты
   ======================================================================= */
.search--wide { margin-bottom: 18px; }
.contacts { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.contact {
  display: grid; grid-template-columns: 44px 1fr; grid-template-areas: "avatar body" "avatar actions";
  gap: 6px 12px; align-items: center;
  padding: 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel-hi);
  transition: all 0.22s var(--ease);
  animation: row-in 0.4s var(--ease-out) both;
}
.contact:hover { transform: translateY(-2px); border-color: rgba(0, 229, 255, 0.34); box-shadow: 0 12px 30px rgba(0, 229, 255, 0.12); }
.contact__avatar { grid-area: avatar; width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-weight: 700; color: #05101c; align-self: start; }
.contact__body { grid-area: body; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.contact__body b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact__body span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact__actions { grid-area: actions; display: flex; gap: 6px; align-items: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 100px; cursor: pointer; font: inherit; font-size: 13px;
  border: 1px solid var(--border); background: var(--panel-hi); color: var(--text);
  transition: all 0.2s var(--ease);
}
.chip:hover { transform: translateY(-2px); border-color: rgba(0, 229, 255, 0.4); }
.chip__dot { width: 18px; height: 18px; border-radius: 6px; }

.alert--ok { border-color: rgba(62, 207, 142, 0.35); background: rgba(62, 207, 142, 0.09); color: #b6f0d3; }

/* (мобильная раскладка описана выше в блоке @media (max-width: 900px)) */


/* блокировка фоновой прокрутки, когда открыт ящик или письмо на телефоне */
body.is-locked { overflow: hidden; }

/* мобильная кнопка обновления */
@keyframes spin-once { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.icon-btn.is-spinning { animation: spin-once 0.5s var(--ease); }


/* =======================================================================
   Мобильные устройства: интерфейс как отдельное приложение
   ======================================================================= */
@media (max-width: 900px) {
  html, body { height: 100%; overflow: hidden; }
  body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }

  .app { display: block; height: 100dvh; }

  /* нижняя навигация вместо бокового рейла */
  .rail {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    flex-direction: row; align-items: stretch; justify-content: space-between; gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    border-right: none; border-top: 1px solid var(--border);
    background: rgba(8, 11, 22, 0.94); backdrop-filter: blur(16px);
  }
  .rail__mark, .rail__spacer, .rail__logout { display: none; }
  .rail__btn { flex: 1 1 0; width: auto; padding: 5px 2px; gap: 2px; border-radius: 12px; }
  .rail__btn span { font-size: 21px; }
  .rail__btn small { font-size: 10.5px; letter-spacing: 0; }
  .rail__btn.is-active { background: linear-gradient(160deg, rgba(0, 229, 255, 0.2), rgba(139, 92, 246, 0.12)); }

  .workspace { height: calc(100dvh - 62px - env(safe-area-inset-bottom, 0px)); overflow: hidden; }
  .view.is-active { height: 100%; animation: none; }
  /* анимация .shell создаёт containing block и мешает fixed-письму занять весь экран */
  #view-mail .shell { display: block; height: 100%; padding: 0; gap: 0; animation: none; transform: none; }

  /* --- список писем на всю высоту --- */
  .list-pane {
    position: absolute; inset: 0;
    border: none; border-radius: 0; box-shadow: none; background: transparent;
  }
  .mobilebar {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-bottom: 1px solid var(--border);
    background: rgba(10, 13, 24, 0.92); backdrop-filter: blur(14px);
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
  }
  .mobilebar__title { flex: 1; font-weight: 650; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobilebar .icon-btn { width: 38px; height: 38px; font-size: 17px; text-decoration: none; }
  .list-pane__head { padding: 8px 10px 10px; gap: 8px; }
  .list-pane__title h1 { display: none; }
  .list-pane__title { min-height: 0; }
  #list-count { font-size: 12px; }
  .select--sm { min-width: 0; flex: 1; }
  .search input { font-size: 16px; padding: 11px 36px 11px 40px; }
  .bulkbar { overflow-x: auto; }
  .list { padding: 4px 4px calc(76px + env(safe-area-inset-bottom, 0px)); }

  .row { grid-template-columns: 22px 38px 1fr auto; padding: 11px 8px; gap: 9px; }
  .row__check { position: static; transform: none; opacity: 1; }
  .row:hover { transform: none; }
  .row__avatar { width: 38px; height: 38px; border-radius: 12px; font-size: 14px; }
  .row__from { font-size: 13px; }
  .row__subject { font-size: 14.5px; }
  .row__date { font-size: 11px; }
  .row__preview { font-size: 12.5px; }

  /* --- ящик с папками: выдвижная панель --- */
  .side {
    position: fixed; top: 0; bottom: 0; left: 0; width: 86%; max-width: 360px; z-index: 60;
    border-radius: 0 22px 22px 0; border-left: none;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 14px calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-104%); transition: transform 0.32s var(--ease-out);
    background: var(--panel-solid); backdrop-filter: blur(18px);
  }
  .side.is-open { transform: none; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6); }
  .side__close { display: grid; margin-left: auto; width: 34px; height: 34px; font-size: 15px; }
  .side__hint { display: block; }
  .folders-wrap { overflow-y: auto; overscroll-behavior: contain; }
  .folders button { padding: 12px; font-size: 15px; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(3, 6, 14, 0.62); backdrop-filter: blur(3px);
           opacity: 0; pointer-events: none; transition: opacity 0.26s ease; }
  .scrim.is-open { opacity: 1; pointer-events: auto; }

  /* --- чтение: полноэкранный слой --- */
  .reader {
    position: fixed; inset: 0; z-index: 120;
    border: none; border-radius: 0; box-shadow: none; background: var(--bg);
    transform: translateX(100%); transition: transform 0.3s var(--ease-out);
  }
  .reader.is-open { transform: none; }
  /* пока открыто письмо или ящик с папками, нижняя навигация скрыта:
     она не нужна и в Chrome перекрывает выдвижные слои из-за backdrop-filter */
  body.is-locked .rail { display: none; }
  .reader__toolbar { padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; }
  .toolbar-desktop { display: none; }
  .toolbar-mobile { display: flex; align-items: center; gap: 10px; width: 100%; }
  .toolbar-mobile__subject { flex: 1; min-width: 0; font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .toolbar-mobile .icon-btn { width: 38px; height: 38px; font-size: 17px; }
  .reader__scroll { padding: 16px 14px 22px; overscroll-behavior: contain; }
  .letter__subject { font-size: 21px; margin-bottom: 12px; }
  .letter__avatar { width: 42px; height: 42px; border-radius: 13px; font-size: 16px; }
  .letter__body { font-size: 15.5px; }
  .attach { flex-direction: column; }
  .attach a { width: 100%; }
  .reply textarea { min-height: 120px; font-size: 16px; }
  .reader__bottombar {
    display: flex; gap: 8px; align-items: center;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: rgba(10, 13, 24, 0.95); backdrop-filter: blur(14px);
  }
  .reader__bottombar .btn { flex: 1; padding: 11px 6px; font-size: 13px; flex-direction: column; gap: 3px; }
  .reader__bottombar .btn span:first-child { font-size: 17px; }

  /* --- разделы --- */
  .view__inner { padding: 14px 12px calc(30px + env(safe-area-inset-bottom, 0px)); }
  .view__head { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 16px; }
  .view__head h1 { font-size: 23px; }
  .view__head .btn { width: 100%; justify-content: center; }
  .card { padding: 16px 14px; border-radius: 14px; }
  .card h2 { font-size: 16px; }
  .themes { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .segmented { display: flex; width: 100%; }
  .segmented button { flex: 1; padding: 10px 6px; }
  .fields { grid-template-columns: 1fr; }
  .rule-form { grid-template-columns: 1fr; }
  .contacts { grid-template-columns: 1fr; }
  .contact { grid-template-columns: 40px 1fr; }
  .rule { align-items: flex-start; }
  .rule__text { font-size: 13px; }
  .rule__hits { margin-left: 0; width: 100%; }
  .rule .btn { flex: 1; }
  .search--wide { margin-bottom: 14px; }
  .about { font-size: 13px; }

  /* --- модальные окна как нижний лист --- */
  .modal { place-items: end center; }
  .modal__card, .modal__card--wide {
    width: 100%; border-radius: 22px 22px 0 0; border-bottom: none;
    transform: translateY(28px) scale(1);
    max-height: 88dvh; display: flex; flex-direction: column;
  }
  .modal.is-open .modal__card { transform: none; }
  .modal__head { padding: 14px 16px; }
  .modal__head::before {
    content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 4px; background: var(--border-hi);
  }
  .modal__body { overflow-y: auto; padding: 16px; }
  .modal__body label input, .modal__body label select { font-size: 16px; }
  .modal__foot { padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px)); }
  .modal__foot .btn { flex: 1; }

  /* --- написание письма и вход --- */
  .compose-page { padding: 12px 10px calc(40px + env(safe-area-inset-bottom, 0px)); }
  .compose-card { padding: 18px 14px; border-radius: 16px; }
  .compose-card h1 { font-size: 20px; }
  .compose-row { grid-template-columns: 1fr; }
  .compose input, .compose textarea { font-size: 16px; }
  /* на телефоне поле письма короче — кнопки отправки видны сразу */
  .compose textarea { min-height: 190px; font-size: 15px; }
  .compose label { margin-bottom: 12px; }
  .compose-actions .btn { flex: 1; }
  .compose-actions .hint { width: 100%; margin-left: 0; text-align: center; }
  /* кнопка «Отправить» всегда под рукой */
  .compose-actions {
    position: sticky; bottom: 0; z-index: 5; margin-top: 14px;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(6, 9, 18, 0) 0%, rgba(6, 9, 18, 0.94) 45%);
    backdrop-filter: blur(8px);
  }
  .login-wrap { padding: 16px; align-items: start; padding-top: calc(28px + env(safe-area-inset-top, 0px)); }
  .login { padding: 22px 18px; border-radius: 18px; }
  .login input { font-size: 16px; }

  /* крупные цели для пальца */
  .btn { min-height: 42px; }
  .icon-btn { width: 34px; height: 34px; }
  .toasts { left: 12px; right: 12px; bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
  .toast { max-width: none; }
}
