:root {
  --bg: #f5f4f0;
  --card: #ffffff;
  --ink: #1d1c1a;
  --muted: #6a675f;
  --line: #e2dfd6;
  --accent: #1d5e49;
  --accent-ink: #ffffff;
  --soft: #eef3f0;
  --danger: #a43b2d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --card: #1f1e1b;
    --ink: #eceae4;
    --muted: #a29e93;
    --line: #35332e;
    --accent: #5fb497;
    --accent-ink: #0e1d18;
    --soft: #23302b;
    --danger: #e38d7f;
  }
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", sans-serif;
}
main { max-width: 880px; margin: 0 auto; padding: 16px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 19px; margin: 0 0 10px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.error { color: var(--danger); margin: 8px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.login { max-width: 380px; margin: 12vh auto 0; }
.login h1 { margin-bottom: 4px; }
.login label { display: block; margin: 14px 0 4px; font-size: 14px; color: var(--muted); }

input, select, button {
  font: inherit;
  color: inherit;
}
input, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
}
button {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button:disabled { opacity: 0.45; cursor: default; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.login button { width: 100%; margin-top: 18px; }

.bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.bar .who { flex: 1 1 200px; min-width: 0; }
.bar .who div { overflow-wrap: anywhere; }
.bar select { width: auto; max-width: 100%; }

.controls { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr) auto; gap: 8px; margin-bottom: 12px; }
@media (max-width: 620px) {
  .controls { grid-template-columns: 1fr; }
}

.list { padding: 0; overflow: hidden; }
.row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 2px 12px;
  width: 100%;
  text-align: start;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 16px;
  background: transparent;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--soft); }
.row .date { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; grid-row: span 2; padding-top: 2px; }
.row .from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .subject { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .clip { font-weight: 400; color: var(--muted); font-size: 13px; margin-inline-start: 8px; }
@media (max-width: 620px) {
  .row { grid-template-columns: minmax(0, 1fr); }
  .row .date { grid-row: auto; }
}
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }

.reader .meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; font-size: 15px; margin-bottom: 12px; }
.reader .meta dt { color: var(--muted); }
.reader .meta dd { margin: 0; overflow-wrap: anywhere; }
.reader .files { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.reader .files button { text-align: start; max-width: 100%; overflow-wrap: anywhere; }
.reader pre.body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

[hidden] { display: none !important; }
.tabs { display: flex; gap: 8px; margin: 14px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.tab { min-height: 38px; padding: 6px 14px; }
.tab.on { background: var(--soft); border-color: var(--accent); font-weight: 600; }
.mailframe { display: block; width: 100%; height: 72vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.tabs ~ pre.body { border-top: 0; padding-top: 0; margin-top: 0; }
.login.card { margin-top: 6vh; }
.actions { display: flex; gap: 8px; }
.actions button { min-height: 40px; padding: 8px 12px; font-size: 15px; }
