/* Korespondencja — centrum poczty powiązane z klientami, wycenami i zadaniami. */
.chat-unread-badge,
.mail-unread-badge {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  margin-left: auto;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font: 700 9px var(--mono);
}

.mobile-nav a { position: relative; }
.mobile-nav a .mail-unread-badge { position: absolute; top: 2px; left: calc(50% + 7px); min-width: 17px; height: 17px; margin: 0; padding: 0 4px; font-size: 9px; }

.view:has(.mail-shell) { min-height: 0; }
.content:has(.mail-shell) { max-width: none; }
.mail-shell {
  display: grid;
  grid-template-columns: minmax(214px, 248px) minmax(310px, 380px) minmax(430px, 1fr) 0;
  height: calc(100dvh - 128px);
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel-solid) 76%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(125%);
  transition: grid-template-columns .32s var(--ease);
}
.view.mail-context-open .mail-shell { grid-template-columns: minmax(200px, 232px) minmax(300px, 350px) minmax(380px, 1fr) minmax(264px, 310px); }

.mail-nav-panel,
.mail-list-panel,
.mail-thread-panel,
.mail-context-panel { min-width: 0; min-height: 0; overflow: hidden; }
.mail-nav-panel { display: flex; flex-direction: column; border-right: 1px solid var(--border); background: color-mix(in srgb, var(--panel-solid) 86%, transparent); }
.mail-list-panel { display: flex; flex-direction: column; border-right: 1px solid var(--border); background: color-mix(in srgb, var(--panel) 72%, transparent); }
.mail-thread-panel { display: flex; min-width: 0; flex-direction: column; background: color-mix(in srgb, var(--bg) 72%, transparent); }
.mail-context-panel { display: flex; width: 100%; min-width: 0; flex-direction: column; overflow-y: auto; border-left: 1px solid var(--border); background: var(--panel-solid); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.view.mail-context-open .mail-context-panel { opacity: 1; pointer-events: auto; }

.mail-nav-head,
.mail-context-panel > header { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 15px; border-bottom: 1px solid var(--border); }
.mail-nav-head h2,
.mail-context-panel > header h2 { margin: 0; overflow: hidden; font-size: 15px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.mail-nav-close { display: none; }

.mail-account-scope { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; margin: 10px 10px 4px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-2); }
.mail-account-scope button { min-width: 0; padding: 6px 5px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.mail-account-scope button.active { background: var(--panel-solid); color: var(--text); box-shadow: var(--shadow); }

.mail-account-list { display: grid; gap: 2px; padding: 8px 8px 4px; }
.mail-account-row { display: grid; grid-template-columns: minmax(0, 1fr) 34px; align-items: center; border-radius: 9px; }
.mail-account-row.active { background: var(--accent-soft); }
.mail-account-row > button { border: 0; background: transparent; color: var(--text); cursor: pointer; }
.mail-account-row > button:first-child { display: flex; min-width: 0; align-items: center; gap: 8px; padding: 8px; text-align: left; }
.mail-account-row > button:last-child { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 7px; color: var(--muted); }
.mail-account-row > button:last-child:hover { background: var(--panel-hover); color: var(--text); }
.mail-account-row span:not(.mail-account-dot) { display: grid; min-width: 0; flex: 1; }
.mail-account-row strong,
.mail-account-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-account-row strong { font-size: 11px; }
.mail-account-row small { color: var(--dim); font-size: 9px; }
.mail-account-row b { min-width: 18px; padding: 1px 5px; border-radius: 8px; background: var(--accent); color: #fff; font: 700 8px var(--mono); text-align: center; }
.mail-account-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--dim); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dim) 14%, transparent); }
.mail-account-dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.mail-account-dot.syncing,
.mail-account-dot.new { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.7s infinite; }
.mail-account-dot.error { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.mail-account-dot.paused { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }

.mail-smart-views,
.mail-folder-tree { display: grid; gap: 1px; padding: 7px 8px; overflow-y: auto; }
.mail-smart-views { flex: 1 1 auto; min-height: 80px; }
.mail-smart-views button,
.mail-folder-tree button { display: flex; min-width: 0; min-height: 30px; align-items: center; gap: 8px; padding: 5px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 10px; text-align: left; cursor: pointer; transition: color .16s, background .16s, transform .16s var(--ease); }
.mail-smart-views button:hover,
.mail-folder-tree button:hover { background: var(--panel-hover); color: var(--text); transform: translateX(1px); }
.mail-smart-views button.active,
.mail-folder-tree button.active { background: var(--accent-soft); color: var(--text); font-weight: 650; }
.mail-smart-views button.active .icon,
.mail-folder-tree button.active .icon { color: var(--accent); }
.mail-smart-views button span,
.mail-folder-tree button span { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-smart-views button b,
.mail-folder-tree button b { color: var(--dim); font: 650 9px var(--mono); }
.mail-folder-title { padding: 8px 14px 2px; border-top: 1px solid var(--border); color: var(--dim); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
/* The whole left panel scrolls as one list: views, then every folder (30+ after the mailbox was sorted) — nothing clipped. */
.mail-nav-panel { overflow-y: auto; overscroll-behavior: contain; }
.mail-smart-views,
.mail-folder-tree { flex: none; overflow: visible; }
.mail-folder-tree button { padding-left: calc(8px + var(--folder-level, 0) * 13px); }

.mail-sync-card { display: grid; gap: 4px; margin: 4px 9px 9px; padding: 9px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2); }
.mail-sync-card > div { display: flex; align-items: center; gap: 7px; }
.mail-sync-card strong { font-size: 10px; }
.mail-sync-card p { margin: 0; color: var(--dim); font-size: 9px; }
.mail-sync-card.error { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: var(--danger-soft); }
.mail-sync-progress { height: 4px; overflow: hidden; border-radius: 4px; background: var(--border); }
.mail-sync-progress span { display: block; height: 100%; border-radius: inherit; background: var(--grad); transition: width .35s var(--ease); }
.mail-nav-panel > footer { display: grid; gap: 8px; padding: 9px; border-top: 1px solid var(--border); }
.mail-work-notice { display: flex; align-items: flex-start; gap: 7px; padding: 8px; border-radius: 9px; background: var(--warn-soft); color: var(--text); font-size: 9px; line-height: 1.45; }
.mail-work-notice .icon { color: var(--warn); }

.mail-list-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; min-height: 66px; align-items: center; padding: 10px 12px 7px; border-bottom: 1px solid var(--border); }
.mail-mobile-folders { display: none; }
.mail-search { min-width: 0; }
.mail-search .input { min-width: 0; height: 38px; font-size: 12px; }
.mail-filter-row { display: flex; gap: 5px; overflow-x: auto; padding: 7px 10px; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.mail-filter-row::-webkit-scrollbar { display: none; }
.mail-filter-row button { flex: 0 0 auto; min-height: 27px; padding: 4px 9px; border: 1px solid var(--border); border-radius: 14px; background: transparent; color: var(--muted); font-size: 9px; cursor: pointer; transition: background .16s, border-color .16s, color .16s; }
.mail-filter-row button:hover,
.mail-filter-row button.active { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--accent-soft); color: var(--text); }
.mail-filter-row [data-shortcuts] { margin-left: auto; border-radius: 7px; font: 700 10px var(--mono); }

.mail-bulk-bar { display: flex; min-height: 40px; align-items: center; gap: 4px; overflow-x: auto; padding: 6px 10px; border-bottom: 1px solid var(--border); background: var(--accent-soft); }
.mail-bulk-bar strong { margin-right: auto; font: 650 9px var(--mono); }
.mail-bulk-bar button { display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 9px; cursor: pointer; white-space: nowrap; }
.mail-bulk-bar button:hover { background: var(--panel-hover); }

.mail-thread-list { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.mail-list-skeleton { display: grid; gap: 18px; padding: 18px; }
.mail-list-skeleton .skeleton { height: 68px; }
.mail-thread-row { position: relative; display: grid; grid-template-columns: 37px minmax(0, 1fr); gap: 9px; padding: 11px 10px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .17s, transform .17s var(--ease), border-color .17s; animation: mailRowIn .28s var(--ease) both; }
.mail-thread-row:hover,
.mail-thread-row:focus-visible { z-index: 1; background: var(--panel-hover); outline: 0; }
.mail-thread-row.active { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.mail-thread-row.selected { background: color-mix(in srgb, var(--accent-soft) 72%, var(--panel-hover)); }
.mail-thread-row.unread .mail-thread-line strong,
.mail-thread-row.unread .mail-thread-subject > span { font-weight: 750; color: var(--text); }
.mail-thread-row.unread::after { content: ''; position: absolute; top: 16px; right: 6px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.mail-thread-check { position: relative; display: grid; align-content: start; justify-items: center; cursor: pointer; }
.mail-thread-check input { position: absolute; z-index: 2; top: -2px; left: -2px; width: 15px; height: 15px; opacity: 0; cursor: pointer; }
.mail-thread-row:hover .mail-thread-check input,
.mail-thread-row.selected .mail-thread-check input,
.mail-thread-check input:focus-visible { opacity: 1; }
.mail-avatar { display: inline-grid; width: 34px; height: 34px; flex: none; place-items: center; border-radius: 11px; background: hsl(var(--mail-avatar, 200) 55% 44% / .19); color: hsl(var(--mail-avatar, 200) 72% 68%); font-size: 10px; font-weight: 750; letter-spacing: .02em; }
.mail-thread-copy { min-width: 0; }
.mail-thread-line { display: flex; min-width: 0; align-items: center; gap: 6px; }
.mail-thread-line strong { min-width: 0; flex: 1; overflow: hidden; color: var(--muted); font-size: 10.5px; font-weight: 590; text-overflow: ellipsis; white-space: nowrap; }
.mail-thread-line time { color: var(--dim); font: 500 8.5px var(--mono); white-space: nowrap; }
.mail-thread-icons { display: inline-flex; align-items: center; gap: 3px; color: var(--dim); }
.mail-thread-icons .icon { width: 12px; height: 12px; }
.mail-thread-icons b { font: 600 8px var(--mono); }
.mail-thread-subject { display: flex; min-width: 0; align-items: center; gap: 5px; margin-top: 2px; }
.mail-thread-subject > span { min-width: 0; flex: 1; overflow: hidden; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.mail-thread-subject button { display: grid; width: 20px; height: 20px; place-items: center; padding: 0; border: 0; background: transparent; color: var(--dim); cursor: pointer; opacity: 0; }
.mail-thread-row:hover .mail-thread-subject button,
.mail-thread-subject button.active { opacity: 1; }
.mail-thread-subject button.active { color: var(--warn); }
.mail-thread-copy > p { height: 16px; margin: 2px 0 5px; overflow: hidden; color: var(--dim); font-size: 9.5px; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; }
.mail-thread-copy mark { border-radius: 2px; background: var(--warn-soft); color: var(--text); }
.mail-thread-tags { display: flex; min-width: 0; gap: 4px; overflow: hidden; }
.mail-thread-tags > button,
.mail-state-badge,
.mail-owner-label { display: inline-flex; min-width: 0; flex: 0 1 auto; align-items: center; gap: 3px; overflow: hidden; padding: 2px 5px; border: 0; border-radius: 5px; background: var(--bg-2); color: var(--muted); font-size: 7.5px; line-height: 13px; text-overflow: ellipsis; white-space: nowrap; }
.mail-thread-tags > button { cursor: pointer; }
.mail-thread-tags > button:hover { background: var(--accent-soft); color: var(--accent); }
.mail-thread-tags .icon { width: 10px; height: 10px; }
.mail-state-badge.todo { background: var(--danger-soft); color: var(--danger); }
.mail-state-badge.waiting,
.mail-state-badge.reminder { background: var(--warn-soft); color: var(--warn); }
.mail-state-badge.internal { background: var(--accent-soft); color: var(--accent); }
.mail-state-badge.deleted { background: var(--danger-soft); color: var(--danger); }
.mail-owner-label { margin-left: auto; }
.mail-load-older { display: block; width: calc(100% - 20px); margin: 10px; padding: 9px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-2); color: var(--muted); font-size: 10px; cursor: pointer; }
.mail-list-error,
.mail-thread-empty,
.mail-thread-loading { display: grid; min-height: 240px; flex: 1; place-items: center; align-content: center; gap: 9px; padding: 24px; color: var(--muted); text-align: center; }
.mail-list-error > .icon { width: 32px; height: 32px; color: var(--danger); }
.mail-list-error strong { color: var(--text); }
.mail-thread-loading { align-content: start; place-items: stretch; padding-top: 26px; }
.mail-thread-loading .skeleton { height: 90px; }

.mail-thread-head { display: flex; min-height: 74px; align-items: center; gap: 10px; padding: 10px 15px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--panel-solid) 88%, transparent); }
.mail-thread-back { display: none; }
.mail-thread-heading { min-width: 0; flex: 1; }
.mail-thread-heading h2 { margin: 0; overflow: hidden; font-size: clamp(14px, 1.25vw, 18px); letter-spacing: -.025em; text-overflow: ellipsis; white-space: nowrap; }
.mail-thread-heading p { margin: 2px 0 0; overflow: hidden; color: var(--dim); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.mail-readonly-badge { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; padding: 2px 6px; border-radius: 5px; background: var(--warn-soft); color: var(--warn); font-size: 8px; font-weight: 650; }
.mail-foreign-badge { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; padding: 2px 6px; border-radius: 5px; background: var(--bg-2); color: var(--muted); font-size: 8px; font-weight: 600; }
.mail-thread-actions { display: flex; flex: none; align-items: center; gap: 3px; }
.mail-thread-actions .btn.active { color: var(--warn); }
.mail-thread-toolbar { display: flex; gap: 4px; overflow-x: auto; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--panel); scrollbar-width: none; }
.mail-thread-toolbar::-webkit-scrollbar { display: none; }
.mail-thread-toolbar button,
.mail-thread-toolbar a { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 5px; min-height: 28px; padding: 4px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 9px; cursor: pointer; }
.mail-thread-toolbar button:hover,
.mail-thread-toolbar a:hover { background: var(--panel-hover); color: var(--text); text-decoration: none; }
.mail-message-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px clamp(10px, 2vw, 24px) 26px; scroll-behavior: smooth; }
.mail-message-card { margin-bottom: 9px; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); box-shadow: 0 5px 20px -18px rgba(0, 0, 0, .9); transition: border-color .2s, background .2s; }
.mail-message-card[open] { border-color: var(--border-strong); background: color-mix(in srgb, var(--panel-solid) 90%, transparent); }
.mail-message-card.outgoing { box-shadow: inset 3px 0 color-mix(in srgb, var(--accent) 55%, transparent); }
.mail-message-card > summary { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 9px; align-items: center; min-height: 58px; padding: 9px 11px; cursor: pointer; list-style: none; }
.mail-message-card > summary::-webkit-details-marker { display: none; }
.mail-message-card > summary > span:nth-child(2) { display: grid; min-width: 0; }
.mail-message-card > summary strong,
.mail-message-card > summary small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-message-card > summary strong { font-size: 11px; }
.mail-message-card > summary small { color: var(--dim); font-size: 9px; }
.mail-message-card > summary time { color: var(--dim); font: 500 8.5px var(--mono); }
.mail-message-card > summary em { grid-column: 2 / -1; color: var(--danger); font-size: 8px; }
.mail-message-meta { padding: 8px 14px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); color: var(--dim); font-size: 9px; }
.mail-message-meta details > summary { cursor: pointer; }
.mail-message-body { padding: 14px; }
.mail-text { margin: 0; overflow-wrap: anywhere; color: var(--text); font: 400 12px/1.65 var(--font); white-space: pre-wrap; }
.mail-html-wrap { overflow: hidden; border-radius: 8px; background: #fff; }
.mail-html-frame { display: block; width: 100%; height: 260px; border: 0; background: #fff; color-scheme: light; transition: height .18s ease; }
.mail-remote-images { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-bottom: 1px solid #d7dce0; background: #fff7e5; color: #5d4600; font-size: 10px; }
.mail-remote-images span { flex: 1; }
.mail-remote-images button { padding: 3px 7px; border: 1px solid #d4bb74; border-radius: 5px; background: #fff; color: #5d4600; cursor: pointer; }
.mail-quoted { margin: 0 14px 12px; color: var(--dim); font-size: 9px; }
.mail-quoted summary { cursor: pointer; }
.mail-quoted pre { padding: 10px; border-left: 2px solid var(--border-strong); background: var(--bg-2); }

.mail-attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 7px; padding: 0 14px 14px; }
.mail-attachment-card { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 54px; padding: 7px; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-2); }
.mail-attachment-card > img,
.mail-file-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 7px; background: var(--panel-solid); color: var(--accent); object-fit: cover; }
.mail-attachment-card > div:nth-child(2) { display: grid; min-width: 0; }
.mail-attachment-card strong,
.mail-attachment-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-attachment-card strong { font-size: 9.5px; }
.mail-attachment-card small { color: var(--dim); font-size: 8px; }
.mail-attachment-card > div:last-child { display: flex; align-items: center; gap: 2px; }
.mail-attachment-card button,
.mail-attachment-card a { display: grid; width: 27px; height: 27px; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.mail-attachment-card button:hover,
.mail-attachment-card a:hover { background: var(--panel-hover); color: var(--accent); }

.mail-notes { display: grid; gap: 7px; margin: 14px 0; padding: 11px; border: 1px solid color-mix(in srgb, var(--warn) 25%, var(--border)); border-radius: 12px; background: var(--warn-soft); }
.mail-notes > header { display: flex; align-items: center; gap: 6px; color: var(--warn); font-size: 10px; }
.mail-notes > header span { margin-left: auto; color: var(--muted); font-size: 8px; }
.mail-notes article { padding: 8px; border-radius: 8px; background: color-mix(in srgb, var(--panel-solid) 82%, transparent); }
.mail-notes article > div { display: flex; justify-content: space-between; gap: 8px; }
.mail-notes article strong { font-size: 9.5px; }
.mail-notes article time { color: var(--dim); font-size: 8px; }
.mail-notes article p { margin: 4px 0 0; font-size: 10px; white-space: pre-wrap; }
.mail-notes form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; align-items: end; }
.mail-notes textarea { min-height: 50px; font-size: 11px; }
.mail-quick-reply { display: flex; width: 100%; align-items: center; gap: 10px; padding: 13px; border: 1px dashed var(--border-strong); border-radius: 11px; background: var(--panel); color: var(--muted); text-align: left; cursor: text; }
.mail-quick-reply:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.mail-quick-reply > span { display: grid; }
.mail-quick-reply small { color: var(--dim); }

.mail-context-panel > section,
.mail-context-panel > footer { margin: 10px; padding: 11px; border: 1px solid var(--border); border-radius: 11px; background: var(--bg-2); }
.mail-context-client { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 8px; }
.mail-context-client > div:nth-child(2) { display: grid; align-content: center; }
.mail-context-client > div:nth-child(2) span { color: var(--dim); font-size: 9px; }
.mail-context-client dl { display: grid; grid-column: 1 / -1; grid-template-columns: 62px minmax(0, 1fr); gap: 5px 8px; margin: 5px 0; font-size: 9.5px; }
.mail-context-client dt { color: var(--dim); }
.mail-context-client dd { margin: 0; overflow-wrap: anywhere; }
.mail-context-client .btn { grid-column: 1 / -1; }
.mail-context-empty { display: grid; justify-items: center; gap: 8px; text-align: center; }
.mail-context-empty > .icon { width: 30px; height: 30px; color: var(--dim); }
.mail-context-empty p { margin: 0; color: var(--muted); font-size: 10px; }
.mail-context-empty button,
.mail-context-list button,
.mail-context-list > div { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; padding: 7px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.mail-context-list > div { cursor: default; }
.mail-context-list h3 { margin: 0 0 5px; color: var(--dim); font-size: 9px; letter-spacing: .05em; text-transform: uppercase; }
.mail-context-list button > span,
.mail-context-list > div > span,
.mail-context-empty button { display: grid; min-width: 0; }
.mail-context-list strong,
.mail-context-list small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-context-list strong { font-size: 9.5px; }
.mail-context-list small { color: var(--dim); font-size: 8px; }
.mail-context-list b,
.mail-context-list time { color: var(--muted); font-size: 8px; white-space: nowrap; }
.mail-context-panel > footer { display: grid; gap: 6px; margin-top: auto; }
.mail-context-panel > footer .btn { justify-content: flex-start; }

.mail-loading-screen { display: grid; min-height: 55vh; place-items: center; align-content: center; gap: 18px; }
.mail-loading-mark { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 18px; background: var(--grad); color: #fff; box-shadow: var(--glow); animation: float 3s ease-in-out infinite; }
.mail-loading-screen > div:last-child { display: grid; width: min(360px, 75vw); gap: 10px; }
.mail-unavailable { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; max-width: 900px; margin: 8vh auto; }
.mail-unavailable h2 { margin: 0; }
.mail-unavailable p { max-width: 68ch; color: var(--muted); }

.mail-onboarding { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(350px, .8fr); gap: clamp(28px, 6vw, 90px); min-height: calc(100dvh - 160px); align-items: center; max-width: 1160px; margin: 0 auto; }
.mail-onboarding-copy { padding: 24px; }
.mail-eyebrow { color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.mail-onboarding-copy h2 { max-width: 12ch; margin: 10px 0 16px; font-size: clamp(32px, 5vw, 62px); line-height: .98; letter-spacing: -.055em; text-wrap: balance; }
.mail-onboarding-copy > p { max-width: 55ch; color: var(--muted); font-size: 15px; line-height: 1.7; }
.mail-onboarding-benefits { display: grid; gap: 8px; margin: 24px 0; }
.mail-onboarding-benefits span { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.mail-onboarding-benefits .icon { color: var(--accent); }
.mail-account-form { display: grid; gap: 13px; padding: 24px; }
.mail-account-form .btn { min-height: 44px; }
.mail-advanced { border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2); }
.mail-advanced > summary { padding: 10px; color: var(--muted); font-size: 11px; cursor: pointer; }
.mail-advanced .form-grid { padding: 0 10px 12px; }
.mail-field-error { min-height: 14px; color: var(--danger); font-size: 9px; }
.mail-signature-editor { min-height: 100px; padding: 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg-2); color: var(--text); font-weight: 400; }
.mail-account-actions,
.mail-connect-choice,
.mail-schedule-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.mail-inline-error { display: flex; align-items: flex-start; gap: 7px; margin: 8px; padding: 9px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 10px; }
.mail-inline-error button { margin-left: auto; border: 0; background: transparent; color: inherit; cursor: pointer; text-decoration: underline; }

.mail-access-log,
.mail-context-search,
.mail-ref-results,
.mail-template-list { display: grid; max-height: min(60vh, 520px); overflow-y: auto; gap: 4px; margin-top: 10px; }
.mail-access-log article { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; padding: 9px; border-bottom: 1px solid var(--border); }
.mail-access-log time { grid-row: span 2; color: var(--dim); font: 500 9px var(--mono); }
.mail-access-log span,
.mail-access-log small { color: var(--muted); font-size: 10px; }
.mail-context-search button,
.mail-ref-results button,
.mail-template-list > div > button:first-child { display: grid; width: 100%; min-width: 0; gap: 2px; padding: 9px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.mail-context-search button:hover,
.mail-ref-results button:hover,
.mail-template-list > div > button:first-child:hover { background: var(--panel-hover); }
.mail-context-search small,
.mail-ref-results small,
.mail-template-list small { color: var(--dim); font-size: 9px; }
.mail-ref-results button { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
.mail-ref-results button > span { display: grid; min-width: 0; }
.mail-template-list > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.mail-contact-empty { padding: 20px; color: var(--dim); text-align: center; }
.client-mail-list { display: grid; gap: 3px; }
.client-mail-list > button { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.client-mail-list > button:hover { background: var(--panel-hover); }
.client-mail-direction { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.client-mail-direction.out { background: var(--success-soft); color: var(--success); }
.client-mail-list > button > span:nth-child(2) { display: grid; min-width: 0; }
.client-mail-list strong,
.client-mail-list small,
.client-mail-list em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-mail-list small { color: var(--muted); font-size: 10px; }
.client-mail-list em { color: var(--dim); font-size: 8px; font-style: normal; }
.client-mail-list time { color: var(--dim); font: 500 8px var(--mono); white-space: nowrap; }
.client-mail-error { display: flex; align-items: flex-start; gap: 7px; padding: 9px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 10px; }
.mail-action-list { display: grid; gap: 3px; max-height: min(58vh, 440px); overflow-y: auto; }
.mail-action-list button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.mail-action-list button:hover { background: var(--panel-hover); }
.mail-action-list kbd { margin-left: auto; }
.mail-shortcut-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 14px; }
.mail-shortcut-list > div { display: grid; grid-template-columns: 70px minmax(0, 1fr); align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.mail-shortcut-list kbd { width: max-content; padding: 2px 6px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--bg-2); font: 600 10px var(--mono); }
.mail-shortcut-list span { color: var(--muted); font-size: 11px; }
.mail-ai-loading { display: grid; min-height: 210px; place-items: center; align-content: center; gap: 8px; color: var(--muted); text-align: center; }
.mail-ai-loading > .icon { width: 34px; height: 34px; color: var(--accent); animation: float 2s ease-in-out infinite; }
.mail-ai-loading strong { color: var(--text); }
.mail-ai-summary { max-height: 65vh; overflow-y: auto; }
.mail-ai-summary h3 { font-size: 12px; }
.mail-ai-summary small { color: var(--dim); }
.mail-inquiry { display: flex; gap: 8px; padding: 9px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); }
.mail-inquiry > span { display: grid; }

.mail-preview-modal { width: min(1100px, 94vw); max-width: none; }
.mail-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.mail-preview-image { display: block; width: 100%; max-height: 76vh; border-radius: 9px; object-fit: contain; background: var(--bg-2); }
.mail-preview-pdf { display: block; width: 100%; height: 76vh; border: 0; border-radius: 9px; background: #fff; }

/* Dokowane okna nowej wiadomości. */
.mail-compose-stack { position: fixed; z-index: 80; right: 20px; bottom: 0; display: flex; max-width: calc(100vw - 40px); align-items: flex-end; gap: 10px; pointer-events: none; }
.mail-compose-window { width: min(540px, calc(100vw - 40px)); overflow: visible; border: 1px solid var(--border-strong); border-bottom: 0; border-radius: 14px 14px 0 0; background: var(--panel-solid); box-shadow: 0 -8px 42px -18px rgba(0, 0, 0, .8); pointer-events: auto; animation: composeIn .28s var(--ease) both; }
.mail-compose-window > header { display: flex; height: 42px; align-items: center; gap: 3px; padding: 0 8px 0 13px; border-radius: 13px 13px 0 0; background: color-mix(in srgb, var(--bg-2) 86%, var(--accent-soft)); cursor: default; }
.mail-compose-window > header > div { display: flex; min-width: 0; flex: 1; align-items: center; gap: 8px; }
.mail-compose-window > header span { overflow: hidden; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.mail-compose-window > header small { color: var(--dim); font-size: 8px; }
.mail-compose-window > header button { display: grid; width: 30px; height: 30px; place-items: center; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.mail-compose-window > header button:hover { background: var(--panel-hover); color: var(--text); }
.mail-compose-window.minimized { width: 300px; }
.mail-compose-window.minimized .mail-compose-body { display: none; }
.mail-compose-body { position: relative; }
.mail-compose-from,
.mail-recipient-row { display: flex; min-height: 38px; align-items: center; gap: 6px; padding: 4px 10px; border-bottom: 1px solid var(--border); }
.mail-compose-from > span,
.mail-recipient-row > span:first-child { width: 28px; flex: none; color: var(--dim); font-size: 9px; }
.mail-compose-from select { height: 30px; padding-block: 3px; border: 0; background: transparent; font-size: 10px; }
.mail-recipient-row > div { display: flex; min-width: 0; flex-wrap: wrap; gap: 3px; }
.mail-recipient-row > input { min-width: 70px; flex: 1; padding: 5px 2px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 11px; }
.mail-recipient-row > button { border: 0; background: transparent; color: var(--dim); font-size: 9px; cursor: pointer; }
.mail-recipient-chip { display: inline-flex; max-width: 180px; align-items: center; gap: 3px; padding: 2px 4px 2px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--text); font-size: 9px; }
.mail-recipient-chip.team { background: var(--success-soft); }
.mail-recipient-chip.history { background: var(--bg-2); }
.mail-recipient-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-recipient-chip button { display: grid; width: 17px; height: 17px; place-items: center; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.mail-contact-results { position: absolute; z-index: 4; top: 76px; right: 8px; left: 40px; max-height: 250px; overflow-y: auto; padding: 5px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--panel-solid); box-shadow: var(--shadow); }
.mail-contact-results button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 7px; border: 0; border-radius: 7px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.mail-contact-results button:hover { background: var(--panel-hover); }
.mail-contact-results button > span:last-child { display: grid; min-width: 0; }
.mail-contact-results small { color: var(--dim); font-size: 8px; }
.mail-contact-kind { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.mail-compose-subject { display: block; width: 100%; height: 39px; padding: 7px 11px; border: 0; border-bottom: 1px solid var(--border); outline: 0; background: transparent; color: var(--text); font-size: 11px; font-weight: 600; }
.mail-rich-toolbar { display: flex; gap: 2px; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.mail-rich-toolbar button { display: grid; width: 28px; height: 28px; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.mail-rich-toolbar button:hover { background: var(--panel-hover); color: var(--text); }
.mail-compose-editor { min-height: 190px; max-height: 42vh; overflow-y: auto; padding: 12px; outline: 0; color: var(--text); font-size: 12px; line-height: 1.6; }
.mail-compose-editor:empty::before { content: attr(data-placeholder); color: var(--dim); pointer-events: none; }
.mail-compose-editor a { text-decoration: underline; }
.mail-compose-quote { margin: 12px 0; color: var(--dim); font-size: 10px; }
.mail-compose-quote blockquote { margin: 6px 0; padding-left: 9px; border-left: 2px solid var(--border-strong); white-space: pre-wrap; }
.mail-signature { margin-top: 16px; color: var(--muted); }
.mail-compose-attachments { display: flex; gap: 5px; overflow-x: auto; padding: 0 9px; }
.mail-compose-attachment { display: inline-flex; max-width: 210px; flex: 0 0 auto; align-items: center; gap: 5px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-2); font-size: 8.5px; }
.mail-compose-attachment > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-compose-attachment small { color: var(--dim); }
.mail-compose-attachment button { display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.mail-upload-state { padding: 5px 11px; color: var(--accent); font-size: 9px; }
.mail-compose-tools { display: flex; gap: 2px; overflow-x: auto; padding: 7px 8px; border-top: 1px solid var(--border); }
.mail-compose-tools .btn { flex: 0 0 auto; min-height: 30px; padding: 5px 7px; font-size: 9px; }
.mail-compose-body > footer { display: flex; align-items: center; gap: 4px; padding: 8px; border-top: 1px solid var(--border); }
.mail-compose-body > footer .small { font-size: 8px; }
.mail-action-toast { align-items: center; }
.mail-action-toast button { margin-left: auto; padding: 4px 8px; border: 0; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-weight: 700; cursor: pointer; }
.mail-ref-search { margin-bottom: 8px; }

@keyframes mailRowIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes composeIn { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }

/* Motyw operacyjny dziedziczy te same kontrakty, lecz rezygnuje z efektów szkła. */
[data-skin='ops'] .mail-shell,
[data-skin='ops'] .mail-nav-panel,
[data-skin='ops'] .mail-list-panel,
[data-skin='ops'] .mail-thread-panel,
[data-skin='ops'] .mail-compose-window { backdrop-filter: none; }
[data-skin='ops'] .mail-shell { border-radius: 8px; background: var(--panel-solid); box-shadow: var(--shadow); }
[data-skin='ops'] .mail-thread-row:hover { transform: none; }
[data-skin='ops'] .mail-thread-row.active { box-shadow: inset 3px 0 var(--accent); }
[data-skin='ops'] .mail-avatar { border-radius: 6px; }
[data-skin='ops'] .mail-message-card,
[data-skin='ops'] .mail-context-panel > section,
[data-skin='ops'] .mail-context-panel > footer { border-radius: 6px; }
[data-skin='ops'] .mail-compose-window { border-radius: 8px 8px 0 0; }
[data-skin='ops'] .mail-compose-window > header { border-radius: 7px 7px 0 0; }
[data-skin='ops'] .mail-smart-views button,
[data-skin='ops'] .mail-folder-tree button { font-size: 12.5px; }
[data-skin='ops'] .mail-thread-line strong,
[data-skin='ops'] .mail-thread-subject > span { font-size: 13px; }
[data-skin='ops'] .mail-thread-copy > p { font-size: 11.5px; }
[data-skin='ops'] .mail-message-card > summary strong { font-size: 13px; }
[data-skin='ops'] .mail-text { font-size: 14px; }

@media (max-width: 1240px) {
  .mail-shell { grid-template-columns: 210px minmax(290px, 340px) minmax(380px, 1fr) 0; }
  .view.mail-context-open .mail-shell { grid-template-columns: 0 minmax(280px, 320px) minmax(360px, 1fr) minmax(250px, 290px); }
  .view.mail-context-open .mail-nav-panel { opacity: 0; pointer-events: none; }
  .mail-thread-actions .btn span { display: none; }
}

@media (max-width: 900px) {
  .content:has(.mail-shell) { padding: 0 0 calc(82px + env(safe-area-inset-bottom)); }
  .mail-shell,
  .view.mail-context-open .mail-shell { display: block; height: calc(100dvh - 130px - env(safe-area-inset-bottom)); min-height: 0; border-right: 0; border-left: 0; border-radius: 0; }
  .mail-list-panel { height: 100%; border-right: 0; }
  .mail-thread-panel,
  .mail-context-panel { display: none; height: 100%; border: 0; opacity: 1; pointer-events: auto; }
  .view.mail-thread-open .mail-list-panel { display: none; }
  .view.mail-thread-open .mail-thread-panel { display: flex; }
  .view.mail-context-open .mail-thread-panel { display: none; }
  .view.mail-context-open .mail-context-panel { display: flex; }
  .mail-nav-panel { position: fixed; z-index: 70; inset: 0 auto 0 0; display: flex; width: min(330px, 88vw); height: 100dvh; padding-bottom: env(safe-area-inset-bottom); border-right: 1px solid var(--border-strong); background: var(--panel-solid); box-shadow: 24px 0 60px rgba(0, 0, 0, .48); transform: translateX(-105%); transition: transform .28s var(--ease); }
  .view.mail-nav-open .mail-nav-panel { transform: none; }
  /* the phone's bottom bar covers the panel's last rows otherwise */
  .mail-nav-panel { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .view.mail-nav-open::after { content: ''; position: fixed; z-index: 65; inset: 0; background: rgba(0, 0, 0, .46); backdrop-filter: blur(2px); }
  .mail-nav-close,
  .mail-mobile-folders,
  .mail-thread-back { display: inline-flex; }
  .mail-list-head { grid-template-columns: auto minmax(0, 1fr) auto; padding-top: 8px; }
  .mail-thread-row { min-height: 84px; padding-block: 12px; }
  .mail-thread-row:hover .mail-thread-check input { opacity: 0; }
  .mail-thread-row.selected .mail-thread-check input { opacity: 1; }
  .mail-message-scroll { padding: 10px 8px 22px; }
  .mail-thread-head { min-height: 64px; padding: 7px 8px; }
  .mail-thread-heading h2 { font-size: 14px; }
  .mail-thread-actions .btn,
  .mail-thread-toolbar button,
  .mail-thread-toolbar a,
  .mail-attachment-card button,
  .mail-attachment-card a,
  .mail-filter-row button { min-width: 44px; min-height: 44px; }
  .mail-thread-toolbar button,
  .mail-thread-toolbar a { justify-content: center; }
  .mail-filter-row button { min-width: auto; }
  .mail-context-panel > header { position: sticky; z-index: 2; top: 0; background: var(--panel-solid); }
  .mail-compose-stack { z-index: 100; inset: 0; display: block; max-width: none; transform: translateY(var(--vv-shift, 0)); }
  .mail-compose-window,
  .mail-compose-window.minimized { display: flex; width: 100vw; height: 100dvh; flex-direction: column; border: 0; border-radius: 0; }
  .mail-compose-window:not(:last-child) { display: none; }
  .mail-compose-window > header { flex: none; height: calc(54px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); border-radius: 0; }
  .mail-compose-window.minimized { height: auto; top: auto; }
  .mail-compose-body { display: flex; min-height: 0; flex: 1; flex-direction: column; }
  .mail-compose-editor { flex: 1; min-height: 130px; max-height: none; font-size: 16px; }
  .mail-recipient-row > input,
  .mail-compose-subject,
  .mail-compose-from select { font-size: 16px; }
  .mail-compose-body > footer { padding-bottom: max(9px, env(safe-area-inset-bottom)); }
  .mail-compose-tools .btn { min-height: 44px; }
  .mail-contact-results { top: 86px; }
}

@media (max-width: 560px) {
  .mail-list-head [data-compose] span { display: none; }
  .mail-list-head [data-compose] { width: 42px; padding-inline: 0; }
  .mail-filter-row { padding-inline: 7px; }
  .mail-thread-row { grid-template-columns: 35px minmax(0, 1fr); padding-inline: 8px; }
  .mail-thread-head [data-reply] span { display: none; }
  .mail-thread-actions { gap: 0; }
  .mail-thread-actions .btn { padding-inline: 8px; }
  .mail-message-card > summary { grid-template-columns: 34px minmax(0, 1fr); }
  .mail-message-card > summary time { grid-column: 2; }
  .mail-attachments { grid-template-columns: 1fr; padding-inline: 9px; }
  .mail-notes form { grid-template-columns: 1fr; }
  .mail-onboarding { grid-template-columns: 1fr; gap: 8px; padding-bottom: 80px; }
  .mail-onboarding-copy { padding: 8px 4px; }
  .mail-onboarding-copy h2 { max-width: 14ch; font-size: 36px; }
  .mail-account-form { padding: 16px; }
  .mail-unavailable { grid-template-columns: 1fr; margin: 20px 0; }
  .mail-shortcut-list { grid-template-columns: 1fr; }
  .mail-preview-modal { width: 100vw; height: 100dvh; border-radius: 0; }
  .mail-preview-pdf { height: calc(100dvh - 80px); }
}

@media (prefers-reduced-motion: reduce) {
  .mail-shell,
  .mail-thread-row,
  .mail-html-frame,
  .mail-compose-window,
  .mail-nav-panel { animation: none; transition: none; }
  .mail-thread-list,
  .mail-message-scroll { scroll-behavior: auto; }
}
