/* Mail Cleaner, Copyright (C) 2026 XxSeRyIxX. SPDX-License-Identifier: AGPL-3.0-or-later. Additional terms: see NOTICE. */
:root {
  --bg: #f3f4f7;
  --card: #ffffff;
  --text: #1b1f27;
  --muted: #667085;
  --line: #e3e6eb;
  --hover: #f6f7f9;
  --brand: #0f6cbd;
  --brand-hover: #0b5a9e;
  --brand-soft: #e7f0fa;
  --danger: #c4314b;
  --danger-hover: #a3283e;
  --danger-soft: #fcebee;
  --warn: #9a5a00;
  --warn-soft: #fff3df;
  --ok: #107c41;
  --ok-soft: #e6f4ea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --card: #191c22;
    --text: #e8eaef;
    --muted: #98a1b0;
    --line: #2a2f38;
    --hover: #20242b;
    --brand: #4ea1f3;
    --brand-hover: #73b5f6;
    --brand-soft: #18293b;
    --danger: #f06a80;
    --danger-hover: #f48b9c;
    --danger-soft: #3a1d24;
    --warn: #f1a93b;
    --warn-soft: #33270f;
    --ok: #5fd08a;
    --ok-soft: #15301f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* index.html marks the desktop edition before the first paint; it boots until the app shows a view. */
.desktop [data-only="web"], .booting #view-connect { display: none !important; }
.no-sizes .size-only { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
}

h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0; }
a { color: var(--brand); }
code { background: var(--hover); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--danger); }
.warn-text { color: var(--warn); }
.nowrap { white-space: nowrap; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
/* Stays on the right in the desktop edition, which hides the brand. */
.topbar > .row { margin-left: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; }
.account { display: flex; align-items: center; gap: 12px; color: var(--muted); }

main { max-width: 1680px; margin: 0 auto; padding: 20px 24px 60px; }
.stack { display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card.narrow { max-width: 640px; margin: 40px auto; }
.card > * + * { margin-top: 12px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.space { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.list-panel { position: sticky; top: 72px; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .list-panel { position: static; }
}

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn.ghost { background: transparent; }
.btn.small { padding: 3px 10px; font-size: 12.5px; }
.btn.big { padding: 11px 22px; font-size: 15px; }
.btn.wide { width: 100%; }
.btn.danger-ghost { color: var(--danger); background: transparent; }
.btn.danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.link { background: none; border: none; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--card);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; margin: 0; }
textarea { width: 100%; resize: vertical; }
textarea.mono { font: 12px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace; white-space: pre; }
#search { min-width: 240px; }
#add-input { flex: 1; min-width: 0; }

.form { display: grid; gap: 12px; }
.form label, .field { display: grid; gap: 4px; font-weight: 600; }
.form .server { align-items: end; }
.form .server .grow { flex: 1; min-width: 220px; }
#imap-port { width: 96px; }
.steps { padding-left: 20px; }
.steps li + li { margin-top: 6px; }

/* Connect: the service tabs, sign-in, and the steps to register your own app */
#oauth > * + *, #imap > * + *, #own-app > * + * { margin-top: 12px; }
#own-app > summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.box { background: var(--hover); padding: 10px 12px; border-radius: 8px; }
.box p { margin: 0 0 8px; }

/* Footer, About and the privacy page */
.footer { padding: 0 24px 24px; text-align: center; }
.footer a, .footer .link { color: var(--muted); }
h3 { font-size: 14px; margin: 0; }
.credits { margin: 6px 0 0; padding-left: 18px; }
.credits li + li { margin-top: 4px; }
.doc { line-height: 1.6; }
.doc h2 { margin-top: 18px; }
.doc > h2:first-child { margin-top: 0; }
.doc ul { padding-left: 20px; }
a.brand { color: inherit; text-decoration: none; }

/* Chips: folder pickers and filter toggles */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--text);
  font: inherit; cursor: pointer; user-select: none;
}
.chip:hover { background: var(--hover); }
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.chip .count { color: var(--muted); font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--card); color: var(--muted); font: inherit; font-weight: 600; padding: 6px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand-soft); color: var(--brand); }

.filters { display: grid; gap: 10px; padding: 12px; border-radius: 10px; background: var(--hover); }
.filter { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.filter select { padding: 4px 8px; }
.summary { margin: 12px 0 0; color: var(--muted); }
.summary b { color: var(--text); }

/* Progress */
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 10px 0 8px; }
.bar > div { height: 100%; width: 0; background: var(--brand); transition: width .4s ease; }

/* Overview cards */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); }
.stat .row { margin-top: 8px; }
.stat.alert b { color: var(--danger); }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Storage: one bar split by what uses the space, and its legend */
.meter { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--line); }
.meter > span { flex: none; height: 100%; background: var(--c); }
.meter > span + span { box-shadow: inset 2px 0 0 var(--card); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted); }
.legend:empty, #st-summary:empty { display: none; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend > span::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.legend b { color: var(--text); font-weight: 600; }
.part-0 { --c: #0f6cbd; }
.part-1 { --c: #5aa2e0; }
.part-2 { --c: #8764b8; }
.part-3 { --c: #2e9d7f; }
.part-4 { --c: #d08a2b; }
.part-rest { --c: #98a1b0; }
.part-trash { --c: var(--danger); }
.ok-text { color: var(--ok); }

.bulk {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; border-radius: 8px; background: var(--brand-soft);
}
.bulk span { font-weight: 600; margin-right: auto; }

/* Tables */
.grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.grid th, .grid td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.grid th[data-sort] { cursor: pointer; user-select: none; }
.grid th[data-sort]:hover { color: var(--text); }
.grid th.asc::after { content: " \2191"; }
.grid th.desc::after { content: " \2193"; }
.grid tbody tr:hover { background: var(--hover); }
.grid tbody tr.sel { background: var(--brand-soft); }
.grid .c-sel { width: 36px; }
.grid .c-who { width: 26%; }
.grid .c-num { width: 66px; text-align: right; }
.grid .c-size { width: 80px; text-align: right; }
.grid .c-date { width: 104px; }
.grid .c-actions { width: 150px; }
.grid .c-from { width: 28%; }
.grid .c-folder { width: 140px; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.actions { text-align: right; white-space: nowrap; }
.grid td.actions .btn + .btn { margin-left: 4px; }
.grid .ellipsis, .grid .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid .who .name { font-weight: 600; }
.grid .who .sub { color: var(--muted); font-size: 12.5px; }
.grid.compact td { padding: 6px 8px; }
.grid tr.unread td { font-weight: 600; }

.score {
  display: inline-block; min-width: 36px; padding: 1px 8px;
  border-radius: 999px; text-align: center; font-weight: 650; cursor: help;
}
.score.lo { background: var(--hover); color: var(--muted); }
.score.mid { background: var(--warn-soft); color: var(--warn); }
.score.hi { background: var(--danger-soft); color: var(--danger); }
.badge { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--ok-soft); color: var(--ok); }

.empty { text-align: center; color: var(--muted); padding: 30px 0; }

/* Remove list */
.ai-box { display: grid; gap: 6px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; }
#list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 46vh; overflow: auto; }
#list li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
#list li .k { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list li .n { color: var(--muted); font-variant-numeric: tabular-nums; }
#list li .x { border: none; background: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; }
#list li .x:hover { color: var(--danger); }
#list li.none { color: var(--muted); border: none; }

/* Dialogs */
dialog {
  width: min(560px, 92vw);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 22px;
  background: var(--card); color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}
dialog.wide { width: min(980px, 94vw); }
dialog::backdrop { background: rgba(12, 16, 24, .5); }
dialog > * + * { margin-top: 14px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.option input { margin-top: 2px; flex: none; }
.indent { padding-left: 26px; }
.warn-box { background: var(--warn-soft); color: var(--warn); padding: 10px 12px; border-radius: 8px; }
.info-box { background: var(--hover); padding: 10px 12px; border-radius: 8px; white-space: pre-line; }
.info-box:empty { display: none; }
.scroll { max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.scroll thead th { position: sticky; top: 0; background: var(--card); }
.pick-list, .link-list { max-height: 40vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 2px 12px; margin: 0; list-style: none; }
.pick-list:empty { display: none; }
.pick-list .option + .option { border-top: 1px solid var(--line); }
.link-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.link-list li + li { border-top: 1px solid var(--line); }
.link-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sender preview and mail viewer */
.grid.clickable tbody tr { cursor: pointer; }
.unsub-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.unsub-box ul { margin: 6px 0 0; padding-left: 18px; }
.unsub-box li + li { margin-top: 4px; }
.unsub-box .who { font-weight: 600; }
.unsub-box p { margin: 6px 0 0; }
/* Only when open: a display rule on a closed dialog would beat the browser's own "display: none". */
dialog.viewer[open] { width: min(1100px, 96vw); height: 92vh; display: flex; flex-direction: column; }
dialog.viewer > * + * { margin-top: 10px; }
.mail-head h2 { font-size: 18px; overflow-wrap: anywhere; }
.mail-head div { overflow-wrap: anywhere; }
#mv-body { flex: 1; width: 100%; min-height: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* Toasts */
#toasts {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 20; width: min(560px, 92vw);
}
.toast {
  background: #1f2633; color: #fff;
  padding: 11px 16px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.toast.bad { background: var(--danger); }
