:root {
  --rail: #1d2b4f;
  --rail-ink: #c9d3ea;
  --rail-hi: #2a3c69;
  --bg: #f2f4f7;
  --surface: #ffffff;
  --ink: #18202e;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e3e7ee;
  --accent: #2448c9;
  --accent-ink: #ffffff;
  --sel: #e7edfd;
  --hover: #f5f7fb;
  --airmail-red: #d23a44;
  --airmail-blue: #2448c9;
  --danger: #c0262f;
  --ok: #138a52;
  --warn: #b7791f;
  --shadow: 0 10px 30px rgba(20, 30, 60, .16), 0 2px 6px rgba(20, 30, 60, .08);
  --radius: 10px;
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --rail: #0c1222; --rail-ink: #aab6d3; --rail-hi: #1b2640;
    --bg: #11151c; --surface: #171c25; --ink: #e5e8ee; --muted: #8e97a8; --faint: #677083; --line: #252c39;
    --accent: #7c98ff; --accent-ink: #0c1222; --sel: #1e2943; --hover: #1b212c; --danger: #ff6b73; --ok: #45c486; --warn: #e3a948;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --rail: #0c1222; --rail-ink: #aab6d3; --rail-hi: #1b2640;
  --bg: #11151c; --surface: #171c25; --ink: #e5e8ee; --muted: #8e97a8; --faint: #677083; --line: #252c39;
  --accent: #7c98ff; --accent-ink: #0c1222; --sel: #1e2943; --hover: #1b212c; --danger: #ff6b73; --ok: #45c486; --warn: #e3a948;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* powiększenie całej poczty (przyciski + / − na szynie); vh/vw niżej są dzielone przez --zoom, bo zoom je mnoży */
:root { --zoom: 1; --rail-w: 84px; }
html { zoom: var(--zoom); }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.app { display: grid; grid-template-columns: var(--rail-w) 236px minmax(340px, 420px) 1fr; height: calc(100vh / var(--zoom)); overflow: hidden; }

/* --- szyna kont --- */
.rail { background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 8px; overflow-y: auto; scrollbar-width: none; }
.stamp { position: relative; width: 54px; height: 54px; border-radius: 16px; border: 0; background: transparent; display: grid; place-items: center; color: #fff; transition: border-radius .15s, background .15s; }
.stamp .mono { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-weight: 700; font-size: 17px; letter-spacing: .02em; background: var(--c, #3b82f6);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.18); transition: border-radius .15s; }
.stamp.all .mono { background: transparent; box-shadow: inset 0 0 0 2px var(--rail-ink); color: var(--rail-ink); }
.stamp:hover .mono, .stamp.on .mono { border-radius: 50%; }
.stamp.on::before { content: ''; position: absolute; left: calc((var(--rail-w) - 54px) / -2); top: 11px; bottom: 11px; width: 4px; border-radius: 0 4px 4px 0; background: #fff; }
/* prawy róg: nieprzeczytane; lewy róg: nowe od ostatniego kliknięcia konta */
.stamp .badge, .stamp .fresh { position: absolute; top: -4px; right: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--airmail-red); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 0 0 2px var(--rail); font-variant-numeric: tabular-nums; }
.stamp .fresh { right: auto; left: -6px; background: #3b82f6; }
.stamp .st { position: absolute; bottom: 0; right: 0; width: 13px; height: 13px; border-radius: 50%; box-shadow: 0 0 0 2px var(--rail); }
.st.live { background: #3ccf86; } .st.sync { background: #f2c94c; animation: pulse 1s infinite; } .st.err { background: #ff5c64; } .st.off { background: #5b6680; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .st.sync { animation: none; } }
.rail .sep { width: 36px; height: 1px; background: var(--rail-hi); margin: 4px 0; }
.rail .grow { flex: 1; }
.rail svg.i { width: 22px; height: 22px; }
.rail-btn { width: 48px; height: 48px; border-radius: 14px; border: 0; background: transparent; color: var(--rail-ink); display: grid; place-items: center; }
.rail-btn:hover { background: var(--rail-hi); color: #fff; }
.zoom-box { display: flex; flex-direction: column; align-items: center; gap: 0; margin: 4px 0; }
.rail-btn.sm { width: 44px; height: 38px; border-radius: 11px; }
.zoom-val { border: 0; background: transparent; color: var(--rail-ink); font-size: 12px; font-weight: 600; padding: 2px 0; font-variant-numeric: tabular-nums; opacity: .8; }
.zoom-val:hover { opacity: 1; color: #fff; }

/* --- foldery --- */
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 16px 16px 10px; }
.side-head h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-head .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-head .err { color: var(--danger); font-size: 12px; margin-top: 6px; }
.side-head { position: relative; }
.side-head h1, .side-head .sub { padding-right: 34px; }
.side-head .edit-nav { position: absolute; top: 10px; right: 10px; }
/* tryb zmiany kolejności folderów */
.edit-bar { margin: 4px 14px 10px; padding: 10px 12px; border-radius: 12px; background: var(--sel); color: var(--ink); font-size: 12.5px; display: flex; flex-direction: column; gap: 8px; }
.edit-bar svg.i { width: 15px; height: 15px; color: var(--accent); vertical-align: -3px; }
.edit-bar div { display: flex; gap: 6px; flex-wrap: wrap; }
.edit-bar .btn { height: 30px; padding: 0 10px; font-size: 12.5px; }
.nav.editing .nav-item { cursor: default; }
.nav.editing .nav-item:hover { background: none; }
.nav-item .grip { margin-left: auto; padding: 4px; margin-right: -4px; border-radius: 6px; cursor: grab; touch-action: none; display: grid; color: var(--muted); }
.nav-item .grip:hover { background: var(--hover); color: var(--ink); }
.nav-item.dragging { background: var(--sel); box-shadow: 0 0 0 2px var(--accent) inset; opacity: .9; }
.nav-item.dragging .grip { cursor: grabbing; }
.compose-btn { margin: 4px 14px 12px; height: 42px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; }
.compose-btn:hover { filter: brightness(1.08); }
.nav { overflow-y: auto; padding: 0 8px 16px; flex: 1; }
.nav h2 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 16px 10px 6px; display: flex; justify-content: space-between; align-items: center; }
.nav h2 button { border: 0; background: none; color: var(--muted); padding: 2px; border-radius: 6px; display: grid; }
.nav h2 button:hover { color: var(--ink); background: var(--hover); }
.nav-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 0; border-radius: 8px; background: none; text-align: left; color: var(--ink); }
.nav-item:hover { background: var(--hover); }
.nav-item.on { background: var(--sel); color: var(--accent); font-weight: 600; }
.nav-item .lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .cnt { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item.on .cnt, .nav-item .cnt.hot { color: var(--accent); }
.nav-item .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.nav-item svg.i { color: var(--muted); }
.nav-item.on svg.i { color: var(--accent); }
.nav-item.drop { outline: 2px dashed var(--accent); }

/* --- lista --- */
.list-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.topbar { display: flex; gap: 6px; align-items: center; padding: 12px 12px 8px; }
.search { flex: 1; display: flex; align-items: center; gap: 4px; background: var(--bg); border: 1px solid transparent; border-radius: 12px; padding: 0 4px 0 10px; height: 40px; }
.search:focus-within { border-color: var(--accent); background: var(--surface); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; height: 100%; }
.search-ico { color: var(--muted); display: grid; }
.icon-btn { width: 34px; height: 34px; border: 0; border-radius: 8px; background: none; color: var(--muted); display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.on { color: var(--accent); background: var(--sel); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.filters { margin: 0 12px 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; font-size: 13px; }
.filters label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 12px; }
.filters .full { grid-column: 1 / -1; }
.filters .checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.filters .checks label { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; }
.filters .accs { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px 3px 8px; background: var(--surface); display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip.on { border-color: var(--accent); background: var(--sel); }
.filters .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12px; }
input.f, select.f, textarea.f { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 9px; width: 100%; outline: none; }
input.f:focus, select.f:focus, textarea.f:focus { border-color: var(--accent); }
.btn { height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

.list-head { display: flex; align-items: center; gap: 4px; padding: 2px 8px 6px 14px; border-bottom: 1px solid var(--line); min-height: 44px; }
.list-head .title { flex: 1; min-width: 0; }
.list-head .title b { font-size: 15px; }
.list-head .title span { color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.list-head input[type=checkbox] { width: 16px; height: 16px; margin: 0 8px 0 0; accent-color: var(--accent); }
.list-head .scope { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-list { flex: 1; overflow-y: auto; outline: none; }
.msg { position: relative; display: grid; grid-template-columns: 22px 1fr auto; gap: 2px 8px; padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.msg::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); opacity: .9; }
.msg:hover { background: var(--hover); }
.msg.on { background: var(--sel); }
.msg.sel { background: var(--sel); }
.msg .ck { grid-row: 1 / 3; align-self: start; margin-top: 2px; width: 16px; height: 16px; accent-color: var(--accent); }
.msg .who { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.msg .when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; gap: 4px; align-items: center; }
.msg .subj { grid-column: 2 / 4; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg .snip { grid-column: 2 / 4; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.unread .who, .msg.unread .subj { color: var(--ink); font-weight: 650; }
.msg.unread .when { color: var(--accent); font-weight: 600; }
.msg .meta { display: flex; gap: 6px; align-items: center; grid-column: 2 / 4; font-size: 11.5px; color: var(--faint); }
.msg .acc { color: var(--muted); }
.msg svg.i { width: 14px; height: 14px; }
.msg .star { color: #e2a400; fill: #e2a400; }
.msg-more { padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.server-bar { margin: 8px 12px; padding: 8px 10px; border-radius: 9px; background: var(--sel); font-size: 12.5px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }

/* --- czytnik --- */
.reader { min-width: 0; min-height: 0; overflow-y: auto; background: var(--surface); }
.reader-empty { height: 100%; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.reader-empty .env { width: 120px; height: 80px; margin: 0 auto 16px; border-radius: 6px; background: var(--bg); position: relative; overflow: hidden; border: 1px solid var(--line); }
.reader-empty .env::before { content: ''; position: absolute; inset: 0; border: 6px solid transparent; border-image: repeating-linear-gradient(-45deg, var(--airmail-red) 0 8px, var(--surface) 8px 14px, var(--airmail-blue) 14px 22px, var(--surface) 22px 28px) 6; }
.reader-empty .env::after { content: ''; position: absolute; left: 50%; top: 30%; width: 34px; height: 24px; transform: translateX(-50%); border: 2px solid var(--faint); border-radius: 3px; }
.rtool { position: sticky; top: 0; z-index: 2; display: flex; gap: 2px; align-items: center; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.rtool .gap { flex: 1; }
.rbody { padding: 18px 24px 40px; max-width: 980px; }
.rsubject { font-size: 21px; line-height: 1.3; font-weight: 700; margin: 0 0 14px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.rfrom { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; background: var(--c); }
.rfrom .names { flex: 1; min-width: 0; }
.rfrom .names b { font-weight: 650; }
.rfrom .addr { color: var(--muted); font-size: 12.5px; }
.rfrom .rcpt { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.rfrom .date { color: var(--muted); font-size: 12.5px; text-align: right; white-space: nowrap; }
.acc-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px 2px 7px; border-radius: 20px; background: var(--bg); color: var(--muted); margin-top: 4px; }
.acc-tag i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.banner { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 9px; background: var(--bg); color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.banner button { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0; }
.mail-frame { width: 100%; border: 0; min-height: 120px; display: block; background: #fff; border-radius: 6px; }
.mail-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.6; }
.mail-text .q { color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; display: block; }
.mail-text a { color: var(--accent); }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.att { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; text-decoration: none; color: var(--ink); max-width: 280px; }
.att:hover { background: var(--hover); }
.att span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att small { color: var(--muted); white-space: nowrap; }
.thread { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 12px; }
.thread h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 6px; }
.thread button { display: flex; width: 100%; gap: 10px; border: 0; background: none; padding: 7px 8px; border-radius: 8px; text-align: left; align-items: center; }
.thread button:hover { background: var(--hover); }
.thread .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.thread .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread small { color: var(--muted); white-space: nowrap; }
.loading { padding: 40px; color: var(--muted); text-align: center; }

/* --- okno pisania --- */
.compose { position: fixed; right: 24px; bottom: 0; width: min(640px, calc(calc(100vw / var(--zoom)) - 32px)); height: min(640px, calc(calc(100vh / var(--zoom)) - 40px)); background: var(--surface); border-radius: 12px 12px 0 0;
  box-shadow: var(--shadow); display: flex; flex-direction: column; z-index: 40; overflow: hidden; border: 1px solid var(--line); border-bottom: 0; }
.compose.max { right: 50%; transform: translateX(50%); bottom: 20px; width: min(980px, calc(calc(100vw / var(--zoom)) - 40px)); height: calc(calc(100vh / var(--zoom)) - 40px); border-radius: 12px; border-bottom: 1px solid var(--line); }
.compose.min { height: 48px; }
.airmail { height: 6px; flex: none; background: repeating-linear-gradient(-45deg, var(--airmail-red) 0 10px, transparent 10px 16px, var(--airmail-blue) 16px 26px, transparent 26px 32px); }
.c-head { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 16px; font-weight: 600; cursor: default; }
.c-head .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-fields { border-top: 1px solid var(--line); }
.c-row { display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); min-height: 40px; position: relative; }
.c-row > label { color: var(--muted); width: 54px; flex: none; font-size: 13px; }
.c-row input, .c-row select { flex: 1; border: 0; outline: none; background: none; min-width: 0; height: 38px; }
.c-row .toggles { display: flex; gap: 4px; }
.c-row .row-x { width: 28px; height: 28px; }
.c-row .row-x svg.i { width: 15px; height: 15px; }
.c-row .toggles button { border: 0; background: none; color: var(--muted); font-size: 12.5px; padding: 4px 6px; border-radius: 6px; }
.c-row .toggles button:hover { background: var(--hover); color: var(--ink); }
.ac { position: absolute; left: 70px; right: 12px; top: 100%; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); overflow: hidden; }
.ac button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 12px; }
.ac button small { color: var(--muted); margin-left: 6px; }
.ac button.on, .ac button:hover { background: var(--sel); }
.c-tools { display: flex; gap: 2px; padding: 4px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.c-tools button { min-width: 30px; height: 30px; border: 0; background: none; border-radius: 6px; color: var(--muted); font-weight: 600; display: grid; place-items: center; padding: 0 6px; }
.c-tools button:hover { background: var(--hover); color: var(--ink); }
.c-body { flex: 1; overflow-y: auto; padding: 14px 16px; outline: none; line-height: 1.55; overflow-wrap: anywhere; }
.c-body blockquote { margin: 0 0 0 .8ex; border-left: 2px solid var(--line); padding-left: 1ex; color: var(--muted); }
.c-body img { max-width: 100%; }
.c-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.c-files .chip button { border: 0; background: none; padding: 0; color: var(--muted); display: grid; }
.c-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.c-foot .gap { flex: 1; }
.compose.drag .c-body { outline: 2px dashed var(--accent); outline-offset: -8px; }

/* --- modal ustawień --- */
.modal { position: fixed; inset: 0; background: rgba(10, 16, 30, .45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.dialog { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); width: min(860px, 100%); max-height: calc(calc(100vh / var(--zoom)) - 32px); display: flex; flex-direction: column; overflow: hidden; }
.dialog > header { display: flex; align-items: center; padding: 14px 16px 14px 22px; border-bottom: 1px solid var(--line); }
.dialog > header h2 { flex: 1; margin: 0; font-size: 17px; }
.dialog .tabs { display: flex; gap: 4px; padding: 10px 18px 0; border-bottom: 1px solid var(--line); }
.dialog .tabs button { border: 0; background: none; padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; }
.dialog .tabs button.on { color: var(--accent); border-color: var(--accent); }
.dialog .content { padding: 18px 22px 22px; overflow-y: auto; }
.acc-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.acc-row .mono { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; background: var(--c); flex: none; }
.acc-row .info { flex: 1; min-width: 0; }
.acc-row .info b { display: block; }
.acc-row .info small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-row .info .e { color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); grid-column: span 3; }
.form-grid label.s2 { grid-column: span 2; } .form-grid label.s1 { grid-column: span 1; } .form-grid label.s6 { grid-column: 1 / -1; } .form-grid label.s4 { grid-column: span 4; }
.form-grid h3 { grid-column: 1 / -1; margin: 8px 0 -4px; font-size: 14px; }
.form-grid .check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; }
.form-grid .actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.test-out { grid-column: 1 / -1; font-size: 12.5px; border-radius: 9px; padding: 10px 12px; background: var(--bg); white-space: pre-wrap; }
.test-out .ok { color: var(--ok); font-weight: 600; } .test-out .bad { color: var(--danger); font-weight: 600; }
details.adv { grid-column: 1 / -1; }
details.adv summary { cursor: pointer; color: var(--accent); font-size: 13px; }
details.adv .form-grid { margin-top: 12px; }

/* --- kreator stopki --- */
.dialog.wide { width: min(1240px, 100%); }
.sig-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.sig-side { position: sticky; top: 0; }
.sig-preview { background: #fff; color: #222; border: 1px solid var(--line); border-radius: 10px; padding: 20px; overflow: auto; max-height: calc(calc(100vh / var(--zoom)) - 220px); }
.img-pick { display: flex; align-items: center; gap: 8px; }
.img-pick .thumb { width: 44px; height: 44px; border-radius: 8px; border: 1px dashed var(--line); flex: none; display: grid; place-items: center; overflow: hidden; background: #fff; }
.img-pick .thumb img { max-width: 100%; max-height: 100%; }
.img-pick .btn { position: relative; cursor: pointer; }
.img-pick input.f { flex: 1; min-width: 0; }
.c-body .sig { color: inherit; }
@media (max-width: 900px) { .sig-wrap { grid-template-columns: 1fr; } .sig-side { position: static; } }

/* --- powiadomienia --- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px; pointer-events: auto; display: flex; gap: 12px; align-items: center; max-width: min(560px, calc(92vw / var(--zoom))); }
.toast.err { background: var(--danger); color: #fff; }
.toast button { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; padding: 0; }

.menu { position: fixed; z-index: 55; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; max-height: calc(60vh / var(--zoom)); overflow-y: auto; min-width: 220px; }
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 7px 10px; border-radius: 7px; text-align: left; }
.menu button:hover { background: var(--hover); }
.menu .grp { font-size: 11.5px; color: var(--muted); padding: 8px 10px 3px; display: flex; gap: 6px; align-items: center; }
.menu .grp i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

/* --- liczniki w panelu folderów --- */
.nav-item .tot { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; min-width: 14px; text-align: right; }
.nav-item .cnt + .tot::before { content: '/'; margin-right: 1px; }

/* --- własne okna potwierdzeń --- */
.ask-back { position: fixed; inset: 0; z-index: 70; background: rgba(10, 16, 30, .45); display: grid; place-items: center; padding: 16px; }
.ask { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); width: min(440px, 100%); padding: 20px 22px 16px; border-top: 6px solid transparent;
  border-image: repeating-linear-gradient(-45deg, var(--airmail-red) 0 10px, transparent 10px 16px, var(--airmail-blue) 16px 26px, transparent 26px 32px) 6 0 0 0; }
.ask h3 { margin: 0 0 6px; font-size: 17px; }
.ask p { margin: 0 0 14px; color: var(--muted); overflow-wrap: anywhere; }
.ask input.f { margin-bottom: 14px; }
.ask-check { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; font-size: 13px; }
.ask-btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.btn.danger { color: var(--danger); }
.btn.primary.danger { background: var(--danger); color: #fff; }

/* --- pasek formatowania --- */
.c-tools { align-items: center; }
.c-tools select { height: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 0 4px; font-size: 12.5px; max-width: 120px; }
.c-tools .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.c-tools button.on { background: var(--sel); color: var(--accent); }
.c-tools svg.i { width: 16px; height: 16px; }
.color-btn { position: relative; min-width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; cursor: pointer; color: var(--muted); font-weight: 700; }
.color-btn:hover { background: var(--hover); color: var(--ink); }
.color-btn span { border-bottom: 3px solid var(--airmail-red); line-height: 1.1; padding: 0 2px; }
.color-btn.hl span { border-bottom-color: #f3d33b; font-weight: 500; }
.color-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.c-body { font-family: Arial, Helvetica, sans-serif; font-size: 14px; }
.c-body hr { border: 0; border-top: 1px solid #ccc; }

/* --- tablety i telefony --- */
.only-mobile, .only-phone, .scrim, .fab { display: none; }
@media (max-width: 1280px) {
  :root { --rail-w: 76px; }
  .app { grid-template-columns: var(--rail-w) 210px minmax(300px, 360px) 1fr; }
}
/* tablet: panel folderów chowa się do wysuwanego menu, lista + podgląd obok siebie */
@media (max-width: 1100px) {
  .app { grid-template-columns: var(--rail-w) minmax(300px, 380px) 1fr; }
  .side { position: fixed; left: var(--rail-w); top: 0; bottom: 0; width: 280px; z-index: 30; box-shadow: var(--shadow); transform: translateX(calc(-100% - var(--rail-w))); transition: transform .2s; }
  .app.side-open .side { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 25; background: rgba(10, 16, 30, .4); }
  .app.side-open .scrim { display: block; }
  .only-mobile { display: grid; }
  .form-grid label, .form-grid label.s2, .form-grid label.s1, .form-grid label.s4 { grid-column: span 3; }
  .sig-wrap { grid-template-columns: 1fr; }
  .sig-side { position: static; }
}
/* tablet w pionie: lista na całą szerokość, podgląd otwiera się na cały ekran (pasek kont zostaje) */
@media (max-width: 900px) {
  .app { grid-template-columns: var(--rail-w) 1fr; }
  .reader { position: fixed; inset: 0 0 0 var(--rail-w); z-index: 20; display: none; }
  .app.reading .reader { display: block; }
  .only-phone { display: grid; }
  .rfrom { flex-wrap: wrap; }
  .rfrom .date { width: 100%; text-align: left; padding-left: 52px; }
}
/* telefon: jedna kolumna; konta + foldery w wysuwanym menu, podgląd i pisanie na cały ekran */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; height: calc(100dvh / var(--zoom)); }
  .rail { position: fixed; left: 0; top: 0; bottom: 0; width: var(--rail-w); z-index: 31; transform: translateX(-100%); transition: transform .2s; }
  .app.side-open .rail { transform: none; }
  .side { left: var(--rail-w); width: min(290px, calc(calc(100vw / var(--zoom)) - var(--rail-w))); }
  .list-pane { border-right: 0; }
  .topbar { padding: 10px 10px 8px; }
  .reader { inset: 0; }
  .rtool { padding: 6px 8px; gap: 0; }
  .rbody { padding: 14px 14px 90px; }
  .rsubject { font-size: 19px; }
  .fab { display: flex; position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 15; height: 54px; padding: 0 20px; border-radius: 18px; border: 0;
    background: var(--accent); color: var(--accent-ink); font-weight: 600; align-items: center; gap: 8px; box-shadow: var(--shadow); }
  .app.reading ~ .fab, .app.side-open ~ .fab { display: none; }
  .compose, .compose.max { right: 0; left: 0; top: 0; width: 100%; height: calc(100dvh / var(--zoom)); bottom: 0; transform: none; border-radius: 0; border: 0; }
  .compose.min { top: auto; height: 48px; }
  .c-tools { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .c-tools > * { flex: none; }
  .modal { padding: 0; }
  .dialog { height: calc(100dvh / var(--zoom)); max-height: calc(100dvh / var(--zoom)); border-radius: 0; }
  .dialog .content { padding: 14px 16px 24px; }
  .form-grid label, .form-grid label.s2, .form-grid label.s1, .form-grid label.s4 { grid-column: 1 / -1; }
  .filters { grid-template-columns: 1fr; }
  .toasts { bottom: 84px; }
  input.f, select.f, textarea.f, .search input, .c-row input, .c-row select { font-size: 16px; } /* bez zoomu na iOS */
}
@media (pointer: coarse) {
  .msg { padding-top: 12px; padding-bottom: 12px; }
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn svg.i, .nav-item svg.i { width: 21px; height: 21px; }
  .nav-item { padding: 10px 12px; }
  .msg .ck { width: 20px; height: 20px; }
}

/* --- wybór konta nadawcy --- */
.from-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 5px 6px; margin-left: -6px; border-radius: 8px; text-align: left; }
.from-btn:hover { background: var(--hover); }
.from-dot { width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center; background: var(--c); color: #fff; font-size: 11px; font-weight: 700; }
.from-txt { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: baseline; overflow: hidden; }
.from-txt b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.from-txt small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.from-chev { color: var(--muted); font-size: 12px; }
.menu .from-opt { padding: 8px 10px; gap: 10px; }
.menu .from-opt.on { background: var(--sel); }
.menu .from-opt .from-txt { flex-direction: column; gap: 0; }
.from-ok { color: var(--accent); font-weight: 700; }
select option { background: var(--surface); color: var(--ink); }

/* --- ikonka i kolor folderu --- */
.ask.fdlg { width: min(460px, 100%); }
.fd-label { font-size: 12px; color: var(--muted); margin: 4px 0 6px; }
.fd-icons { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-bottom: 12px; }
.fd-icons button { aspect-ratio: 1; border: 1px solid transparent; border-radius: 8px; background: var(--bg); color: var(--ink); display: grid; place-items: center; }
.fd-icons button:hover { border-color: var(--line); }
.fd-icons button.on { border-color: var(--accent); background: var(--sel); color: var(--accent); }
.fd-colors { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.fd-colors button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); background: var(--sw); box-shadow: 0 0 0 1px var(--line); padding: 0; }
.fd-colors button.on { box-shadow: 0 0 0 2px var(--accent); }
.fd-colors button.none { background: var(--bg); color: var(--muted); font-size: 12px; }
.fd-preview { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; background: var(--bg); margin-bottom: 14px; font-weight: 500; }
.fdlg input.f.bad { border-color: var(--danger); }
@media (max-width: 420px) { .fd-icons { grid-template-columns: repeat(6, 1fr); } }
