/* tempmail — light/dark theme via CSS custom properties */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #fafafa;
  --border: #e4e6eb;
  --text: #1a1d23;
  --text-dim: #6b7280;
  --accent: #6366f1;
  --accent-soft: #eef0fe;
  --danger: #dc2626;
  --unread-dot: #6366f1;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
  --radius: 10px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #101318;
  --panel: #171b22;
  --panel-2: #1d222b;
  --border: #2a303c;
  --text: #e6e9ef;
  --text-dim: #9aa3b2;
  --accent: #818cf8;
  --accent-soft: #232842;
  --danger: #f87171;
  --unread-dot: #818cf8;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

button { font: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.icon { padding: 7px 10px; }
.btn.wide { width: 100%; }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 16px;
  line-height: 1;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }

input[type="text"], input[type="password"], input:not([type]) {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  outline: none;
  min-width: 0;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.error { color: var(--danger); font-size: 13px; }

/* ---------- login ---------- */
.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
}
.login-screen form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px;
  width: min(360px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.login-logo { font-size: 44px; }
.login-screen h1 { margin: 0; font-size: 26px; }
.login-sub { margin: 0 0 8px; color: var(--text-dim); font-size: 14px; }

/* ---------- layout ---------- */
.app {
  display: grid;
  grid-template-columns: 270px 1fr;
  height: 100vh;
}
.main {
  display: grid;
  grid-template-columns: minmax(340px, 520px) 1fr;
  min-width: 0;
  height: 100vh;
}

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 10px;
}
.sidebar-header h1 {
  font-size: 16px;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-actions { display: flex; gap: 2px; }

.new-inbox {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.new-inbox input { width: 100%; }
.new-inbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.new-inbox-actions .preset-select { flex: 1 1 auto; min-width: 100px; }
.new-inbox-actions .btn { flex: 0 0 auto; padding: 7px 12px; }

.inbox-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
}
.inbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
}
.inbox-item:hover { background: var(--panel-2); }
.inbox-item.active { background: var(--accent-soft); border-color: var(--accent); }
.inbox-item .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.inbox-item .counts { color: var(--text-dim); font-size: 12px; }
.badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
.inbox-item .mini-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 6px;
  padding: 2px 5px;
  font-size: 12px;
  opacity: 0;
}
.inbox-item:hover .mini-btn { opacity: 1; }
.mini-btn:hover { background: var(--border); color: var(--text); }

.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.address-tools { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.address-tools input { width: 80px; padding: 4px 6px; font-size: 11px; }
.alias-list { margin-bottom: 6px; }
.alias-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin: 3px 0; font-size: 11px; }
.inbox-expiry { margin-bottom: 8px; }
.inbox-expiry strong { color: var(--text); }
.inbox-expiry.warning strong { color: #b45309; }
.inbox-expiry.urgent strong, .inbox-expiry.expired strong { color: var(--danger); }
.expiry-actions { display: flex; gap: 4px; margin-top: 7px; }
.expiry-actions .btn { padding: 3px 7px; font-size: 11px; }

/* ---------- list pane ---------- */
.list-pane {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.list-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.list-header h2 {
  font-size: 15px;
  margin: 0;
  flex: 0 1 auto;
}
.address-preview {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-dim);
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: right;
}
.list-header .btn.small { flex: 0 0 auto; white-space: nowrap; }
.list-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.list-toolbar input { flex: 1 1 220px; min-width: 160px; }
.tool-btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 6px 8px;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tool-btn:hover { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.tool-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.message-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
}
.msg-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  grid-template-areas:
    "dot from time"
    "dot subj time"
    "dot prev time";
  gap: 1px 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 2px;
}
.msg-item:hover { background: var(--panel-2); }
.msg-item.active { background: var(--accent-soft); border-color: var(--accent); }
.msg-item .dot {
  grid-area: dot;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  background: transparent;
}
.msg-item.unread .dot { background: var(--unread-dot); }
.msg-item.unread .from, .msg-item.unread .subj { font-weight: 600; }
.msg-item .from { grid-area: from; font-size: 13.5px; }
.msg-item .subj { grid-area: subj; font-size: 13.5px; color: var(--text); }
.msg-item .prev {
  grid-area: prev;
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.msg-item .time { grid-area: time; font-size: 11.5px; color: var(--text-dim); align-self: start; }
.msg-item .att {
  grid-area: time;
  align-self: end;
  font-size: 11px;
  color: var(--text-dim);
  justify-self: end;
}
.msg-item .time.has-att { display: none; }

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 20px;
}
.empty-icon { font-size: 40px; margin-bottom: 8px; }
.empty-state p { margin: 4px 0; }
.empty-state .hint { font-size: 13px; }
.empty-state b { color: var(--text); }

/* ---------- reader ---------- */
.reader {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.reader-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.reader-meta { flex: 1; min-width: 0; }
.reader-meta h2 { margin: 0 0 4px; font-size: 17px; }
.reader-meta p { margin: 1px 0; font-size: 13px; color: var(--text-dim); }
.reader-actions { display: flex; gap: 6px; flex-shrink: 0; }

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
  background: var(--panel-2);
}
.att-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.att-chip .size { color: var(--text-dim); font-size: 11.5px; }

.reader-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn {
  border: none;
  background: transparent;
  padding: 5px 14px;
  font-size: 13px;
  color: var(--text-dim);
}
.seg-btn.active { background: var(--accent); color: #fff; }
.seg-btn:not(.active):hover { color: var(--text); }

.reader-body {
  flex: 1;
  overflow: hidden;
  padding: 0;
}
.reader-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}
.reader-body pre {
  margin: 0;
  height: 100%;
  overflow: auto;
  padding: 20px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.55;
}
.reader-note {
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 100;
  animation: toast-in 0.18s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- mobile ---------- */
.only-mobile { display: none; }
@media (max-width: 1100px) and (min-width: 901px) {
  .app { grid-template-columns: 240px 1fr; }
  .new-inbox-actions { flex-wrap: wrap; }
}
@media (max-width: 900px) {
  .only-mobile { display: inline-block; }
  .app { grid-template-columns: 1fr; position: relative; }
  .main { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 85vw);
    z-index: 50;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .list-pane { border-right: none; }
  .list-header { flex-wrap: wrap; }
  .address-preview { display: none; }
  .list-header .btn.small { padding: 4px 8px; }
  .list-toolbar { flex-wrap: nowrap; }
  .reader { position: fixed; inset: 0; z-index: 40; }
  .reader-header { flex-wrap: wrap; }
  .reader-actions { width: 100%; justify-content: flex-end; }
}

.domain-select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 13px;
  outline: none;
  max-width: 170px;
  cursor: pointer;
}
.domain-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- search highlighting ---------- */
mark {
  background: rgba(250, 204, 21, 0.35);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* ---------- preset select ---------- */
.preset-select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 6px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  max-width: 118px;
}

/* ---------- modal (QR) ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  animation: fade-in 0.15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
  min-width: 300px;
  max-width: 92vw;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.modal-header h3 { margin: 0; font-size: 15px; }
.qr-address {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  text-align: center;
  margin: 6px 0 12px;
  word-break: break-all;
}
.qr-image { display: flex; justify-content: center; }
.qr-image svg { background: #fff; border-radius: 8px; padding: 6px; }

/* ---------- dashboard drawer ---------- */
.drawer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  justify-content: flex-end;
  z-index: 90;
  animation: fade-in 0.15s ease-out;
}
.drawer-box {
  background: var(--panel);
  border-left: 1px solid var(--border);
  width: min(560px, 94vw);
  height: 100%;
  overflow-y: auto;
  padding: 18px 22px;
}
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.dash-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.dash-card.wide { grid-column: 1 / -1; }
.dash-card h4 {
  margin: 0 0 8px;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.dash-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 0;
  font-size: 13px;
}
.dash-dl dt { color: var(--text-dim); }
.dash-dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.dash-audit {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12.5px;
  max-height: 260px;
  overflow-y: auto;
}
.dash-audit li { padding: 5px 0; border-bottom: 1px solid var(--border); }
.dash-audit .audit-time { color: var(--text-dim); margin-right: 8px; }
.dash-audit code { font-size: 11px; color: var(--text-dim); word-break: break-all; }
.alerts-banner {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #ef4444;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
.policy-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}
.policy-controls label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.policy-controls input[type="number"] {
  width: 90px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 6px;
}
@media (max-width: 640px) {
  .dash-grid { grid-template-columns: 1fr; }
  .drawer-box { width: 100vw; }
}
