/* ConcerningM — themed to concerning.fyi: flat near-black, monochrome,
   4px corners, 1px hairlines, Inter, zero gradients or glows. */

:root {
  --bg: #1a1a1a;
  --surface: #141414;
  --surface-2: #1f1f1f;
  --hover: #202020;
  --text: #f5f5f5;
  --nav-text: #d4d4d4;
  --muted: #a3a3a3;
  --subtle: #737373;
  --faint: #4a4a4a;
  --border: #3a3a3a;
  --border-soft: #2a2a2a;
  --link: #8080ff;
  --radius: 4px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, Helvetica, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }

/* ---------- shell ---------- */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 224px;
  flex: 0 0 224px;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 10px;
  gap: 2px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 8px 16px;
  font-weight: 600; font-size: 14.5px; letter-spacing: -0.01em;
}
.brand .mark { width: 19px; height: 19px; flex: 0 0 19px; color: var(--text); display: block; }
.brand small {
  color: var(--subtle); font-weight: 400; font-size: 11px;
  margin-left: auto; letter-spacing: 0;
}

.compose-btn {
  margin: 0 2px 12px;
  padding: 7px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 500; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.compose-btn:hover { background: var(--hover); border-color: #4a4a4a; }

.nav-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--subtle); padding: 14px 9px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px; border-radius: var(--radius);
  color: var(--muted); width: 100%; text-align: left;
  font-size: 13px;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); font-weight: 500; }
.nav-item .ico { width: 16px; display: inline-flex; align-items: center; justify-content: center; color: var(--faint); }
.ico-svg { display: block; flex: 0 0 auto; }
.star-svg { color: var(--nav-text); }
.chip .ico-svg { display: inline-block; vertical-align: -1px; }
.icon-btn .ico-svg, .compose-btn .ico-svg { pointer-events: none; }
.nav-item.active .ico { color: var(--muted); }
.nav-item .count {
  margin-left: auto; font-size: 11px; color: var(--subtle);
  font-variant-numeric: tabular-nums;
}
.nav-item .count.unread { color: var(--text); font-weight: 600; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border-soft); padding-top: 8px; }

/* ---------- list pane ---------- */
.list-pane {
  width: 380px; flex: 0 0 380px;
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  background: var(--bg);
  min-width: 0;
}
.list-head {
  padding: 11px 14px 10px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 10px;
}
.list-title { display: flex; align-items: center; gap: 8px; }
.list-title h1 {
  font-size: 13px; font-weight: 600; letter-spacing: .02em;
  text-transform: uppercase; color: var(--nav-text);
}
.list-title .spacer { flex: 1; }
.icon-btn {
  width: 26px; height: 26px; border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--subtle); font-size: 12px;
  border: 1px solid transparent;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-soft); }
.icon-btn.on { color: var(--text); }

.search-wrap { position: relative; }
.search-wrap input {
  width: 100%; padding: 7px 11px 7px 29px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); outline: none; font-size: 13px;
}
.search-wrap input::placeholder { color: var(--subtle); }
.search-wrap input:focus { border-color: var(--border); background: var(--surface-2); }
.search-wrap .s-ico {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--subtle); font-size: 11px;
}

.thread-list { flex: 1; overflow-y: auto; }
.thread {
  display: block; width: 100%; text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  position: relative;
}
.thread:hover { background: var(--surface); }
.thread.active { background: var(--surface-2); }
.thread.active::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--text);
}
.t-top { display: flex; align-items: center; gap: 7px; }
.t-from {
  font-size: 13px; font-weight: 400; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.thread.unread .t-from { font-weight: 600; color: var(--text); }
.t-date {
  font-size: 11px; color: var(--subtle); flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}
.t-subject {
  font-size: 13px; color: var(--muted); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thread.unread .t-subject { color: var(--text); font-weight: 500; }
.t-snippet {
  font-size: 12px; color: var(--subtle); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden;
}
.t-flags { display: flex; gap: 6px; align-items: center; margin-top: 5px; }
.chip {
  font-size: 10px; padding: 1px 6px; border-radius: 3px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border-soft);
}
.chip.unread-dot { background: var(--text); border: none; width: 5px; height: 5px; padding: 0; border-radius: 50%; }
.chip.warn { color: var(--muted); border-color: var(--border); }
.star { color: var(--nav-text); font-size: 11px; }

.empty {
  padding: 60px 24px; text-align: center; color: var(--subtle); font-size: 13px; line-height: 1.6;
}

/* ---------- reader ---------- */
.reader { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.reader:has(> .empty) { justify-content: center; }
#reader > .empty { padding: 40px 24px; }

.reader-head {
  padding: 10px 16px; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 4px;
}
.reader-head .spacer { flex: 1; }
.reader-scroll { flex: 1; overflow-y: auto; padding: 26px 30px 60px; }
.r-subject {
  font-size: 20px; font-weight: 600; letter-spacing: -0.02em;
  line-height: 1.32; margin-bottom: 16px;
}
.r-meta { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 22px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--nav-text); border: 1px solid var(--border-soft);
}
.r-from { font-size: 13px; font-weight: 600; color: var(--text); }
.r-addrs { font-size: 12px; color: var(--subtle); margin-top: 3px; line-height: 1.55; }
.r-body { font-size: 14px; line-height: 1.72; color: var(--nav-text); }
.r-body p { margin: 0 0 12px; }
.r-body pre, .r-body code { font-family: var(--mono); font-size: 12.5px; }
.r-body pre {
  background: var(--surface); border: 1px solid var(--border-soft);
  padding: 12px; border-radius: var(--radius); overflow-x: auto; margin: 0 0 12px;
}
.r-body blockquote {
  border-left: 2px solid var(--border); padding-left: 12px; color: var(--muted); margin: 0 0 12px;
}
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 0; }
.att {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border: 1px solid var(--border-soft); border-radius: var(--radius);
  background: var(--surface); font-size: 12.5px; color: var(--nav-text);
}
.att:hover { background: var(--surface-2); border-color: var(--border); }
.att .sz { color: var(--subtle); font-size: 11px; }

.msg-block { padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--border-soft); }
.msg-block:last-child { border-bottom: none; }
iframe.mailframe {
  width: 100%; border: 1px solid var(--border-soft); background: #fff;
  border-radius: var(--radius); min-height: 200px;
}

/* ---------- compose / modals ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 10, 10, .72);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal {
  width: min(660px, 100%); max-height: 86vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .55);
}
.modal-head {
  padding: 11px 14px; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center;
  font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--nav-text);
}
.modal-head .spacer { flex: 1; }
.modal-body { padding: 2px 14px 14px; overflow-y: auto; }
.field { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.field label {
  width: 56px; font-size: 11px; color: var(--subtle); flex: 0 0 56px;
  text-transform: uppercase; letter-spacing: .06em;
}
.field input, .field textarea { flex: 1; background: none; border: none; outline: none; font-size: 13.5px; }
.field input::placeholder, .field textarea::placeholder { color: var(--subtle); }
.field textarea { resize: vertical; min-height: 210px; font-family: var(--font); line-height: 1.65; padding: 8px 0; }
.modal-foot {
  padding: 11px 14px; border-top: 1px solid var(--border-soft);
  display: flex; gap: 8px; align-items: center;
}
.btn {
  padding: 7px 13px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.btn:hover { background: var(--hover); border-color: #4a4a4a; }
.btn.primary { background: var(--text); color: #141414; border: 1px solid var(--text); }
.btn.primary:hover { background: #fff; border-color: #fff; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }

/* address management + sender picker */
.sender-select {
  flex: 1; background: none; border: none; outline: none; font-size: 13.5px;
  color: var(--text); padding: 0; appearance: none; cursor: pointer;
}
.sender-select option { background: var(--surface); color: var(--text); }

.sect { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.sect-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; margin-bottom: 10px;
  display: flex; align-items: baseline; gap: 8px;
}
.sect-note { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--subtle); font-size: 11px; }
.addr-row {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 0; border-bottom: 1px solid var(--border-soft);
}
.addr-main { flex: 1; font-size: 13px; color: var(--nav-text); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.addr-name { color: var(--subtle); margin-left: 8px; font-size: 12px; }
.mini {
  font-size: 11px; color: var(--subtle); padding: 2px 7px;
  border: 1px solid var(--border-soft); border-radius: 3px; white-space: nowrap;
}
.mini:hover { color: var(--text); border-color: var(--border); }
.mini.danger:hover { color: #d98a8a; border-color: #5a3a3a; }
.addr-add { display: flex; gap: 7px; margin-top: 10px; }
.addr-add input {
  flex: 1; padding: 7px 10px; background: var(--bg);
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  outline: none; font-size: 13px;
}
.addr-add input:focus { border-color: var(--border); }
.sect-err { color: #d98a8a; font-size: 11.5px; margin-top: 7px; min-height: 14px; }
.via { color: var(--subtle); font-size: 11.5px; }

/* ---------- login ---------- */
.login-wrap { height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(340px, 100%); background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 30px 26px; text-align: center;
}
.login-card .mark-lg { width: 46px; height: 46px; margin: 0 auto 14px; display: block; color: var(--text); }
.login-card h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 5px; }
.login-card p.sub { color: var(--subtle); font-size: 12.5px; margin-bottom: 22px; }
.login-card input {
  width: 100%; padding: 9px 11px; margin-bottom: 9px; text-align: left;
  background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: var(--radius); outline: none; font-size: 13px;
}
.login-card input:focus { border-color: var(--border); }
.login-card .btn { width: 100%; margin-top: 5px; padding: 9px; }
.err { color: #d98a8a; font-size: 12px; margin-top: 10px; min-height: 16px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 9px 15px; border-radius: var(--radius); font-size: 13px; z-index: 100;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .5);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2e2e2e; border-radius: 0; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .list-pane { flex: 1 1 auto; width: auto; border-right: none; }
  .reader { display: none; }
  #app.reading .list-pane { display: none; }
  #app.reading .reader { display: flex; }
}
