:root {
  --bg: #0f1220;
  --panel: #171b2f;
  --panel2: #1f2540;
  --border: rgba(135, 37, 231, 0.35);
  --primary: rgb(135, 37, 231);
  --primary2: rgb(168, 92, 255);
  --text: #f2f4ff;
  --muted: #9aa3c7;
  --danger: #ff5d6c;
  --ok: #31d199;
  --shadow: 0 18px 55px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Arial, sans-serif; background: radial-gradient(circle at top left, #26215a, var(--bg) 45%); color: var(--text); min-height: 100vh; }
button, input, textarea { font: inherit; }
button { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
button:hover { filter: brightness(1.15); }
button.primary { background: linear-gradient(135deg, var(--primary), var(--primary2)); border-color: transparent; font-weight: 700; }
button.danger { color: white; background: rgba(255, 93, 108, .18); border-color: rgba(255, 93, 108, .35); }
button.ghost { background: transparent; }
button.full { width: 100%; margin: 10px 0; }
input, textarea, select { width: 100%; background: rgba(255,255,255,.06); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none; }
textarea { resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
code { color: #d7c4ff; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { background: rgba(255,93,108,.13); border: 1px solid rgba(255,93,108,.35); color: #ffd1d6; padding: 10px; border-radius: 10px; margin: 10px 0; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.35; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(440px, 100%); background: rgba(23,27,47,.9); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 18px; padding: 26px; }
.auth-card h1 { margin: 0 0 6px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0; }
.tabs button.active { background: var(--primary); }
.mail-screen { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: rgba(15,18,32,.82); border-right: 1px solid var(--border); padding: 18px; position: sticky; top: 0; height: 100vh; }
.brand h2 { margin: 0 0 4px; }
nav { display: grid; gap: 8px; margin: 10px 0 20px; }
.folder { text-align: left; display: flex; justify-content: space-between; align-items: center; }
.folder.active { background: rgba(135,37,231,.35); }
#inboxBadge, #draftBadge { color: var(--ok); font-weight: 700; }
.content { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); background: rgba(15,18,32,.45); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.topbar h2 { margin: 0; }
.search-wrap { display: flex; gap: 8px; min-width: 360px; }
.layout { display: grid; grid-template-columns: minmax(320px, 42%) 1fr; gap: 16px; padding: 16px; height: calc(100vh - 74px); }
.list-panel, .read-panel { min-height: 0; overflow: auto; background: rgba(23,27,47,.72); border: 1px solid var(--border); border-radius: 16px; }
.message-list { display: grid; gap: 8px; padding: 10px; }
.message-card { padding: 12px; border: 1px solid rgba(255,255,255,.08); border-radius: 12px; background: rgba(255,255,255,.04); cursor: pointer; }
.message-card:hover { border-color: var(--primary); }
.message-card.active { background: rgba(135,37,231,.18); }
.message-card.unread .subject { font-weight: 800; }
.message-card .meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.subject { margin: 7px 0 5px; }
.preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader { padding: 18px; }
.reader h2 { margin: 0 0 8px; }
.reader-meta { color: var(--muted); font-size: 13px; line-height: 1.6; border-bottom: 1px solid rgba(255,255,255,.08); padding-bottom: 12px; margin-bottom: 14px; }
.reader-body { white-space: pre-wrap; line-height: 1.5; }
.reader-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.attachments { margin-top: 16px; }
.attachment-link { display: block; color: #d7c4ff; margin: 6px 0; word-break: break-all; }
.empty-state { min-height: 100%; display: grid; place-items: center; color: var(--muted); padding: 20px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(2px); z-index: 20; }
.modal { position: fixed; z-index: 30; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 28px)); max-height: calc(100vh - 36px); overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); }
.modal.wide { width: min(840px, calc(100vw - 28px)); }
.modal.admin { width: min(1100px, calc(100vw - 28px)); }
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.attachment-row { display: flex; gap: 8px; margin: 8px 0; }
.attachment-row button { flex: 0 0 auto; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.admin-card { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 14px; }
.admin-card h3 { margin-top: 0; }
.inline { display: flex; gap: 8px; align-items: center; }
.admin-list { display: grid; gap: 8px; margin-top: 10px; max-height: 330px; overflow: auto; }
.admin-row { background: rgba(0,0,0,.15); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; padding: 10px; }
.admin-row .row-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.checkbox { display: flex; gap: 8px; align-items: center; }
.checkbox input { width: auto; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #14182b; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; z-index: 50; box-shadow: var(--shadow); }
@media (max-width: 900px) {
  .mail-screen { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .search-wrap { min-width: 0; }
  .admin-grid { grid-template-columns: 1fr; }
}
