/* ===================================================================
   StuMailHub - shared stylesheet

   Two visual modes share one set of tokens:
     - the marketing pages (home, about, sign in): airy, centred
     - the mail app (inbox, message, compose, accounts): a Gmail-style
       shell with a fixed top bar, a left folder rail and dense rows

   Light/dark via prefers-color-scheme, with a data-theme override on
   <html> for the manual toggle. No inline styles anywhere: the CSP in
   bootstrap.php forbids them.
   =================================================================== */

:root {
  --bg: #f6f8fc;
  --bg-glow-a: rgba(26, 115, 232, 0.12);
  --bg-glow-b: rgba(66, 133, 244, 0.10);
  --card: rgba(255, 255, 255, 0.88);
  --card-solid: #ffffff;
  --card-border: #dadce0;
  --text: #202124;
  --muted: #5f6368;
  --faint: #80868b;
  --accent: #1a73e8;
  --accent-text: #ffffff;
  --accent-soft: rgba(26, 115, 232, 0.10);
  --accent-softer: rgba(26, 115, 232, 0.05);
  --accent-hover: #1557b0;
  --danger: #d93025;
  --danger-soft: rgba(217, 48, 37, 0.09);
  --ok: #188038;
  --ok-soft: rgba(24, 128, 56, 0.10);
  --shadow: 0 24px 60px -24px rgba(32, 33, 36, 0.28);
  --shadow-sm: 0 1px 3px rgba(60, 64, 67, 0.16);
  --shadow-row: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  --radius: 16px;
  --radius-sm: 10px;

  /* app shell - Gmail-style */
  --app-bg: #f6f8fc;
  --app-surface: #ffffff;
  --app-line: #e8eaed;
  --row-read: #f6f8fc;
  --row-unread: #ffffff;
  --hover: rgba(32, 33, 36, 0.04);
  --compose-bg: #c2e7ff;
  --compose-text: #001d35;
  --nav-active: #d3e3fd;
  --nav-active-text: #0b57d0;
  --search-bg: #eaf1fb;
  --rail: 256px;
  --topbar: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131314;
    --bg-glow-a: rgba(138, 180, 248, 0.18);
    --bg-glow-b: rgba(66, 133, 244, 0.14);
    --card: rgba(32, 33, 36, 0.82);
    --card-solid: #1e1f20;
    --card-border: #3c4043;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --faint: #80868b;
    --accent: #8ab4f8;
    --accent-text: #062e6f;
    --accent-soft: rgba(138, 180, 248, 0.16);
    --accent-softer: rgba(138, 180, 248, 0.08);
    --accent-hover: #aecbfa;
    --danger: #f28b82;
    --danger-soft: rgba(242, 139, 130, 0.14);
    --ok: #81c995;
    --ok-soft: rgba(129, 201, 149, 0.14);
    --shadow: 0 24px 70px -28px rgba(0, 0, 0, 0.8);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-row: 0 1px 2px 0 rgba(0, 0, 0, 0.6), 0 1px 3px 1px rgba(0, 0, 0, 0.4);

    --app-bg: #131314;
    --app-surface: #1e1f20;
    --app-line: #3c4043;
    --row-read: #131314;
    --row-unread: #1e1f20;
    --hover: rgba(232, 234, 237, 0.08);
    --compose-bg: #004a77;
    --compose-text: #c2e7ff;
    --nav-active: #0842a0;
    --nav-active-text: #d3e3fd;
    --search-bg: #2a2b2d;
  }
}

:root[data-theme="dark"] {
  --bg: #131314;
  --bg-glow-a: rgba(138, 180, 248, 0.18);
  --bg-glow-b: rgba(66, 133, 244, 0.14);
  --card: rgba(32, 33, 36, 0.82);
  --card-solid: #1e1f20;
  --card-border: #3c4043;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --faint: #80868b;
  --accent: #8ab4f8;
  --accent-text: #062e6f;
  --accent-soft: rgba(138, 180, 248, 0.16);
  --accent-softer: rgba(138, 180, 248, 0.08);
  --accent-hover: #aecbfa;
  --danger: #f28b82;
  --danger-soft: rgba(242, 139, 130, 0.14);
  --ok: #81c995;
  --ok-soft: rgba(129, 201, 149, 0.14);
  --shadow: 0 24px 70px -28px rgba(0, 0, 0, 0.8);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-row: 0 1px 2px 0 rgba(0, 0, 0, 0.6), 0 1px 3px 1px rgba(0, 0, 0, 0.4);

  --app-bg: #131314;
  --app-surface: #1e1f20;
  --app-line: #3c4043;
  --row-read: #131314;
  --row-unread: #1e1f20;
  --hover: rgba(232, 234, 237, 0.08);
  --compose-bg: #004a77;
  --compose-text: #c2e7ff;
  --nav-active: #0842a0;
  --nav-active-text: #d3e3fd;
  --search-bg: #2a2b2d;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body.has-glow::before {
  content: "";
  position: fixed;
  inset: -20%;
  background:
    radial-gradient(42rem 42rem at 18% 12%, var(--bg-glow-a), transparent 65%),
    radial-gradient(38rem 38rem at 82% 88%, var(--bg-glow-b), transparent 60%);
  filter: blur(8px);
  z-index: -1;
  pointer-events: none;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.18; margin: 0 0 14px; }
h1 { font-size: clamp(1.9rem, 5vw, 3rem); }
h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 16px; color: var(--muted); }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 760px; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-text);
  padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0; z-index: 100;
}
.skip:focus { left: 0; }

/* ===================================================================
   Marketing header
   =================================================================== */

.site-head {
  position: sticky; top: 0; z-index: 50;
  background: var(--card);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
}
.site-head .inner { display: flex; align-items: center; gap: 18px; height: 64px; }

.logo {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; letter-spacing: -0.01em; font-size: 1.05rem;
  color: var(--text); text-decoration: none; flex-shrink: 0;
}
.logo:hover { text-decoration: none; }
.logo svg { width: 26px; height: 26px; color: var(--accent); }

.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav a {
  padding: 8px 13px; border-radius: 999px;
  color: var(--muted); font-size: 0.93rem; font-weight: 500;
}
.nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); font-weight: 600; }

.theme-toggle {
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--card-border); border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }

/* ===================================================================
   Buttons
   =================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border: 1px solid transparent; border-radius: 999px;
  font: inherit; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--card-border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-quiet { background: transparent; color: var(--muted); border-color: transparent; }
.btn-quiet:hover { background: var(--hover); color: var(--text); }
.btn-sm { padding: 7px 14px; font-size: 0.87rem; }
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ===================================================================
   Marketing sections
   =================================================================== */

.hero { padding: 84px 0 64px; text-align: center; }
.hero .badge { margin-bottom: 24px; }
.hero p.lead { max-width: 54ch; margin: 0 auto 32px; font-size: 1.12rem; color: var(--muted); }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.addr-demo {
  display: inline-flex; align-items: center; gap: 2px;
  margin-top: 44px; padding: 14px 20px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 999px; box-shadow: var(--shadow-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(0.85rem, 2.6vw, 1.05rem);
  max-width: 100%; overflow-x: auto;
}
.addr-demo .you { color: var(--accent); font-weight: 600; }
.addr-demo .at { color: var(--faint); }

.section { padding: 64px 0; }
.section-head { text-align: center; max-width: 60ch; margin: 0 auto 44px; }
.section-head p { font-size: 1.03rem; }

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow-sm);
}
.card h3 { margin-bottom: 8px; }
.card p { margin: 0; font-size: 0.95rem; }
.card .icon {
  display: grid; place-items: center;
  width: 42px; height: 42px; margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
}
.card .icon svg { width: 21px; height: 21px; }

.steps { counter-reset: step; display: grid; gap: 20px; padding: 0; margin: 0; }
.steps li { counter-increment: step; position: relative; list-style: none; padding-left: 56px; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 0.95rem;
}
.steps h3 { margin-bottom: 4px; }
.steps p { margin: 0; font-size: 0.95rem; }

.cta {
  text-align: center; padding: 52px 28px;
  background: var(--accent-soft); border: 1px solid var(--card-border);
  border-radius: var(--radius);
}
.cta h2 { margin-bottom: 10px; }
.cta p { max-width: 46ch; margin: 0 auto 24px; }

.prose h2 { margin-top: 40px; }
.prose ul { padding-left: 22px; color: var(--muted); }
.prose li { margin-bottom: 9px; }

.site-foot {
  margin-top: 40px; padding: 36px 0;
  border-top: 1px solid var(--card-border);
  font-size: 0.9rem; color: var(--muted);
}
.site-foot .inner { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; }
.site-foot nav { margin-left: auto; display: flex; gap: 20px; flex-wrap: wrap; }
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--accent); }

/* ===================================================================
   Forms
   =================================================================== */

.auth-shell { display: grid; place-items: center; padding: 56px 16px; }
.auth-card {
  width: 100%; max-width: 440px; padding: 36px 32px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 24px; box-shadow: var(--shadow); backdrop-filter: blur(16px);
}
.auth-card h1 { font-size: 1.6rem; margin-bottom: 6px; text-align: center; }
.auth-card .sub { text-align: center; margin-bottom: 28px; font-size: 0.95rem; }

.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 7px; font-size: 0.88rem; font-weight: 600; color: var(--text); }
.input {
  width: 100%; padding: 12px 14px;
  background: var(--card-solid); color: var(--text);
  border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  font: inherit; font-size: 0.97rem;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--faint); }
select.input { appearance: none; cursor: pointer; }
textarea.input { resize: vertical; min-height: 220px; line-height: 1.65; }

.alert {
  padding: 12px 15px; margin-bottom: 20px;
  border-radius: var(--radius-sm); font-size: 0.92rem;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.alert-info { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.hint { font-size: 0.85rem; color: var(--faint); margin: 0; }
.auth-foot { margin-top: 22px; text-align: center; font-size: 0.9rem; }

/* ===================================================================
   App shell - top bar
   =================================================================== */

body.app-shell { background: var(--app-bg); }

.app-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  height: var(--topbar);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--app-bg);
  border-bottom: 1px solid var(--app-line);
}
.app-top .logo { min-width: 0; }

.app-search { flex: 1 1 auto; max-width: 720px; min-width: 0; }
.app-search form { display: flex; align-items: center; gap: 12px;
  background: var(--search-bg); border: 1px solid transparent;
  border-radius: 8px; padding: 0 16px; height: 48px;
  transition: background-color .15s, box-shadow .15s;
}
.app-search form:focus-within {
  background: var(--app-surface);
  border-color: transparent;
  box-shadow: var(--shadow-row);
}
.app-search svg { width: 18px; height: 18px; color: var(--faint); flex-shrink: 0; }
.app-search input {
  flex: 1 1 auto; min-width: 0;
  border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 0.95rem; outline: none;
}
.app-search input::placeholder { color: var(--faint); }

.app-top .who { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.app-top .who .addr {
  font-size: 0.88rem; color: var(--muted);
  max-width: 24vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.role-chip {
  padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; flex-shrink: 0;
}

/* ===================================================================
   App shell - folder rail
   =================================================================== */

.app-side {
  position: fixed; top: var(--topbar); bottom: 0; left: 0;
  width: var(--rail); z-index: 40;
  padding: 16px 10px 24px;
  overflow-y: auto;
  background: var(--app-bg);
}

.compose-btn {
  display: inline-flex; align-items: center; gap: 14px;
  margin: 0 8px 16px; padding: 16px 26px 16px 20px;
  border: 0; border-radius: 16px;
  background: var(--compose-bg); color: var(--compose-text);
  font: inherit; font-size: 0.9rem; font-weight: 600;
  box-shadow: var(--shadow-sm); cursor: pointer; text-decoration: none;
  transition: box-shadow .15s, filter .15s;
}
.compose-btn:hover { box-shadow: var(--shadow-row); filter: brightness(0.98); text-decoration: none; }
.compose-btn svg { width: 20px; height: 20px; }

.folder-list { list-style: none; margin: 0; padding: 0; }
.folder {
  display: flex; align-items: center; gap: 14px;
  height: 36px; padding: 0 14px 0 18px;
  border-radius: 0 999px 999px 0;
  color: var(--text); font-size: 0.88rem; text-decoration: none;
}
.folder:hover { background: var(--hover); text-decoration: none; }
.folder svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.folder .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .count { font-size: 0.78rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.folder.is-active { background: var(--nav-active); font-weight: 700; color: var(--nav-active-text); }
.folder.is-active svg, .folder.is-active .count { color: var(--nav-active-text); }

.rail-heading {
  margin: 20px 0 6px; padding: 0 18px;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--faint);
}

/* ===================================================================
   App shell - main column
   =================================================================== */

.app-main {
  margin-left: var(--rail);
  padding: calc(var(--topbar) + 16px) 16px 48px;
  min-height: 100vh;
}
.app-panel {
  background: var(--app-surface);
  border: 1px solid var(--app-line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.app-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--app-line);
  min-height: 52px;
}
.app-bar .title { font-weight: 700; font-size: 0.98rem; }
.app-bar .spacer { margin-left: auto; }
.app-bar .count { font-size: 0.84rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.app-bar form { display: flex; align-items: center; gap: 8px; }
.app-bar label { font-size: 0.84rem; color: var(--muted); font-weight: 600; }
.app-bar select.input { width: auto; min-width: 230px; padding: 7px 11px; font-size: 0.88rem; }

/* ===================================================================
   Message list
   =================================================================== */

.thread-list { list-style: none; margin: 0; padding: 0; }

.thread {
  display: grid;
  grid-template-columns: 34px 200px minmax(0, 1fr) 92px;
  align-items: center; gap: 14px;
  padding: 0 16px; height: 44px;
  border-bottom: 1px solid var(--app-line);
  background: var(--row-read);
  color: var(--text); text-decoration: none;
  position: relative;
}
.thread:last-child { border-bottom: 0; }
.thread:hover {
  box-shadow: var(--shadow-row);
  z-index: 1;
  text-decoration: none;
}
.thread.is-unread { background: var(--row-unread); }
.thread.is-unread .sender,
.thread.is-unread .subject,
.thread.is-unread .when { font-weight: 700; color: var(--text); }

.thread .sender { font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread .subject { font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread .subject .dash { color: var(--faint); font-weight: 400; }
.thread .meta { color: var(--faint); font-weight: 400; }
.thread .when {
  text-align: right; font-size: 0.78rem; color: var(--muted);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.thread .clip { color: var(--faint); display: inline-flex; }
.thread .clip svg { width: 14px; height: 14px; }

.avatar {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 0.8rem; font-weight: 700; color: #fff;
  text-transform: uppercase; user-select: none;
}
.avatar-0 { background: #1a73e8; }
.avatar-1 { background: #0891b2; }
.avatar-2 { background: #be185d; }
.avatar-3 { background: #047857; }
.avatar-4 { background: #b45309; }
.avatar-5 { background: #6d28d9; }

.pager { display: flex; gap: 10px; justify-content: center; align-items: center; padding: 18px 0 0; }
.pager .pos { font-size: 0.85rem; color: var(--faint); }

.empty { padding: 72px 24px; text-align: center; color: var(--muted); }
.empty svg { width: 44px; height: 44px; color: var(--faint); margin-bottom: 14px; }
.empty p { margin: 0; }

/* ===================================================================
   Reading a message
   =================================================================== */

.reading { padding: 0; }
.reading .head { padding: 22px 26px 0; }
.reading h1 { font-size: 1.35rem; line-height: 1.3; margin-bottom: 18px; }

.sender-row { display: flex; align-items: flex-start; gap: 14px; padding-bottom: 18px; }
.sender-row .avatar { width: 38px; height: 38px; font-size: 0.95rem; flex-shrink: 0; }
.sender-row .who { min-width: 0; flex: 1 1 auto; }
.sender-row .name { font-weight: 700; font-size: 0.95rem; }
.sender-row .addr { color: var(--faint); font-size: 0.85rem; overflow-wrap: anywhere; }
.sender-row .to { color: var(--muted); font-size: 0.85rem; margin-top: 3px; overflow-wrap: anywhere; }
.sender-row .when { color: var(--muted); font-size: 0.84rem; white-space: nowrap; flex-shrink: 0; }

.msg-body {
  padding: 22px 26px;
  border-top: 1px solid var(--app-line);
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 0.94rem; line-height: 1.7; color: var(--text);
}

/* A notice inside a panel: tighter than .msg-body, which is sized for
   a whole message body. */
.panel-note { padding: 14px 16px; }
.panel-note .alert { margin-bottom: 0; }
.panel-note .alert + .alert { margin-top: 10px; }

.attach { padding: 18px 26px; border-top: 1px solid var(--app-line); }
.attach h2 {
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--faint); margin-bottom: 12px; font-weight: 700;
}
.attach ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.attach li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; font-size: 0.88rem;
  border: 1px solid var(--app-line); border-radius: 10px;
  background: var(--app-bg);
}
.attach svg { width: 16px; height: 16px; color: var(--faint); flex-shrink: 0; }
.attach .size { color: var(--faint); font-size: 0.8rem; }

.reply-bar { display: flex; gap: 10px; flex-wrap: wrap; padding: 18px 26px; border-top: 1px solid var(--app-line); }

.back-link {
  display: inline-flex; align-items: center; gap: 7px;
  margin-bottom: 14px; font-size: 0.9rem; font-weight: 600; color: var(--muted);
}
.back-link:hover { color: var(--accent); text-decoration: none; }
.back-link svg { width: 15px; height: 15px; }

/* ===================================================================
   Compose
   =================================================================== */

.compose { max-width: 820px; }
.compose .app-bar { background: var(--app-bg); }

.compose-fields { padding: 4px 0; }
.compose-row {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--app-line);
}
.compose-row label { width: 54px; flex-shrink: 0; font-size: 0.85rem; color: var(--faint); font-weight: 600; }
.compose-row input {
  flex: 1 1 auto; min-width: 0; border: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 0.92rem; padding: 13px 0; outline: none;
}
.compose-row .toggle { font-size: 0.82rem; font-weight: 600; color: var(--muted); }

.compose-body {
  width: 100%; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 0.94rem; line-height: 1.7;
  padding: 18px 20px; min-height: 300px; resize: vertical; outline: none;
}

.compose-foot {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 20px; border-top: 1px solid var(--app-line);
}
.compose-foot .spacer { margin-left: auto; }
.file-field { display: flex; align-items: center; gap: 10px; font-size: 0.86rem; color: var(--muted); }
.file-field input[type="file"] { font: inherit; font-size: 0.82rem; color: var(--muted); max-width: 260px; }

/* ===================================================================
   Admin: mailbox accounts
   =================================================================== */

.account-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.account-table th, .account-table td {
  text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--app-line);
}
.account-table th {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--faint); font-weight: 700;
}
.account-table td { color: var(--muted); }
.account-table td.addr { color: var(--text); font-weight: 600; }
.account-table tr:last-child td { border-bottom: 0; }

.new-account { padding: 20px 20px 4px; display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.addr-field { display: flex; align-items: stretch; }
.addr-field input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.addr-field .suffix {
  display: flex; align-items: center; padding: 0 13px;
  border: 1px solid var(--card-border); border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--app-bg); color: var(--faint);
  font-size: 0.9rem; white-space: nowrap;
}

/* ===================================================================
   Settings: self-service forwarding
   =================================================================== */

.settings-body { padding: 22px 24px 28px; max-width: 620px; }
.settings-lead { font-size: 0.96rem; color: var(--muted); margin-bottom: 22px; }
.settings-lead strong { color: var(--text); }

.forwarding-state {
  padding: 16px 18px; margin-bottom: 24px;
  border: 1px solid var(--app-line); border-radius: var(--radius-sm);
  background: var(--app-bg);
}
.forwarding-state .state-on {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 4px; font-size: 0.96rem; color: var(--text);
}
.forwarding-state .state-on strong { color: var(--accent); }
.forwarding-state .hint { margin-bottom: 14px; }
.forwarding-state form { margin: 0; }
.dot-on {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ok); flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--ok-soft);
}

.forwarding-form { margin: 0; }
.check {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 2px 0 20px; font-size: 0.92rem; color: var(--muted); cursor: pointer;
}
.check input { margin-top: 3px; flex-shrink: 0; accent-color: var(--accent); }

.forwarding-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.panel-aside {
  margin: 20px 0 0; padding-top: 16px;
  border-top: 1px solid var(--app-line);
  font-size: 0.85rem; color: var(--faint);
}
.panel-aside + .panel-aside { padding-top: 10px; border-top: 0; margin-top: 4px; }

/* ===================================================================
   Responsive
   =================================================================== */

@media (max-width: 1000px) {
  :root { --rail: 0px; }

  .app-side {
    position: static; width: auto; height: auto;
    padding: calc(var(--topbar) + 14px) 16px 0;
    display: flex; align-items: center; gap: 10px;
  }
  .compose-btn {
    position: fixed; right: 18px; bottom: 18px; z-index: 55;
    margin: 0; padding: 15px 22px;
  }
  .folder-list {
    display: flex; gap: 8px; overflow-x: auto;
    width: 100%; padding-bottom: 6px;
    scrollbar-width: none;
  }
  .folder-list::-webkit-scrollbar { display: none; }
  .folder {
    border-radius: 999px; padding: 0 16px; height: 34px;
    border: 1px solid var(--app-line); background: var(--app-surface);
    white-space: nowrap; flex-shrink: 0;
  }
  .rail-heading { display: none; }
  .app-main { margin-left: 0; padding-top: 14px; }
}

@media (max-width: 760px) {
  .hero { padding: 56px 0 44px; }
  .section { padding: 48px 0; }
  .nav a { padding: 8px 10px; font-size: 0.88rem; }
  .auth-card { padding: 28px 22px; }
  .site-foot nav { margin-left: 0; }

  .app-top { gap: 10px; padding: 0 12px; }
  .app-top .who .addr { display: none; }
  .app-main { padding-left: 10px; padding-right: 10px; }
  .app-side { padding-left: 10px; padding-right: 10px; }

  .thread {
    grid-template-columns: 34px minmax(0, 1fr) 62px;
    grid-template-rows: auto auto;
    height: auto; padding: 9px 12px; gap: 3px 12px;
    align-items: start;
  }
  .thread .avatar { grid-row: 1 / span 2; align-self: center; }
  .thread .sender { grid-column: 2; grid-row: 1; }
  .thread .when { grid-column: 3; grid-row: 1; }
  .thread .subject { grid-column: 2 / span 2; grid-row: 2; white-space: normal; }

  .reading .head, .msg-body, .attach, .reply-bar { padding-left: 16px; padding-right: 16px; }
  .sender-row .when { display: none; }
  .compose-row { padding: 0 14px; }
  .compose-body { padding: 16px 14px; }
}

@media (max-width: 480px) {
  .wrap { padding: 0 16px; }
  .site-head .inner { gap: 10px; }
  .nav { gap: 0; }
  .nav a { padding: 8px 8px; font-size: 0.85rem; white-space: nowrap; }
  .logo { font-size: 1rem; gap: 7px; }
  .logo svg { width: 23px; height: 23px; }
  .app-bar select.input { min-width: 0; width: 100%; }
  .app-bar form { flex: 1 1 100%; }
}

@media (max-width: 400px) {
  .logo span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
