/* PehaMail — Peha System dark/red shell */

:root {
  --bg: #0a0a0c;
  --bg-elev: #121216;
  --bg-side: #0e0e12;
  --surface: #16161c;
  --surface-2: #1c1c24;
  --ink: #f2f2f5;
  --ink-2: #c8c8d2;
  --muted: #8b8b9a;
  --line: #2a2a35;
  --line-soft: #22222c;
  --accent: #e50914;
  --accent-hot: #ff3b45;
  --accent-soft: rgba(229, 9, 20, 0.18);
  --accent-ink: #ffffff;
  --brand: #e50914;
  --brand-soft: rgba(229, 9, 20, 0.16);
  --unread: #e50914;
  --danger: #ff6b6b;
  --ok: #3ecf8e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55);
  --font: "Outfit", system-ui, sans-serif;
  --radius: 14px;
  --radius-lg: 20px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --row-hover: #1e1e28;
  --suggest-hover: rgba(229, 9, 20, 0.14);
  --focus-ring: 0 0 0 3px rgba(229, 9, 20, 0.28);
}

html[data-theme="light"] {
  --bg: #f4f2f2;
  --bg-elev: #ffffff;
  --bg-side: #ebe6e6;
  --surface: #ffffff;
  --surface-2: #faf7f7;
  --ink: #16161a;
  --ink-2: #3a3a44;
  --muted: #6b6b78;
  --line: #e4dcdc;
  --line-soft: #efe8e8;
  --accent: #e50914;
  --accent-hot: #c40812;
  --accent-soft: rgba(229, 9, 20, 0.1);
  --brand: #e50914;
  --brand-soft: rgba(229, 9, 20, 0.1);
  --unread: #e50914;
  --danger: #b20710;
  --shadow: 0 1px 2px rgba(40, 20, 20, 0.08);
  --shadow-lg: 0 16px 40px rgba(40, 20, 20, 0.12);
  --row-hover: #f8f1f1;
  --suggest-hover: rgba(229, 9, 20, 0.1);
  --focus-ring: 0 0 0 3px rgba(229, 9, 20, 0.18);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body:has(.mail-view:not([hidden])) {
  overflow: hidden;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

.brand {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.brand span { color: var(--accent); }

/* ——— Login (brand-first) ——— */
.login-view {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  overflow: hidden;
  background: #07070a;
  color: #f2f2f5;
}

.login-atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 480px at 18% -10%, rgba(229, 9, 20, 0.28), transparent 58%),
    radial-gradient(700px 420px at 92% 8%, rgba(229, 9, 20, 0.1), transparent 50%),
    radial-gradient(600px 380px at 50% 110%, rgba(255, 255, 255, 0.04), transparent 45%),
    linear-gradient(180deg, #0c0c10 0%, #07070a 55%, #050507 100%);
  animation: ambience 10s ease-in-out infinite alternate;
}

.login-stage {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  display: grid;
  gap: 1.5rem;
}

.login-hero {
  text-align: center;
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-eyebrow {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.45);
}

.login-brand {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 3.15rem);
  line-height: 1;
  color: #fff;
}

.login-tagline {
  margin: 0.75rem 0 0;
  color: rgba(242, 242, 245, 0.62);
  font-size: 0.98rem;
  font-weight: 500;
}

.login-panel {
  padding: 1.65rem 1.5rem 1.45rem;
  background: rgba(18, 18, 24, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  animation: rise 0.65s 0.08s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-heading {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: #fff;
}

.lede {
  margin: 0 0 1.25rem;
  color: rgba(200, 200, 210, 0.75);
  line-height: 1.45;
  font-size: 0.92rem;
}

.login-panel label,
#compose-form label,
#settings-form label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.login-view label { color: rgba(200, 200, 210, 0.78); }

input, textarea, select {
  width: 100%;
  padding: 0.72rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.login-view input,
.login-view textarea {
  background: rgba(8, 8, 12, 0.65);
  border-color: rgba(255, 255, 255, 0.1);
  color: #f2f2f5;
}

input:focus, textarea:focus, select:focus {
  border-color: rgba(229, 9, 20, 0.75);
  box-shadow: var(--focus-ring);
}

.btn-primary,
button[type="submit"] {
  appearance: none;
  width: 100%;
  padding: 0.88rem 1.1rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--accent-hot), var(--accent));
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: -0.01em;
  transition: filter 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 22px rgba(229, 9, 20, 0.28);
}

.btn-primary:hover,
button[type="submit"]:hover {
  filter: brightness(1.06);
}

.btn-primary:active,
button[type="submit"]:active {
  transform: scale(0.985);
}

.btn-primary:focus-visible,
button[type="submit"]:focus-visible,
.btn-ghost:focus-visible,
.btn-compose:focus-visible,
.mailbox-nav button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-forgot {
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 0.7rem;
  padding: 0.4rem;
  border: none;
  background: transparent;
  color: rgba(255, 90, 95, 0.95);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-forgot:hover { color: #fff; }

.btn-forgot-back {
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(200, 200, 210, 0.7);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  margin-bottom: 0.75rem;
}

.btn-forgot-back:hover { color: #ff5a5f; }

.forgot-panel { margin-top: 0.25rem; animation: rise 0.35s ease both; }

.forgot-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 650;
  color: #fff;
}

.forgot-lede {
  margin: 0 0 1rem;
  color: rgba(200, 200, 210, 0.7);
  font-size: 0.9rem;
  line-height: 1.4;
}

.forgot-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.forgot-tab {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 8, 12, 0.45);
  color: rgba(200, 200, 210, 0.75);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.55rem 0.4rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.forgot-tab.is-active {
  border-color: rgba(229, 9, 20, 0.65);
  color: #ff7a7f;
  background: rgba(229, 9, 20, 0.14);
}

.forgot-mode label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(200, 200, 210, 0.78);
}

.forgot-mode textarea {
  resize: vertical;
  min-height: 4rem;
}

.btn-secondary {
  appearance: none;
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #f2f2f5;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: rgba(229, 9, 20, 0.55);
  color: #ff7a7f;
}

.forgot-mode > button:not(.btn-secondary):not(.btn-primary) {
  appearance: none;
  width: 100%;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--accent-hot), var(--accent));
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.forgot-mode > button:disabled,
.btn-secondary:disabled,
.btn-primary:disabled {
  opacity: 0.65;
  cursor: wait;
}

.forgot-status {
  margin-top: 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(62, 207, 142, 0.12);
  color: #7dffc0;
  font-size: 0.88rem;
  line-height: 1.4;
}

.error {
  color: #ff8b91;
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

/* ——— Mail shell ——— */
.mail-view {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(820px 380px at 0% 0%, rgba(229, 9, 20, 0.09), transparent 55%),
    var(--bg);
  animation: fade 0.4s ease both;
}

.mail-view.reader-open {
  grid-template-columns: 220px minmax(240px, 0.9fr) minmax(340px, 1.25fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.95rem 0.75rem 0.85rem 0.85rem;
  background:
    linear-gradient(180deg, rgba(229, 9, 20, 0.05), transparent 28%),
    var(--bg-side);
  border-right: 1px solid var(--line);
  min-height: 0;
  overflow: auto;
}

.sidebar-brand {
  padding: 0.25rem 0.45rem 0.35rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.sidebar-user-meta {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.sidebar-brand-text {
  font-size: 1.15rem;
}

.user-email {
  color: var(--muted);
  font-size: 0.76rem;
  word-break: break-all;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 750;
  font-size: 0.95rem;
  color: #fff;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.user-avatar.lg {
  width: 52px;
  height: 52px;
  font-size: 1.15rem;
  border-radius: 14px;
}

.quota-box {
  margin-top: auto;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
}

.quota-text { margin-bottom: 0.35rem; }

.usage-bar {
  width: 100%;
  height: 5px;
  background: var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
}

.usage-bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), #ff5a5f);
  transition: width 0.35s ease;
}

.mailbox-nav {
  display: grid;
  gap: 0.15rem;
  flex: 1;
  padding-right: 0.15rem;
}

.mailbox-nav button {
  appearance: none;
  border: 0;
  text-align: left;
  background: transparent;
  color: var(--ink-2);
  padding: 0.58rem 0.95rem;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 0.92rem;
  transition: background 0.14s ease, color 0.14s ease, transform 0.12s ease;
}

.mailbox-nav button:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

html[data-theme="light"] .mailbox-nav button:hover {
  background: rgba(0, 0, 0, 0.04);
}

.mailbox-nav button.active {
  background: var(--brand-soft);
  color: var(--accent-hot);
  font-weight: 650;
}

.badge {
  min-width: 1.35rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--brand);
  background: transparent;
  font-weight: 700;
}

.sidebar-footer {
  display: grid;
  gap: 0.15rem;
  padding-top: 0.25rem;
}

.sidebar .btn-ghost {
  justify-content: flex-start;
  width: 100%;
  border-radius: 10px;
}

.account-switcher {
  margin: 0 0 0.35rem;
  padding: 0 0.1rem;
}

.account-switcher-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.account-switcher select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-compose {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 0.85rem 1.2rem;
  background: linear-gradient(180deg, var(--accent-hot), var(--accent));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(229, 9, 20, 0.28);
  transition: filter 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-compose::before {
  content: "✎";
  font-size: 1rem;
}

.btn-compose:hover {
  filter: brightness(1.06);
  box-shadow: 0 12px 28px rgba(229, 9, 20, 0.34);
}

.btn-compose:active { transform: scale(0.985); }

.btn-ghost {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

a.btn-ghost {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-ghost:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

html[data-theme="light"] .btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
}

.btn-ghost.danger:hover {
  color: var(--danger);
  background: var(--accent-soft);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  border-left: 1px solid var(--line);
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.main-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.message-list {
  overflow: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}

.message-row {
  width: 100%;
  appearance: none;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  text-align: left;
  padding: 0.65rem 1rem 0.65rem 0.85rem;
  cursor: pointer;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: start;
  transition: background 0.14s ease, box-shadow 0.14s ease;
  animation: rowIn 0.28s ease both;
}

.message-row:hover {
  background: var(--row-hover);
  box-shadow: inset 3px 0 0 rgba(229, 9, 20, 0.35);
}

.message-row.unread {
  box-shadow: inset 3px 0 0 var(--unread);
}

.message-row.unread .from,
.message-row.unread .subject {
  font-weight: 700;
  color: var(--ink);
}

.message-row .avatar {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
}

.row-main { min-width: 0; }

.from {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.1rem;
}

.subject-line {
  display: flex;
  gap: 0.4rem;
  min-width: 0;
  align-items: baseline;
}

.subject {
  font-size: 0.88rem;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  max-width: 55%;
}

.preview {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.meta {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 0.15rem;
}

.message-row.unread .meta {
  color: var(--unread);
  font-weight: 650;
}

.empty {
  padding: 4rem 1.5rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.reader {
  border-left: 1px solid var(--line);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  animation: slide 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.reader-header {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}

.reader-body {
  padding: 1.35rem 1.5rem 2rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}

.reader-body h3 {
  margin: 0 0 1rem;
  font-size: clamp(1.2rem, 2.4vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.reader-meta {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  line-height: 1.45;
}

.reader-content {
  white-space: pre-wrap;
  line-height: 1.65;
  color: var(--ink-2);
  font-size: 0.95rem;
}

.reader-html {
  line-height: 1.55;
  color: var(--ink-2);
  font-size: 0.95rem;
  overflow-x: auto;
  max-width: 100%;
}

.reader-html img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.reader-html a { color: var(--brand); }

.attachments {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.attachments h4 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.attachments a {
  display: inline-block;
  margin: 0.25rem 0.5rem 0.25rem 0;
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}

.attachments a:hover { text-decoration: underline; }

.attachments img.preview {
  display: block;
  max-width: min(360px, 100%);
  margin: 0.5rem 0 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
}

/* ——— Dialogs ——— */
dialog {
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  width: min(560px, calc(100vw - 1.5rem));
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
  animation: fade 0.2s ease both;
}

dialog[open] {
  animation: rise 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

#compose-form,
#settings-form {
  padding: 1.35rem 1.4rem 1.25rem;
}

#compose-form h3,
#settings-form h3 {
  margin: 0 0 1rem;
  font-weight: 750;
  font-size: 1.3rem;
  letter-spacing: -0.03em;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

#compose-send,
#settings-form .btn-primary,
#settings-form button[type="submit"] {
  width: auto;
  min-width: 7.5rem;
  border-radius: 999px;
  padding: 0.65rem 1.35rem;
}

.compose-status {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.35rem 0;
}

.compose-file-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.compose-file-list li {
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  background: var(--bg);
  margin-bottom: 0.25rem;
  border: 1px solid var(--line-soft);
}

.attach-label input[type="file"] {
  padding: 0.45rem 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.to-wrap {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.to-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.to-field {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.6rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: text;
}

.to-field:focus-within {
  border-color: rgba(229, 9, 20, 0.75);
  box-shadow: var(--focus-ring);
}

.to-field #compose-to {
  flex: 1 1 140px;
  min-width: 120px;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0.35rem 0.15rem !important;
  margin: 0;
  outline: none;
}

.compose-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-width: 100%;
}

.compose-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  max-width: 100%;
  padding: 0.2rem 0.35rem 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.2;
  border: 1px solid rgba(229, 9, 20, 0.25);
}

.compose-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.compose-chip-x {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.2rem;
  border-radius: 999px;
}

.compose-chip-x:hover {
  color: var(--brand);
  background: rgba(229, 9, 20, 0.12);
}

.field-hint,
.settings-hint {
  display: block;
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.settings-hint { margin: 0 0 1rem; font-size: 0.9rem; }

.compose-suggest {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 200px;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  scrollbar-width: thin;
  scrollbar-color: #5a4040 transparent;
}

.compose-suggest::-webkit-scrollbar { width: 8px; }
.compose-suggest::-webkit-scrollbar-track { background: transparent; }
.compose-suggest::-webkit-scrollbar-thumb {
  background: #5a4040;
  border-radius: 999px;
}

html[data-theme="light"] .compose-suggest {
  scrollbar-color: #c4b4b4 transparent;
}
html[data-theme="light"] .compose-suggest::-webkit-scrollbar-thumb {
  background: #c4b4b4;
}

.compose-suggest li button {
  width: 100%;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  font: inherit;
}

.compose-suggest li button:hover,
.compose-suggest li button:focus {
  background: var(--suggest-hover);
  outline: none;
}

.settings-block { margin-bottom: 1.1rem; }

.settings-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.theme-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.theme-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  border-radius: 10px;
  padding: 0.55rem;
  cursor: pointer;
  font-weight: 600;
}

.theme-btn.active {
  border-color: rgba(229, 9, 20, 0.55);
  color: var(--accent-hot);
  background: var(--brand-soft);
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.65rem;
}

.avatar-letter-label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.avatar-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.avatar-colors button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  appearance: none;
}

.avatar-colors button.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}

/* ——— Motion ——— */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slide {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes rowIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

@keyframes ambience {
  from { filter: saturate(1) brightness(1); }
  to { filter: saturate(1.08) brightness(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 900px) {
  .mail-view,
  .mail-view.reader-open {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.85rem;
  }

  .sidebar-brand {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
  }

  .btn-compose { width: 100%; }

  .mailbox-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    flex: 0;
    padding-right: 0;
  }

  .mailbox-nav button {
    flex: 1 1 auto;
    border-radius: 999px;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
  }

  .mailbox-nav button.active { border-color: transparent; }

  .quota-box { margin-top: 0; }

  .sidebar-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .sidebar-footer .btn-ghost { width: auto; }

  .message-row {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .message-row .meta {
    grid-column: 2;
    justify-self: start;
  }

  .reader {
    position: fixed;
    inset: 0;
    z-index: 20;
    border-left: 0;
    padding-bottom: var(--safe-bottom);
    height: 100dvh;
    max-height: 100dvh;
  }
}
