:root {
  --accent: #a855f7;
  --accent2: #7c3aed;
  --accent-dark: #6d28d9;
  --accent-soft: #241633;
  --accent-glow: rgba(168,85,247,.45);
  --bg: #0a0710;
  --bg2: #0f0a17;
  --panel: #14101d;
  --panel2: #1b1526;
  --line: #2a2138;
  --text: #ece7f5;
  --muted: #a79bc0;
  --faint: #6f6488;
  --star: #f5c451;
  --danger: #f2547b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 12px 40px rgba(80,20,140,.14);
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); }
::selection { background: var(--accent-glow); }

.logo { font-family: "Fredoka", system-ui, sans-serif; font-weight: 600; letter-spacing: -.3px; display: inline-flex; align-items: center; gap: 9px; }
.logo .mark {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-size: 18px;
  box-shadow: 0 3px 14px var(--accent-glow);
}

/* ============ LANDING ============ */
.landing { min-height: 100%; display: flex; flex-direction: column; }
.landing.hide { display: none; }
.lnav { display: flex; align-items: center; padding: 20px 6vw; }
.lnav .logo { font-size: 24px; }
.lnav .spacer { flex: 1; }
.lnav .ghost { padding: 9px 20px; border-radius: 10px; border: 1.5px solid var(--line); font-weight: 600; }
.lnav .ghost:hover { border-color: var(--accent); color: var(--accent); }
.hero {
  flex: 1; display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center;
  padding: 3vh 6vw 6vh; max-width: 1240px; margin: 0 auto; width: 100%;
}
.hero-copy h1 { font-family: "Fredoka", sans-serif; font-size: clamp(38px, 5.5vw, 68px); line-height: 1.03; margin: 0 0 18px; letter-spacing: -1.5px; }
.hero-copy h1 .grad { background: linear-gradient(100deg, var(--accent), #d8b4fe); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-copy p.lead { font-size: 19px; color: var(--muted); max-width: 30em; line-height: 1.5; margin: 0 0 28px; }
.features { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.feat { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: 14px; font-weight: 500; }
.feat .fi { font-size: 18px; }
.hero-glow { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.hero-glow::before { content: ""; position: absolute; top: -20%; right: -10%; width: 60vw; height: 60vw; background: radial-gradient(circle, var(--accent-glow), transparent 60%); filter: blur(30px); opacity: .5; }
.hero-glow::after { content: ""; position: absolute; bottom: -30%; left: -10%; width: 50vw; height: 50vw; background: radial-gradient(circle, rgba(124,58,237,.35), transparent 60%); filter: blur(30px); opacity: .4; }
.hero-cta { display: flex; gap: 12px; margin-top: 30px; flex-wrap: wrap; }
.hero-cta .btn { width: auto; padding: 13px 26px; }
.hero-cta .btn.secondary { padding: 13px 24px; }

/* ---- section shell ---- */
.section { max-width: 1180px; margin: 0 auto; padding: 60px 6vw; }
.section-head { text-align: center; margin-bottom: 44px; }
.section-head .eyebrow { color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; }
.section-head h2 { font-family: "Fredoka", sans-serif; font-size: clamp(28px, 3.6vw, 42px); margin: 8px 0 10px; letter-spacing: -.8px; }
.section-head p { color: var(--muted); font-size: 17px; max-width: 34em; margin: 0 auto; }

/* ---- demo inbox window ---- */
.demo-window { max-width: 1000px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 30px 80px rgba(80,20,140,.22); }
.dw-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.dw-dot { width: 12px; height: 12px; border-radius: 50%; }
.dw-url { flex: 1; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px 12px; font-size: 12.5px; color: var(--muted); max-width: 300px; margin: 0 auto; }
.dw-url i { color: var(--accent); font-size: 11px; margin-right: 6px; }
.dw-body { display: grid; grid-template-columns: 168px 300px 1fr; height: 460px; }
.dw-side { border-right: 1px solid var(--line); padding: 14px 10px; background: var(--bg2); }
.dw-compose { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px; border-radius: 12px; background: linear-gradient(100deg, var(--accent2), var(--accent)); color: #fff; font-weight: 700; font-size: 13px; margin-bottom: 12px; }
.dw-folder { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 0 18px 18px 0; font-size: 13px; color: var(--muted); cursor: default; }
.dw-folder.on { background: var(--accent-soft); color: #d8b4fe; font-weight: 700; }
.dw-folder .c { margin-left: auto; font-size: 11px; color: var(--accent); font-weight: 700; }
.dw-folder i { width: 16px; text-align: center; }
.dw-list { border-right: 1px solid var(--line); overflow-y: auto; }
.dw-item { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.dw-item:hover { background: var(--panel2); }
.dw-item.on { background: var(--accent-soft); }
.dw-item.unread .dw-from, .dw-item.unread .dw-subj { font-weight: 700; color: var(--text); }
.dw-av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; }
.dw-from { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-subj { font-size: 12.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-time { font-size: 11px; color: var(--faint); white-space: nowrap; align-self: start; }
.dw-dotnew { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); align-self: center; }
.dw-reader { padding: 22px 26px; overflow-y: auto; }
.dw-reader h3 { margin: 0 0 14px; font-size: 20px; }
.dw-rmeta { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.dw-rmeta .dw-av { width: 40px; height: 40px; font-size: 15px; }
.dw-rname { font-weight: 700; font-size: 14px; }
.dw-raddr { color: var(--muted); font-size: 12.5px; }
.dw-rbody { line-height: 1.6; color: var(--text); font-size: 14.5px; }
.dw-rbody p { margin: 0 0 12px; }
.dw-hint { text-align: center; color: var(--faint); font-size: 13px; margin-top: 16px; }

/* ---- feature detail grid ---- */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.dcard { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px; transition: border-color .15s, transform .15s; }
.dcard:hover { border-color: var(--accent); transform: translateY(-3px); }
.dcard .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 20px; margin-bottom: 14px; }
.dcard h3 { margin: 0 0 8px; font-size: 17px; }
.dcard p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }

/* ---- specs strip ---- */
.specs { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.spec { flex: 1; min-width: 150px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px 16px; }
.spec .n { font-family: "Fredoka", sans-serif; font-size: 26px; color: var(--accent); font-weight: 700; }
.spec .l { color: var(--muted); font-size: 13px; margin-top: 4px; }

.lfoot { text-align: center; padding: 30px 24px; color: var(--faint); font-size: 13px; border-top: 1px solid var(--line); margin-top: 30px; }
.lfoot .flogo { font-family: "Fredoka", sans-serif; color: var(--text); font-weight: 600; }

@media (max-width: 860px) {
  .dw-body { grid-template-columns: 1fr; height: auto; }
  .dw-side { display: none; }
  .dw-list { max-height: 260px; }
  .dw-reader { border-top: 1px solid var(--line); }
  .detail-grid { grid-template-columns: 1fr; }
}

/* ============ AUTH CARD ============ */
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 34px 32px; justify-self: end; }
.auth-card .logo { font-size: 24px; margin-bottom: 6px; }
.auth-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field .row { display: flex; align-items: center; }
.field input, .field select { width: 100%; padding: 12px 13px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg2); transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .suffix { padding: 12px; border: 1.5px solid var(--line); border-left: none; border-radius: 0 10px 10px 0; background: var(--bg2); color: var(--muted); white-space: nowrap; }
.field .row input { border-radius: 10px 0 0 10px; }
.btn { width: 100%; padding: 13px; border-radius: 11px; background: linear-gradient(100deg, var(--accent2), var(--accent)); color: #fff; font-weight: 700; transition: filter .15s, transform .05s; box-shadow: 0 4px 16px var(--accent-glow); }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: transparent; color: var(--accent); border: 1.5px solid var(--line); box-shadow: none; }
.btn.secondary:hover { background: var(--accent-soft); }
.auth-toggle { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.auth-toggle button { color: var(--accent); font-weight: 600; }
.err { color: var(--danger); font-size: 13px; margin: 4px 0 12px; min-height: 16px; }
.hint { color: var(--faint); font-size: 12px; margin-top: 4px; }

/* ============ APP SHELL ============ */
.app { display: none; height: 100%; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); }
.app.on { display: grid; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg2); position: relative; z-index: 20; }
.topbar .logo { font-size: 21px; min-width: var(--sidebar-w); }
.search { flex: 1; max-width: 680px; display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1.5px solid transparent; border-radius: 12px; padding: 10px 14px; }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; border: none; background: none; }
.search input:focus { outline: none; }
.topbar .spacer { flex: 1; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #fff; display: grid; place-items: center; font-weight: 700; cursor: pointer; user-select: none; }
.iconbtn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.iconbtn:hover { background: var(--panel); color: var(--text); }

.impersonate { display: none; align-items: center; gap: 7px; background: var(--accent-soft); color: #d8b4fe; padding: 4px 14px; font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--line); }
.impersonate.on { display: flex; }
.impersonate i { font-size: 11px; }
.impersonate button { color: var(--accent); text-decoration: underline; font-weight: 700; margin-left: 2px; }

.body { display: flex; min-height: 0; }
.sidebar { width: var(--sidebar-w); flex: none; border-right: 1px solid var(--line); padding: 14px 10px; overflow-y: auto; background: var(--bg2); }
.compose-btn { display: flex; align-items: center; gap: 12px; padding: 14px 22px; border-radius: 16px; background: linear-gradient(100deg, var(--accent2), var(--accent)); color: #fff; font-weight: 700; font-size: 15px; margin-bottom: 14px; box-shadow: 0 4px 16px var(--accent-glow); }
.compose-btn:hover { filter: brightness(1.08); }
.folders { list-style: none; margin: 0; padding: 0; }
.folder { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: 0 22px 22px 0; color: var(--text); font-size: 14px; cursor: pointer; margin-right: 8px; user-select: none; }
.folder:hover { background: var(--panel); }
.folder.active { background: var(--accent-soft); color: #d8b4fe; font-weight: 700; }
.folder .ic { width: 20px; text-align: center; }
.folder .count { margin-left: auto; font-size: 12px; color: var(--accent); font-weight: 700; }
.side-add { margin-top: 8px; color: var(--muted); font-size: 13px; padding: 8px 14px; }
.side-add:hover { color: var(--accent); }
.side-section { margin-top: 18px; padding: 0 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); font-weight: 700; }

.list { flex: 1; min-width: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--panel); }
.body.reading .list { flex: 0 0 400px; }
.list-head { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--line); min-height: 48px; }
.list-title { font-weight: 700; font-size: 15px; padding-left: 6px; text-transform: capitalize; }
.list-head .spacer { flex: 1; }
.msgs { overflow-y: auto; flex: 1; }
.msg { display: grid; grid-template-columns: 24px 22px 1fr auto; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.msg:hover { background: var(--panel2); }
.msg.active { background: var(--accent-soft); }
.msg.unread .msg-from, .msg.unread .msg-subj b { font-weight: 700; color: var(--text); }
.msg-from { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.msg.unread .msg-from { color: var(--text); }
.msg-main { min-width: 0; }
.msg-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg-subj { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.msg-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.msg-date { font-size: 12px; color: var(--faint); white-space: nowrap; }
.star { color: var(--faint); font-size: 16px; background: none; }
.star.on { color: var(--star); }
.paperclip { color: var(--faint); font-size: 13px; }
.empty { padding: 60px 20px; text-align: center; color: var(--faint); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

.reader { display: none; flex: 1; min-width: 0; flex-direction: column; background: var(--bg2); }
.reader.on { display: flex; }
.reader-bar { display: flex; align-items: center; gap: 4px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.reader-bar .spacer { flex: 1; }
.reader-scroll { overflow-y: auto; flex: 1; padding: 26px 22px; }
.reader-card { max-width: 820px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 30px 34px; box-shadow: var(--shadow); }
.reader-subject { font-size: 25px; font-weight: 700; margin: 0 0 20px; line-height: 1.2; letter-spacing: -.4px; }
.reader-meta { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.reader-meta .avatar { width: 46px; height: 46px; font-size: 17px; flex-shrink: 0; }
.reader-from { font-weight: 700; font-size: 15px; }
.reader-fromaddr { color: var(--muted); font-size: 13px; font-weight: 400; }
.reader-to { color: var(--faint); font-size: 12.5px; margin-top: 3px; }
.reader-date { color: var(--faint); font-size: 12.5px; white-space: nowrap; align-self: flex-start; }
.reader-body { font-size: 15px; line-height: 1.65; color: var(--text); }
.reader-body iframe { width: 100%; border: none; min-height: 200px; background: #fff; border-radius: 10px; }
.reader-body .plain { white-space: pre-wrap; word-break: break-word; line-height: 1.65; }
.attachments { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.att { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 11px; font-size: 13px; color: var(--text); background: var(--bg2); font-weight: 500; }
.att:hover { border-color: var(--accent); color: var(--accent); }
.att i { color: var(--accent); }
.reader-actions { display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 10px 18px; border-radius: 11px; border: 1.5px solid var(--line); font-size: 14px; font-weight: 600; color: var(--text); }
.chip:hover { background: var(--panel2); }
.chip.primary { background: linear-gradient(100deg, var(--accent2), var(--accent)); color: #fff; border: none; box-shadow: 0 4px 14px var(--accent-glow); }

/* Compose */
.compose { position: fixed; bottom: 0; right: 24px; width: 560px; max-width: calc(100vw - 48px); background: var(--panel); border: 1px solid var(--line); border-bottom: none; border-radius: 14px 14px 0 0; box-shadow: 0 -4px 40px rgba(0,0,0,.5); display: none; flex-direction: column; z-index: 40; max-height: 84vh; }
.compose.on { display: flex; }
.compose-head { background: linear-gradient(100deg, var(--accent2), var(--accent)); color: #fff; padding: 12px 16px; border-radius: 14px 14px 0 0; display: flex; align-items: center; }
.compose-head .t { font-size: 14px; font-weight: 700; }
.compose-head .spacer { flex: 1; }
.compose-head button { color: #f3e8ff; }
.compose-fields { padding: 6px 16px; }
.crow { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.crow label { color: var(--muted); font-size: 13px; width: 52px; }
.crow input, .crow select { flex: 1; border: none; background: none; padding: 11px 4px; }
.crow input:focus, .crow select:focus { outline: none; }
.crow select { color: var(--accent); font-weight: 600; }
/* Searchable From combobox */
.combo { position: relative; flex: 1; min-width: 0; }
.combo-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 11px 4px; background: none; color: var(--accent); font-weight: 600; text-align: left; }
.combo-btn span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-btn i { color: var(--faint); font-size: 11px; transition: transform .15s; }
.combo.open .combo-btn i { transform: rotate(180deg); }
.combo-pop { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 45; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); display: none; overflow: hidden; }
.combo.open .combo-pop { display: block; }
.combo-search { width: 100%; padding: 11px 13px; border: none; border-bottom: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 13.5px; }
.combo-search:focus { outline: none; }
.combo-list { max-height: 230px; overflow-y: auto; padding: 4px; }
.combo-opt { padding: 9px 10px; font-size: 13.5px; cursor: pointer; display: flex; align-items: center; gap: 8px; border-radius: 8px; }
.combo-opt:hover, .combo-opt.active { background: var(--accent-soft); }
.combo-opt .chk { width: 14px; color: var(--accent); font-size: 12px; flex: none; }
.combo-opt span.a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-empty { padding: 14px; color: var(--faint); font-size: 13px; text-align: center; }
.crow .cc-toggle { color: var(--muted); font-size: 13px; padding: 0 6px; }
.compose-body { flex: 1; padding: 14px 16px; overflow-y: auto; min-height: 190px; line-height: 1.55; outline: none; }
.compose-body:empty:before { content: attr(data-ph); color: var(--faint); }
.compose-foot { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.send-btn { background: linear-gradient(100deg, var(--accent2), var(--accent)); color: #fff; font-weight: 700; padding: 11px 26px; border-radius: 22px; box-shadow: 0 4px 14px var(--accent-glow); }
.compose-foot .spacer { flex: 1; }
.att-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 10px; }
.att-list .att { font-size: 12px; }
.att-list .att button { color: var(--danger); font-weight: 700; }

/* Menu / toast / modal */
.menu { position: absolute; top: 54px; right: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 8px; min-width: 250px; display: none; z-index: 50; }
.menu.on { display: block; }
.menu .who { padding: 12px; text-align: center; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu .who .avatar { width: 56px; height: 56px; margin: 0 auto 8px; font-size: 22px; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 9px; width: 100%; text-align: left; font-size: 14px; color: var(--text); }
.menu-item:hover { background: var(--panel2); }
.badge-admin { display: inline-block; margin-left: 6px; font-size: 10px; background: var(--accent); color: #fff; padding: 2px 7px; border-radius: 20px; font-weight: 700; vertical-align: middle; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--panel2); border: 1px solid var(--line); color: #fff; padding: 13px 22px; border-radius: 11px; font-size: 14px; box-shadow: var(--shadow); opacity: 0; transition: all .25s; z-index: 60; max-width: 90vw; }
.toast.on { transform: translateX(-50%) translateY(0); opacity: 1; }
.modal-back { position: fixed; inset: 0; background: rgba(5,2,10,.66); backdrop-filter: blur(3px); display: none; place-items: center; z-index: 55; padding: 20px; overflow-y: auto; }
.modal-back.on { display: grid; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px; width: 100%; max-width: 440px; box-shadow: var(--shadow); }
.modal.wide { max-width: 760px; }
.modal h3 { margin: 0 0 4px; }
.modal .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp .7s linear infinite; margin: 40px auto; }
@keyframes sp { to { transform: rotate(360deg); } }

/* Admin panel */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { padding: 10px 16px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabpane { display: none; }
.tabpane.on { display: block; }
.dtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.dtable th { text-align: left; color: var(--faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12px; }
.dtable td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dtable tr:hover td { background: var(--panel2); }
.mini { padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--text); }
.mini:hover { border-color: var(--accent); color: var(--accent); }
.mini.danger:hover { border-color: var(--danger); color: var(--danger); }
.adminform { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 18px; padding: 16px; background: var(--bg2); border-radius: 12px; }
.adminform .field { margin: 0; flex: 1; min-width: 130px; }
.adminform .btn { width: auto; padding: 11px 20px; }

/* Toggle switch (admin tick, etc.) */
.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 23px; border-radius: 23px; background: var(--line); position: relative; transition: background .18s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.switch input:checked + .track { background: linear-gradient(100deg, var(--accent2), var(--accent)); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:checked ~ .lbl { color: var(--accent); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Admin as a full page (not a popup) */
.adminpage { display: none; overflow-y: auto; background: var(--bg2); }
.adminpage.on { display: block; }
.app.admin-mode .body { display: none; }
.adminpage-inner { max-width: 940px; margin: 0 auto; padding: 26px 22px 60px; }
.adminpage-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.adminpage-head .back { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1.5px solid var(--line); font-weight: 600; font-size: 14px; }
.adminpage-head .back:hover { border-color: var(--accent); color: var(--accent); }
.adminpage-head h2 { font-family: "Fredoka", sans-serif; margin: 0; font-size: 24px; }

/* Undo-send toast with an action button */
.toast .undo { margin-left: 14px; color: var(--accent); font-weight: 700; text-decoration: underline; }
.toast .undo:hover { filter: brightness(1.2); }

/* Expanded settings */
.settings-modal { max-width: 640px; max-height: 88vh; overflow-y: auto; }
.set-sec { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.set-sec.first { border-top: none; padding-top: 0; margin-top: 0; }
.set-sec h4 { margin: 0 0 3px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.set-sec h4 i { color: var(--accent); }
.set-sec .d { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
.slider-row { display: flex; align-items: center; gap: 14px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--accent); height: 6px; }
.slider-val { min-width: 92px; text-align: right; font-weight: 700; color: var(--accent); }
textarea.set { width: 100%; min-height: 84px; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg2); resize: vertical; font-family: inherit; color: var(--text); }
textarea.set:focus { outline: none; border-color: var(--accent); }
.toggle-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.toggle-row input { width: auto; }
.rule-row { display: grid; grid-template-columns: .9fr .9fr 1.3fr .9fr 1.3fr auto; gap: 6px; margin-bottom: 8px; align-items: center; }
.rule-row select, .rule-row input { padding: 8px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--bg2); font-size: 12.5px; color: var(--text); min-width: 0; }
.rule-row .rm { color: var(--danger); font-weight: 700; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; }
.rule-row .rm:hover { border-color: var(--danger); }
.kv { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--bg2); border-radius: 10px; overflow: hidden; }
.kv td { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.kv tr:last-child td { border-bottom: none; }
.kv td:first-child { color: var(--muted); width: 116px; }
.kv td:last-child { font-family: ui-monospace, "SF Mono", monospace; color: var(--text); }
@media (max-width: 640px) {
  .rule-row { grid-template-columns: 1fr 1fr; }
  .rule-row .rm { grid-column: 1 / -1; }
}

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .auth-card { justify-self: stretch; max-width: 100%; }
}
@media (max-width: 900px) {
  .topbar { gap: 10px; }
  .topbar .logo { min-width: 0; }
  .topbar .logo span:not(.mark) { display: none; }
  .topbar .search { max-width: none; min-width: 0; }
  .topbar .search input { min-width: 0; }
  .sidebar { position: fixed; top: 57px; bottom: 0; left: 0; width: var(--sidebar-w); z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 8px 0 30px rgba(0,0,0,.5); }
  .sidebar.open { transform: none; }
  .list, .body.reading .list { flex: 1; border-right: none; }
  .reader.on { position: fixed; inset: 57px 0 0; z-index: 25; }
  .compose { right: 0; left: 0; width: 100%; max-width: 100%; }
  .reader-scroll { padding: 16px 12px; }
  .reader-card { padding: 20px 18px; }
  .reader-meta { flex-wrap: wrap; row-gap: 4px; }
  .reader-meta .reader-date { width: 100%; padding-left: 59px; }
  .reader-subject { font-size: 21px; }
}
.reader-from { word-break: break-word; }
.hamburger { display: none; }
@media (max-width: 900px) { .hamburger { display: grid; } }
