/* ── Fallback variables (lainrocks-old palette) ─────────────────
   Overridden at runtime by whichever theme the user picks.
   ──────────────────────────────────────────────────────────────── */
:root {
  --bg:          #111111;
  --bg-2:        #0e0e0e;
  --bg-3:        #222222;
  --border:      #6E6667;
  --border-hi:   #00746e;
  --text:        #DBC2BE;
  --text-dim:    #765A57;
  --text-mid:    #a08580;
  --accent:      #00746e;
  --accent-dim:  #022b2a;
  --error:       #f06060;
  --font-mono:   "Lucida Console", "Courier New", monospace;
  --font-serif:  Georgia, serif;
  --radius:      4px;
  --sidebar-w:   200px;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

a { color: inherit; text-decoration: none; }

/* ── Header ─────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 48px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo {
  font-family: var(--font-serif);
  font-size: 22px;
  font-style: italic;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.header-nav { display: flex; align-items: center; gap: 20px; }
.username { color: var(--text-dim); font-size: 11px; }
.btn-compose, .btn-logout { font-family: var(--font-mono); font-size: 11px; color: var(--text-mid); transition: color 0.15s; }
.btn-compose:hover { color: var(--accent); }
.btn-logout:hover  { color: var(--error); }

/* ── App layout ─────────────────────────────────────────────────── */
.app-layout { display: flex; height: calc(100vh - 48px); }

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  overflow-y: auto;
}
.sidebar-compose {
  display: block;
  margin: 0 12px 16px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}
.sidebar-compose:hover { background: var(--accent); color: var(--bg); }
.mailbox-list { display: flex; flex-direction: column; }
.mailbox-item {
  padding: 6px 16px;
  font-size: 11px;
  color: var(--text-mid);
  border-left: 2px solid transparent;
  transition: color 0.1s, border-color 0.1s;
}
.mailbox-item:hover  { color: var(--text); }
.mailbox-item.active { color: var(--accent); border-left-color: var(--accent); }

/* ── Message list ───────────────────────────────────────────────── */
.message-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.list-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--border);
}
.list-header h2 { font-family: var(--font-serif); font-style: italic; font-size: 18px; font-weight: 400; color: var(--text); }
.msg-count { font-size: 10px; color: var(--text-dim); }
.empty-state { padding: 48px 24px; color: var(--text-dim); font-size: 12px; }
.message-row {
  display: grid;
  grid-template-columns: 200px 1fr 100px;
  gap: 12px;
  align-items: center;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.message-row:hover { background: var(--bg-2); }
.msg-from { color: var(--text-mid); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-row.unread .msg-from { color: var(--accent); }
.msg-subject { color: var(--text-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-row.unread .msg-from,
.message-row.unread .msg-subject { color: var(--text); font-weight: 600; }
.message-row.unread .msg-from { color: var(--accent); }
.msg-date { color: var(--text-dim); font-size: 10px; text-align: right; }

/* ── Message view ───────────────────────────────────────────────── */
.message-view { flex: 1; overflow-y: auto; padding: 24px 36px; max-width: 820px; }
.message-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.back-link { font-size: 11px; color: var(--text-dim); transition: color 0.1s; }
.back-link:hover { color: var(--text); }
.btn-reply {
  font-size: 11px; font-family: var(--font-mono); color: var(--accent);
  border: 1px solid var(--accent); padding: 4px 12px; border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}
.btn-reply:hover { background: var(--accent); color: var(--bg); }
.message-header-block { border-bottom: 1px solid var(--border); padding-bottom: 20px; margin-bottom: 24px; }
.message-subject { font-family: var(--font-serif); font-style: italic; font-size: 26px; font-weight: 400; line-height: 1.3; color: var(--text); margin-bottom: 12px; }
.message-meta { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--text-mid); }
.meta-label { color: var(--text-dim); margin-right: 6px; }
.message-body pre { font-family: var(--font-mono); font-size: 13px; line-height: 1.7; color: var(--text); white-space: pre-wrap; word-break: break-word; }

/* ── Login ──────────────────────────────────────────────────────── */
.login-wrap { min-height: calc(100vh - 48px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 440px; border: 1px solid var(--border); border-radius: var(--radius); padding: 36px 40px; background: var(--bg-2); animation: fadeUp 0.3s ease both; }
.login-header { margin-bottom: 28px; }
.login-title { font-family: var(--font-serif); font-style: italic; font-size: 32px; font-weight: 400; color: var(--accent); line-height: 1; margin-bottom: 6px; }
.login-sub { font-size: 11px; color: var(--text-dim); }
.login-form, .compose-form { display: flex; flex-direction: column; gap: 20px; }
.field-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; }
.field-group legend { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; padding: 0 4px; }
.field-row { display: grid; grid-template-columns: 48px 1fr; gap: 8px; align-items: center; margin-top: 10px; }
.field-row label { font-size: 11px; color: var(--text-dim); }
input, textarea {
  width: 100%; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font-mono); font-size: 12px; padding: 6px 10px;
  outline: none; transition: border-color 0.15s;
}
input:focus, textarea:focus { border-color: var(--border-hi); }
input::placeholder, textarea::placeholder { color: var(--text-dim); }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-primary {
  font-family: var(--font-mono); font-size: 12px; background: var(--accent); color: var(--bg);
  border: none; border-radius: var(--radius); padding: 10px 20px; cursor: pointer;
  align-self: flex-start; transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-cancel { font-size: 11px; color: var(--text-dim); padding: 10px 0; transition: color 0.1s; }
.btn-cancel:hover { color: var(--text); }

/* ── Compose ────────────────────────────────────────────────────── */
.compose-wrap { min-height: calc(100vh - 48px); display: flex; align-items: flex-start; justify-content: center; padding: 36px 24px; }
.compose-card { width: 100%; max-width: 700px; border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 36px; background: var(--bg-2); }
.compose-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.compose-header h2 { font-family: var(--font-serif); font-style: italic; font-size: 20px; font-weight: 400; }
.compose-field { display: grid; grid-template-columns: 60px 1fr; gap: 10px; align-items: start; border-bottom: 1px solid var(--border); padding: 10px 0; }
.compose-field label { font-size: 11px; color: var(--text-dim); padding-top: 7px; }
.compose-field input { background: transparent; border: none; border-radius: 0; padding: 6px 0; }
.compose-field input:focus { border-color: transparent; box-shadow: none; }
.compose-body-field { align-items: start; }
.compose-body-field textarea { background: transparent; border: none; border-radius: 0; padding: 6px 0; resize: vertical; font-size: 13px; line-height: 1.7; }
.compose-actions { display: flex; align-items: center; gap: 16px; padding-top: 8px; }

/* ── Error banner ───────────────────────────────────────────────── */
.error-banner { background: rgba(240,96,96,0.08); border: 1px solid var(--error); color: var(--error); font-size: 11px; padding: 10px 14px; border-radius: var(--radius); }

/* ── Message actions ────────────────────────────────────────────── */
.message-actions { display: flex; align-items: center; gap: 10px; }
.delete-form { display: inline; margin: 0; padding: 0; }
.btn-delete {
  font-family: var(--font-mono); font-size: 11px; background: transparent;
  border: 1px solid var(--border); color: var(--text-dim); padding: 4px 12px;
  border-radius: var(--radius); cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.btn-delete:hover { border-color: var(--error); color: var(--error); }

/* ── Flash banner ───────────────────────────────────────────────── */
.flash-banner { padding: 8px 24px; font-size: 11px; background: rgba(0,116,110,0.06); border-bottom: 1px solid rgba(0,116,110,0.15); color: var(--accent); }

/* ── Attachments ────────────────────────────────────────────────── */
.attachments { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.attachments-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; margin-right: 4px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 10px; font-size: 11px; color: var(--text-mid); transition: border-color 0.15s, color 0.15s; }
.attachment-chip:hover { border-color: var(--accent); color: var(--accent); }
.att-icon { font-size: 13px; }
.att-size { color: var(--text-dim); font-size: 10px; }

/* ── Pagination ─────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; border-top: 1px solid var(--border); margin-top: auto; }
.page-btn { font-size: 11px; color: var(--text-mid); padding: 4px 8px; border-radius: var(--radius); transition: color 0.1s; }
.page-btn:hover { color: var(--accent); }
.page-btn.disabled { color: var(--text-dim); pointer-events: none; opacity: 0.4; }
.page-info { font-size: 10px; color: var(--text-dim); }

/* ── Theme switcher ─────────────────────────────────────────────── */
.theme-switcher {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
}
.theme-switcher label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.theme-switcher select {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-mid);
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, color 0.15s;
  width: fit-content;
}
.theme-switcher select:hover,
.theme-switcher select:focus { border-color: var(--accent); color: var(--text); }

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}