/* Inboxd — Neumorphic Dark */

:root {
  --bg: #1d1e23;            /* page background */
  --bg-soft: #21232a;        /* subtle panel tint */
  --shadow-dark: #14151a;    /* outer shadow / inner shadow */
  --shadow-light: #2a2c34;   /* outer highlight / inner highlight */
  --text: #d4d6dc;
  --text-dim: #8a8d97;
  --text-faint: #5b5e67;
  --accent: #d4d6dc;
  --accent-dim: #a0a3ab;
  --gold: #d4a04a;
  --red: #c25555;
  --green: #5cb37a;
  --radius: 14px;
  --radius-lg: 22px;
  --radius-sm: 10px;
  --r-shadow: 7px 7px 14px var(--shadow-dark), -7px -7px 14px var(--shadow-light);
  --r-shadow-sm: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
  --s-shadow: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light);
  --s-shadow-sm: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }
::selection { background: var(--accent); color: white; }

/* ── Neumorphic primitives ─────────────────────────────────────── */
.neu-raised {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--r-shadow);
}
.neu-sunken {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--s-shadow);
}

/* ── Auth screen ───────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
  background: var(--bg);
}
.auth-card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--r-shadow);
  padding: 44px 40px;
  width: 100%; max-width: 400px;
}
.auth-card h1 {
  margin: 0 0 6px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}
.auth-card .tag { color: var(--text-dim); margin-bottom: 28px; font-size: 13px; }

.auth-card .field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.auth-card label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
  padding-left: 4px;
}
.auth-card input {
  background: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 13px 18px;
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--s-shadow-sm);
  transition: box-shadow 0.2s ease;
}
.auth-card input:focus { outline: none; box-shadow: var(--s-shadow); }
.auth-card .username-row { display: flex; align-items: center; gap: 10px; }
.auth-card .username-row input { flex: 1; }
.auth-card .at-suffix { color: var(--text-dim); font-size: 13px; white-space: nowrap; font-weight: 500; }

.btn-primary {
  width: 100%;
  background: var(--bg);
  color: var(--accent);
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin-top: 10px;
  box-shadow: var(--r-shadow);
  transition: box-shadow 0.15s ease, color 0.15s ease;
}
.btn-primary:hover { color: var(--text); }
.btn-primary:active { box-shadow: var(--s-shadow); color: var(--accent); }
.btn-primary:disabled { color: var(--text-faint); cursor: not-allowed; box-shadow: var(--r-shadow); }

.auth-card .switch { text-align: center; color: var(--text-dim); margin-top: 18px; font-size: 13px; }
.auth-card .switch a { cursor: pointer; color: var(--accent); font-weight: 500; }
.auth-card .err {
  background: var(--bg);
  box-shadow: var(--s-shadow-sm);
  color: var(--red);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}
.auth-card .hint { font-size: 11px; color: var(--text-faint); margin-top: 4px; padding-left: 4px; }

/* ── App layout ────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 240px 380px 1fr;
  height: 100vh;
  gap: 18px;
  padding: 18px;
  background: var(--bg);
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--r-shadow);
  display: flex; flex-direction: column;
  padding: 22px 14px;
}
.sidebar-head { padding: 4px 12px 18px; }
.sidebar-head .brand {
  font-size: 22px; font-weight: 800; letter-spacing: -0.5px;
  color: var(--text);
  display: inline-flex; align-items: center; gap: 10px;
}
.sidebar-head .brand-icon { width: 30px; height: 30px; border-radius: 7px; }
.sidebar-head .who {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
  letter-spacing: 0.3px;
}

.compose-btn {
  margin: 6px 8px 20px;
  padding: 14px 20px;
  background: var(--bg);
  color: var(--accent);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
  box-shadow: var(--r-shadow-sm);
  transition: box-shadow 0.15s ease, color 0.15s ease;
}
.compose-btn:hover { color: var(--text); }
.compose-btn:active { box-shadow: var(--s-shadow-sm); }

.folder-list { padding: 0 8px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.folder {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  background: var(--bg);
  transition: color 0.15s ease, box-shadow 0.15s ease;
}
.folder:hover { color: var(--text); }
.folder.active {
  color: var(--accent);
  box-shadow: var(--s-shadow-sm);
}
.folder .count {
  font-size: 10px;
  color: var(--text-faint);
  background: var(--bg);
  padding: 3px 9px;
  border-radius: 10px;
  box-shadow: var(--s-shadow-sm);
  font-weight: 600;
  min-width: 22px;
  text-align: center;
}
.folder.active .count { color: var(--accent); }

.sidebar-foot { padding: 10px 16px 0; font-size: 12px; color: var(--text-faint); }
.sidebar-foot button {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 6px 0;
  font-weight: 500;
}
.sidebar-foot button:hover { color: var(--text); }

/* ── List pane ─────────────────────────────────────────────────── */
.list-pane {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--r-shadow);
  overflow-y: auto;
  padding: 8px;
}
.list-header { padding: 14px 14px 8px; position: sticky; top: -8px; background: var(--bg); z-index: 1; }
.list-header input {
  width: 100%;
  background: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 11px 16px;
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--s-shadow-sm);
  transition: box-shadow 0.2s ease;
}
.list-header input::placeholder { color: var(--text-faint); }
.list-header input:focus { outline: none; box-shadow: var(--s-shadow); }

.msg-item {
  padding: 14px 16px;
  margin: 4px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg);
  transition: box-shadow 0.15s ease;
}
.msg-item:hover { box-shadow: var(--r-shadow-sm); }
.msg-item.unread .msg-from, .msg-item.unread .msg-subject { font-weight: 700; color: var(--text); }
.msg-item.unread { background: var(--bg); }
.msg-item.unread::before {
  content: ""; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text);
  box-shadow: var(--r-shadow-sm);
  margin-right: 8px; vertical-align: middle;
}
.msg-item.selected { box-shadow: var(--s-shadow-sm); }

.msg-row { display: flex; align-items: baseline; gap: 10px; }
.msg-from { font-size: 13.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.msg-date { font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.msg-subject { font-size: 13px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.msg-snippet { font-size: 12px; color: var(--text-faint); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-star { color: var(--text-faint); cursor: pointer; font-size: 14px; transition: color 0.15s ease; }
.msg-star.on { color: var(--gold); }
.empty-list { padding: 80px 24px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* ── Reader ────────────────────────────────────────────────────── */
.reader {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--r-shadow);
  overflow-y: auto;
}
.reader-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%;
  color: var(--text-faint);
  font-size: 13px;
}
.reader-head {
  padding: 28px 32px 20px;
  position: sticky; top: 0;
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 1;
}
.reader-subject {
  font-size: 24px;
  margin: 0 0 12px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}
.reader-meta { color: var(--text-dim); font-size: 13px; line-height: 1.6; }
.reader-meta b { color: var(--text); font-weight: 600; }
.reader-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.reader-actions button {
  background: var(--bg);
  color: var(--text-dim);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  box-shadow: var(--r-shadow-sm);
  transition: box-shadow 0.15s ease, color 0.15s ease;
}
.reader-actions button:hover { color: var(--text); }
.reader-actions button:active { box-shadow: var(--s-shadow-sm); }
.reader-actions button.danger { color: var(--red); }
.reader-actions button.danger:hover { color: var(--red); }

.reader-body { padding: 28px 32px; line-height: 1.65; color: var(--text); }
.reader-body iframe {
  width: 100%; min-height: 400px;
  border: 0;
  background: #f5f5f5;
  border-radius: var(--radius);
  box-shadow: var(--s-shadow-sm);
}
.reader-body pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: inherit;
  margin: 0;
  background: var(--bg);
  padding: 18px 22px;
  border-radius: var(--radius);
  box-shadow: var(--s-shadow-sm);
}

.attachments { padding: 0 32px 24px; display: flex; flex-wrap: wrap; gap: 10px; }
.attachment {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--bg);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--r-shadow-sm);
  transition: box-shadow 0.15s ease, color 0.15s ease;
}
.attachment:hover { color: var(--text); }
.attachment:active { box-shadow: var(--s-shadow-sm); }
.attachment .size { color: var(--text-faint); font-size: 11px; }

/* ── Compose ───────────────────────────────────────────────────── */
.compose-overlay {
  position: fixed; bottom: 18px; right: 18px;
  width: 600px; max-width: calc(100vw - 36px);
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--r-shadow);
  display: flex; flex-direction: column;
  max-height: 80vh;
  z-index: 100;
  overflow: hidden;
}
.compose-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
}
.compose-head .title {
  font-weight: 700; font-size: 13.5px;
  color: var(--text);
  letter-spacing: 0.3px;
}
.compose-head .close {
  background: var(--bg);
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  box-shadow: var(--r-shadow-sm);
  transition: box-shadow 0.15s ease, color 0.15s ease;
}
.compose-head .close:hover { color: var(--text); }
.compose-head .close:active { box-shadow: var(--s-shadow-sm); }

.compose-body { padding: 0 22px 16px; display: flex; flex-direction: column; gap: 12px; flex: 1; overflow-y: auto; }
.compose-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  box-shadow: var(--s-shadow-sm);
}
.compose-row label {
  color: var(--text-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  min-width: 36px;
}
.compose-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13.5px;
  padding: 8px 0;
}
.compose-row input:focus { outline: none; }
.compose-body textarea {
  flex: 1; min-height: 240px;
  background: var(--bg);
  border: none;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  resize: none;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--s-shadow-sm);
}
.compose-body textarea:focus { outline: none; box-shadow: var(--s-shadow); }

.compose-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
}
.compose-foot .send-btn {
  background: var(--bg);
  color: var(--accent);
  border: none;
  border-radius: var(--radius);
  padding: 11px 28px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  box-shadow: var(--r-shadow-sm);
  transition: box-shadow 0.15s ease, color 0.15s ease;
}
.compose-foot .send-btn:hover { color: var(--text); }
.compose-foot .send-btn:active { box-shadow: var(--s-shadow-sm); }
.compose-foot .send-btn:disabled { color: var(--text-faint); cursor: not-allowed; }
.compose-foot .status { color: var(--text-faint); font-size: 11px; letter-spacing: 0.2px; }

/* ── Toasts ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  padding: 14px 24px;
  border-radius: var(--radius);
  box-shadow: var(--r-shadow);
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  color: var(--text);
}
.toast.err { color: var(--red); }
.toast.ok { color: var(--green); }

/* ── Compose: From dropdown, attachment chips ──────────────────── */
.compose-from-wrap { flex: 1; }
.compose-from {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13.5px;
  padding: 8px 0;
  -webkit-appearance: none; appearance: none;
  cursor: pointer;
}
.compose-from:focus { outline: none; }
.compose-from option { background: var(--bg); color: var(--text); }

.att-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0 0; }
.att-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg);
  color: var(--text-dim);
  padding: 7px 12px 7px 14px;
  border-radius: 100px;
  font-size: 12px;
  box-shadow: var(--r-shadow-sm);
}
.att-chip .att-size { color: var(--text-faint); font-size: 11px; }
.att-chip .att-remove {
  background: var(--bg);
  border: none;
  color: var(--text-faint);
  width: 20px; height: 20px;
  border-radius: 50%;
  margin-left: 4px;
  font-size: 12px;
  cursor: pointer;
  box-shadow: var(--r-shadow-sm);
}
.att-chip .att-remove:hover { color: var(--red); }
.att-chip .att-remove:active { box-shadow: var(--s-shadow-sm); }

.compose-foot-left { display: flex; gap: 8px; align-items: center; }
.attach-btn {
  background: var(--bg);
  color: var(--text-dim);
  border: none;
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--r-shadow-sm);
  transition: color 0.15s ease, box-shadow 0.15s ease;
}
.attach-btn:hover { color: var(--text); }
.attach-btn:active { box-shadow: var(--s-shadow-sm); }

/* ── Settings modal ────────────────────────────────────────────── */
.settings-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 21, 26, 0.7);
  backdrop-filter: blur(4px);
  z-index: 150;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.settings-modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--r-shadow);
  width: 100%; max-width: 540px;
  max-height: 88vh;
  display: flex; flex-direction: column;
}
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px 16px;
}
.settings-head .title {
  font-size: 18px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--text);
}
.settings-head .close {
  background: var(--bg);
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  width: 36px; height: 36px;
  border-radius: 50%;
  box-shadow: var(--r-shadow-sm);
  transition: box-shadow 0.15s ease, color 0.15s ease;
}
.settings-head .close:hover { color: var(--text); }
.settings-head .close:active { box-shadow: var(--s-shadow-sm); }

.settings-body { padding: 0 28px 28px; overflow-y: auto; }
.settings-section {
  margin-bottom: 26px;
  padding-bottom: 26px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.settings-section:last-child { border-bottom: none; padding-bottom: 0; }
.settings-section h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.settings-section .field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.settings-section label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  padding-left: 4px;
}
.settings-section input, .settings-section textarea {
  background: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-size: 13.5px;
  box-shadow: var(--s-shadow-sm);
  transition: box-shadow 0.2s ease;
  font-family: inherit;
  resize: vertical;
}
.settings-section input:focus, .settings-section textarea:focus { outline: none; box-shadow: var(--s-shadow); }
.set-value {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-size: 13.5px;
  box-shadow: var(--s-shadow-sm);
}
.set-help { color: var(--text-dim); font-size: 12.5px; margin: 0 0 12px; }
.alias-row { display: flex; align-items: center; gap: 10px; }
.alias-row input { flex: 1; }
.alias-row .at-suffix { color: var(--text-dim); font-size: 13px; white-space: nowrap; }

.quota-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.quota-row .mono { color: var(--text); font-size: 12px; }
.quota-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  box-shadow: var(--s-shadow-sm);
  overflow: hidden;
}
.quota-fill {
  height: 100%;
  background: var(--text-dim);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ── Scrollbars ────────────────────────────────────────────────── */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--shadow-light); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 12px; padding: 12px;
  }
  .sidebar {
    grid-row: 1;
    flex-direction: row;
    padding: 14px 16px;
    align-items: center;
    min-height: 56px;
    overflow-x: auto;
  }
  .sidebar-head { padding: 0 12px 0 4px; flex-shrink: 0; }
  .sidebar-head .who { display: none; }
  .compose-btn { margin: 0 12px 0 0; padding: 8px 16px; font-size: 12px; flex-shrink: 0; }
  .folder-list { display: flex; padding: 0; flex: 1; overflow-x: auto; gap: 4px; }
  .folder { white-space: nowrap; padding: 6px 14px; font-size: 12px; flex-shrink: 0; }
  .folder .count { display: none; }
  .sidebar-foot { display: none; }
  .list-pane { grid-row: 2; }
  .reader { display: none; }
  .app.reading .list-pane { display: none; }
  .app.reading .reader { display: block; grid-row: 2; }
  .compose-overlay { right: 8px; left: 8px; width: auto; bottom: 8px; }
}
