:root {
  --bg: #0f1117;
  --bg2: #161923;
  --bg3: #1e2230;
  --border: #262b3b;
  --text: #e8eaf2;
  --text2: #9aa1b5;
  --text3: #6b7288;
  --accent: #4a7cff;
  --danger: #e0533d;
  --ok: #2fa864;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
#app { height: 100vh; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select {
  font: inherit; color: var(--text);
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
a { color: var(--accent); text-decoration: none; }

/* ---------- layout ---------- */
.layout { display: flex; height: 100vh; }
.sidebar {
  width: 220px; min-width: 220px; background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 10px 8px; overflow-y: auto;
}
.main { flex: 1; display: flex; min-width: 0; }
.list-pane { width: 46%; min-width: 380px; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.detail-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.full-pane { flex: 1; overflow-y: auto; padding: 24px 32px; }

/* ---------- sidebar ---------- */
.side-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 6px; color: var(--text2);
  width: 100%; text-align: left; font-size: 13.5px;
}
.side-item:hover { background: var(--bg3); color: var(--text); }
.side-item.active { background: var(--bg3); color: var(--text); font-weight: 600; }
.side-item .count { margin-left: auto; font-size: 11.5px; color: var(--text3); }
.side-item .count.unread { color: var(--accent); font-weight: 700; }
.side-sep { margin: 10px 10px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text3); }
.acct-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sync-note { font-size: 10.5px; color: var(--text3); padding: 2px 10px 0; }

/* ---------- message list ---------- */
.list-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--bg2);
}
.list-head input { flex: 1; }
.list-scroll { flex: 1; overflow-y: auto; }
.msg-row {
  display: flex; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--border); cursor: pointer; position: relative;
}
.msg-row:hover { background: var(--bg2); }
.msg-row.focused { background: var(--bg3); box-shadow: inset 3px 0 0 var(--accent); }
.msg-row.selected { background: #1a2a4a; }
.msg-row .acct-bar { width: 3px; border-radius: 2px; flex: none; }
.msg-main { flex: 1; min-width: 0; }
.msg-top { display: flex; gap: 8px; align-items: baseline; }
.msg-from { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.msg-row.read .msg-from { font-weight: 400; color: var(--text2); }
.msg-date { margin-left: auto; font-size: 11.5px; color: var(--text3); white-space: nowrap; }
.msg-subj { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.msg-row.read .msg-subj { color: var(--text2); }
.msg-snip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: var(--text3); }
.badge {
  font-size: 9.5px; font-weight: 700; padding: 1px 6px; border-radius: 8px;
  text-transform: uppercase; letter-spacing: .04em; flex: none;
}
.star { color: #e0a53d; }
.empty { padding: 48px 20px; text-align: center; color: var(--text3); }

/* ---------- thread view ---------- */
.thread-head { padding: 14px 20px 10px; border-bottom: 1px solid var(--border); background: var(--bg2); }
.thread-head h2 { font-size: 17px; font-weight: 650; }
.thread-scroll { flex: 1; overflow-y: auto; padding: 12px 20px; }
.tmsg { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; background: var(--bg2); }
.tmsg-head { display: flex; gap: 10px; padding: 10px 14px; align-items: baseline; cursor: pointer; }
.tmsg-head .who { font-weight: 600; }
.tmsg-head .when { margin-left: auto; color: var(--text3); font-size: 12px; }
.tmsg-body { padding: 0 14px 12px; }
.tmsg-body iframe { width: 100%; border: none; background: #fff; border-radius: 6px; }
.tmsg-body pre { white-space: pre-wrap; font: inherit; }
.att { display: inline-block; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; margin: 6px 6px 0 0; font-size: 12px; }
.toolbar { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg2); flex-wrap: wrap; }
.btn {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 12px; font-size: 12.5px; color: var(--text);
}
.btn:hover { border-color: var(--text3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.small { padding: 3px 8px; font-size: 11.5px; }
kbd {
  background: var(--bg3); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 5px; font-size: 11px; font-family: inherit;
}

/* ---------- compose ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  width: min(720px, 94vw); max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-head { padding: 14px 18px 0; font-weight: 650; font-size: 15px; }
.modal-body { padding: 12px 18px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.modal-body textarea { min-height: 220px; resize: vertical; }
.modal-foot { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); align-items: center; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; }

/* ---------- tables (cleanup / rules / settings) ---------- */
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
tr:hover td { background: var(--bg2); }
h1 { font-size: 20px; margin-bottom: 4px; }
.sub { color: var(--text3); font-size: 13px; margin-bottom: 18px; }
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h3 { font-size: 14px; margin-bottom: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--text2); }
.muted { color: var(--text3); font-size: 12px; }
.pill { border-radius: 10px; padding: 1px 8px; font-size: 11px; font-weight: 600; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 18px; z-index: 100; box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.toast.error { border-color: var(--danger); }

/* ---------- login ---------- */
.login-wrap { height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { width: 320px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.login-box h1 { font-size: 28px; }

/* ---------- snooze menu ---------- */
.menu {
  position: absolute; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; z-index: 60; min-width: 180px; box-shadow: 0 10px 40px rgba(0,0,0,.5);
  overflow: hidden;
}
.menu button { display: block; width: 100%; text-align: left; padding: 8px 14px; font-size: 13px; }
.menu button:hover { background: var(--bg2); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
