/* EpicMail — общий стиль сайта и веб-почты. Без внешних шрифтов и CDN (CSP: только 'self'). */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e3e7ef;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #5b4cf0;
  --accent-2: #8b5cf6;
  --accent-soft: #eeebff;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --ok: #059669;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f1a;
    --surface: #121827;
    --surface-2: #182033;
    --border: #243049;
    --text: #e6e9f2;
    --muted: #93a0b8;
    --accent: #7c6cff;
    --accent-2: #a78bfa;
    --accent-soft: #221f45;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- Бренд */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 19px; letter-spacing: -.02em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand b { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---- Кнопки и поля */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font: 600 15px var(--font); cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-text); box-shadow: 0 6px 18px rgba(91, 76, 240, .28); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.input { width: 100%; height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 15px var(--font); }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.input[disabled] { background: var(--surface-2); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 10px 0 0 10px; }
.input-group .suffix { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border); border-left: 0; border-radius: 0 10px 10px 0; background: var(--surface-2); color: var(--muted); font-size: 14px; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: var(--accent-soft); color: var(--text); border: 1px solid transparent; }
@media (prefers-color-scheme: dark) { .alert-error { background: #3b1219; color: #fecaca; border-color: #5b1d27; } }

/* ---- Публичные страницы */
.site-header { max-width: 1120px; margin: 0 auto; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; }
.site-header nav { display: flex; gap: 10px; }
.hero { max-width: 1120px; margin: 0 auto; padding: 56px 24px 32px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(34px, 5vw, 56px); letter-spacing: -.035em; margin-bottom: 18px; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { font-size: 18px; color: var(--muted); max-width: 520px; margin: 0 0 28px; }
.hero .cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 18px; }
.mock-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; }
.mock-row + .mock-row { border-top: 1px solid var(--border); border-radius: 0; }
.mock-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; }
.mock-row b { display: block; font-size: 14px; }
.mock-row small { color: var(--muted); font-size: 13px; }
.features { max-width: 1120px; margin: 0 auto; padding: 24px 24px 64px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.feature .ico { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 12px; }
.feature .ico svg { width: 22px; height: 22px; }
.feature h3 { font-size: 16px; }
.feature p { color: var(--muted); margin: 0; font-size: 14px; }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.site-footer div { max-width: 1120px; margin: 0 auto; padding: 20px 24px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; padding-top: 24px; }
  .features { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) { .features { grid-template-columns: 1fr; } }

/* ---- Вход и регистрация */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 32px; }
.auth-card .brand { margin-bottom: 22px; }
.auth-card h1 { font-size: 24px; letter-spacing: -.02em; }
.auth-card p.sub { color: var(--muted); margin: 0 0 22px; }
.auth-card .btn { width: 100%; }
.auth-card .alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }

/* ---- Веб-почта */
.app { height: 100vh; display: grid; grid-template-rows: 60px 1fr; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .search { flex: 1; max-width: 560px; }
.topbar .search .input { height: 38px; background: var(--surface-2); border-color: transparent; }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.topbar .who form { margin: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.main { display: grid; grid-template-columns: 232px 400px 1fr; min-height: 0; }
.sidebar { padding: 14px 10px; overflow: auto; border-right: 1px solid var(--border); }
.sidebar .btn { width: 100%; margin-bottom: 12px; }
.folder { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; color: var(--text); font-size: 14px; }
.folder:hover { background: var(--surface-2); text-decoration: none; }
.folder.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.folder svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.folder .count { margin-left: auto; font-size: 12px; font-weight: 700; }
.list { border-right: 1px solid var(--border); overflow: auto; background: var(--surface); }
.list-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.list-head h2 { font-size: 17px; margin: 0; }
.list-head small { color: var(--muted); }
.msg { display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.msg:hover { background: var(--surface-2); text-decoration: none; }
.msg.active { background: var(--accent-soft); }
.msg .line1 { display: flex; gap: 8px; align-items: baseline; }
.msg .from { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .date { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.msg .subject { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .preview { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.unread .from, .msg.unread .subject { font-weight: 700; }
.msg.unread .date { color: var(--accent); font-weight: 600; }
.msg .clip { width: 14px; height: 14px; color: var(--muted); flex: none; }
.pager { display: flex; justify-content: space-between; padding: 12px 16px; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty svg { width: 56px; height: 56px; opacity: .35; margin-bottom: 8px; }
.reader { display: grid; grid-template-rows: auto auto 1fr; min-height: 0; background: var(--surface); }
.reader-head { padding: 18px 24px 12px; border-bottom: 1px solid var(--border); }
.reader-head .toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.reader-head h1 { font-size: 21px; letter-spacing: -.01em; margin-bottom: 12px; }
.reader-meta { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; font-size: 14px; }
.reader-meta .avatar { width: 40px; height: 40px; font-size: 15px; }
.reader-meta .addr { color: var(--muted); font-size: 13px; }
.reader-meta time { color: var(--muted); font-size: 13px; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 24px; border-bottom: 1px solid var(--border); }
.attachment { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text); background: var(--surface-2); }
.attachment small { color: var(--muted); }
.reader iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.notice { padding: 8px 24px; font-size: 13px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.back { display: none; }
@media (max-width: 1180px) { .main { grid-template-columns: 200px 340px 1fr; } }
@media (max-width: 900px) {
  .app { grid-template-rows: 56px 1fr; }
  .main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { display: flex; gap: 6px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px; }
  .list, .reader { grid-row: 2; }
  .sidebar .btn { display: none; }
  .folder { white-space: nowrap; }
  .topbar .search { display: none; }
  .has-reader .list { display: none; }
  .main:not(.has-reader) .reader { display: none; }
  .back { display: inline-flex; }
}
