/* ============================================================
   mailv2 Webmailer — Erscheinungsbild
   Setzt colors_and_type.css voraus: @font-face (Outfit / Inter)
   und die Farb-Tokens. Alle Klassen- und ID-Namen entsprechen dem
   Markup 1:1 — diese Datei ändert nur das Aussehen, nie die Struktur.
   ============================================================ */

:root {
  /* Markenfarbe von mailv2 */
  --mv:        #0d9488;   /* teal-600  — primary action        */
  --mv-700:    #0f766e;   /* hover / pressed                   */
  --mv-600:    #0d9488;
  --mv-500:    #14b8a6;
  --mv-400:    #2dd4bf;
  --mv-100:    #ccfbf1;
  --mv-50:     #f0fdfa;
  --mv-ink:    #0f5f57;   /* accent text on tint               */

  /* header (dark, refined) */
  --hd:        #14181f;
  --hd-2:      #1e2530;
  --hd-3:      #2a333f;
  --hd-line:   #0c0f14;
  --hd-txt:    #e8ecf1;
  --hd-txt-2:  #9aa6b4;

  /* semantic re-map to accent */
  --sent:      #0d9488;
  --sent-50:   #ecfdf5;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--bg);
  color: var(--ink);
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
a { color: var(--mv-700); text-decoration: none; }
a:hover { color: var(--mv); text-decoration: underline; }

.mockup-banner {
  position: fixed; top: 10px; right: 10px; z-index: 100;
  background: var(--warn-50); color: var(--warn);
  font-size: 11px; font-weight: 600;
  padding: 4px 11px; border-radius: 999px; border: 1px solid #fcd9a3;
  box-shadow: var(--shadow-sm);
  pointer-events: none; letter-spacing: .3px;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
  background: var(--hd);
  color: var(--hd-txt);
  padding: 0 18px; height: 58px;
  display: flex; align-items: center; gap: 14px;
  flex-shrink: 0; border-bottom: 1px solid var(--hd-line);
}
header h1 {
  font-family: var(--font-display);
  font-size: 18px; margin: 0; font-weight: 600; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 11px;
  letter-spacing: -.01em; color: #fff;
}
header .brand-mark { width: 48px; height: 30px; display: inline-block; flex-shrink: 0; }
header .brand-mark svg { display: block; width: 100%; height: 100%; }

.search { flex: 1; max-width: 460px; position: relative; }
.search input {
  width: 100%; padding: 9px 12px 9px 34px;
  background: var(--hd-2); color: var(--hd-txt);
  border: 1px solid var(--hd-3); border-radius: var(--r-md);
  font-size: 13px; transition: border-color .12s, background .12s;
}
.search input:focus { outline: none; border-color: var(--mv-500); background: var(--hd-3); }
.search::before {
  content: ''; position: absolute; left: 12px; top: 50%; width: 14px; height: 14px;
  transform: translateY(-50%);
  background: var(--hd-txt-2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") center/contain no-repeat;
}
.search input::placeholder { color: var(--hd-txt-2); }

.who {
  font-family: var(--font-body); font-size: 12.5px; color: var(--hd-txt-2);
  background: var(--hd-2); padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--hd-3); white-space: nowrap;
}

header button, header a#btn-admin {
  background: var(--hd-2); color: var(--hd-txt);
  border: 1px solid var(--hd-3);
  padding: 8px 15px; border-radius: var(--r-md); cursor: pointer;
  font-size: 13px; font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px; line-height: 1;
  transition: background .12s, border-color .12s, transform .06s;
}
header button:hover, header a#btn-admin:hover { background: var(--hd-3); border-color: #3a4553; }
header button:active { transform: translateY(1px); }
header button.primary {
  background: var(--mv); border-color: var(--mv);
  color: #fff; box-shadow: 0 1px 2px rgba(13,148,136,.4);
}
header button.primary:hover { background: var(--mv-700); border-color: var(--mv-700); }
header a#btn-admin { background: var(--warn); border-color: var(--warn); color: #fff; }
header a#btn-admin:hover { background: #92400e; border-color: #92400e; }

header .spacer { flex: 1; }
header #btn-settings {
  background: transparent; border: 0; border-radius: var(--r-md);
  width: 40px; height: 40px; padding: 0; margin: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--hd-txt-2); cursor: pointer; line-height: 1;
  transition: background .12s, color .12s;
}
header #btn-settings:hover { background: var(--hd-2); color: #fff; }

/* sidebar sub-heading + cost widget */
.side-subheading {
  padding: 8px 18px 3px; font-size: 10.5px; font-weight: 600;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em;
  margin-top: 4px;
}
.side-subheading:first-child { margin-top: 0; }
#cost-section .cost-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 18px; font-size: 12.5px; color: var(--ink-2);
  cursor: pointer; border-radius: var(--r-sm); margin: 0 8px;
}
#cost-section .cost-row:hover { background: var(--tint); color: var(--ink-strong); }
#cost-section .cost-value {
  font-family: var(--font-display); font-weight: 600; color: var(--ink-strong);
  font-feature-settings: "tnum" 1;
}

/* cost detail overlay */
.cost-detail-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45);
  z-index: 100; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.cost-detail-overlay.open { display: flex; }
.cost-detail-panel {
  background: #fff; border-radius: var(--r-lg); max-width: 800px; width: 90vw; max-height: 85vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-md);
}
.cost-detail-header {
  padding: 16px 22px; border-bottom: 1px solid var(--line-2); background: var(--tint);
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--ink-strong);
}
.cost-detail-header button { background: transparent; border: 0; font-size: 22px; cursor: pointer; color: var(--ink-3); }
.cost-detail-header button:hover { color: var(--ink-strong); }
.cost-detail-body { padding: 16px 22px; overflow-y: auto; flex: 1; font-size: 13px; }
.cost-detail-body table { width: 100%; border-collapse: collapse; }
.cost-detail-body th { text-align: left; font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.cost-detail-body td { padding: 8px 6px; border-bottom: 1px solid var(--line-2); }
.cost-detail-body td.num { font-family: var(--font-display); text-align: right; font-feature-settings: "tnum" 1; }

#compose-send-btn #compose-send-cost:not([hidden]) { margin-left: 6px; font-weight: 500; opacity: .9; }

/* ============================================================
   LAYOUT
   ============================================================ */
main { display: flex; flex: 1; min-height: 0; }

aside.sidebar {
  width: 244px; background: #fff; border-right: 1px solid var(--line);
  padding: 10px 0; overflow-y: auto; flex-shrink: 0;
  display: flex; flex-direction: column;
}
.side-section { padding: 8px 0 12px; border-bottom: 1px solid var(--line-2); }
.side-section:last-child { border-bottom: 0; }
.side-section h3 {
  font-size: 10.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase;
  padding: 6px 18px; margin: 0; letter-spacing: .08em;
  cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
}
.side-section h3:hover { color: var(--ink); }
.side-section h3::after {
  content: '▾'; font-size: 9px; margin-inline-start: 6px; color: var(--ink-3);
  transition: transform .2s ease; transform-origin: center;
}
.side-section.collapsed h3::after { transform: rotate(-90deg); }
.side-section .section-body { overflow: hidden; max-height: 5000px; transition: max-height .25s ease; }
.side-section.collapsed .section-body { max-height: 0; }
.side-section .add-link {
  padding: 8px 18px; font-size: 12.5px; color: var(--ink-3); cursor: pointer;
  font-weight: 500; transition: color .12s;
}
.side-section .add-link:hover { color: var(--mv-700); }

/* folder tree */
.folder-item {
  padding: 8px 16px 8px 10px; cursor: pointer; margin: 1px 8px;
  display: flex; align-items: center; gap: 8px;
  border-radius: var(--r-md); position: relative;
  font-size: 13.5px; font-weight: 500; color: var(--ink);
  user-select: none; transition: background .12s, color .12s;
}
.folder-item:hover { background: var(--tint); color: var(--ink-strong); }
.folder-item.active { background: var(--mv-50); color: var(--mv-700); font-weight: 600; }
.folder-item.active::before {
  content: ''; position: absolute; left: -4px; top: 8px; bottom: 8px;
  width: 3px; background: var(--mv); border-radius: 2px;
}
.folder-item.has-unread { font-weight: 600; color: var(--ink-strong); }
.folder-item.active.has-unread { color: var(--mv-700); }
.folder-item.drop-target { background: var(--mv-50); outline: 1.5px dashed var(--mv-500); outline-offset: -2px; }
.folder-item .chevron {
  width: 14px; text-align: center; font-size: 9px; color: var(--ink-3);
  transition: transform .12s ease; flex-shrink: 0; display: inline-block;
}
.folder-item .chevron.expanded { transform: rotate(90deg); }
.folder-item .chevron-spacer { width: 14px; flex-shrink: 0; }
.folder-item.subfolder { padding-left: 30px; }
.folder-item .icon { width: 18px; flex-shrink: 0; opacity: .85; font-size: 14px; }
.folder-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.folder-item .count {
  font-size: 11px; color: var(--ink-3); background: var(--line-2);
  padding: 1px 8px; border-radius: 999px; font-weight: 600; font-family: var(--font-display);
}
.folder-item.active .count { background: var(--mv-100); color: var(--mv-700); }

/* contacts */
.contact-item {
  padding: 7px 16px; cursor: pointer; margin: 1px 8px;
  display: flex; align-items: center; gap: 9px;
  border-radius: var(--r-md); position: relative;
  font-size: 13.5px; font-weight: 500; color: var(--ink);
  user-select: none; transition: background .12s, color .12s;
}
.contact-item:hover { background: var(--tint); color: var(--ink-strong); }
.contact-item.active { background: var(--mv-50); color: var(--mv-700); font-weight: 600; }
.contact-item.active::before {
  content: ''; position: absolute; left: -4px; top: 7px; bottom: 7px;
  width: 3px; background: var(--mv); border-radius: 2px;
}
.contact-item .icon { width: 22px; height: 22px; flex-shrink: 0; opacity: 1; text-align: center;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--line-2); border-radius: 50%; font-size: 12px; }
.contact-item.active .icon { background: var(--mv-100); }
.contact-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.contact-item .ctag {
  font-size: 10px; padding: 1px 7px; border-radius: 999px;
  flex-shrink: 0; font-weight: 600; line-height: 15px; text-transform: uppercase; letter-spacing: .03em;
}
.contact-item .ctag.pending  { background: var(--warn-50); color: var(--warn); }
.contact-item .ctag.unknown  { background: var(--line-2); color: var(--ink-3); }
.contact-item .ctag.disabled { background: var(--line-2); color: var(--ink-3); }
/* Der Absender fuehrt ein gewerbliches Konto. Steht nur in der Liste der persoenlichen
   Kontakte: dort ist es eine Auskunft, die man sonst nicht hat. In der gewerblichen Liste
   waere es keine — die Kontakte dort sind ohnehin ueber einen Business-Token entstanden. */
.contact-item .ctag.tier-business { background: var(--info-50); color: var(--info); }
.contact-item.pending_unknown .label { font-style: italic; color: var(--ink-3); }
.contact-item.disabled .label { color: var(--ink-3); text-decoration: line-through; }
.contact-item.disabled .icon  { opacity: .5; }

/* ============================================================
   MAIL LIST
   ============================================================ */
section.list {
  width: 380px; background: #fff; border-right: 1px solid var(--line);
  overflow-y: auto; flex-shrink: 0; display: flex; flex-direction: column;
}
.list-header {
  padding: 14px 18px 12px; border-bottom: 1px solid var(--line-2); background: #fff;
  font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--ink-strong);
  display: flex; justify-content: space-between; align-items: baseline; flex-shrink: 0;
  letter-spacing: -.01em;
}
.list-header .meta { font-size: 11.5px; color: var(--ink-3); font-weight: 500; font-family: var(--font-body); }

.list-filter-tabs {
  display: flex; gap: 6px; padding: 8px 14px 10px;
  border-bottom: 1px solid var(--line-2); background: #fff;
  overflow-x: auto; flex-shrink: 0;
}
.list-filter-tab {
  padding: 5px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 500; color: var(--ink-2); cursor: pointer; user-select: none;
  background: var(--tint); border: 1px solid transparent; white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.list-filter-tab:hover { color: var(--ink-strong); background: var(--line-2); }
.list-filter-tab.active { color: var(--mv-700); background: var(--mv-50); border-color: var(--mv-100); }

.list-quick-action { padding: 10px 14px; border-bottom: 1px solid var(--line-2); background: var(--tint); display: flex; gap: 8px; }
.list-quick-action button {
  flex: 1; padding: 8px 12px; border-radius: var(--r-md);
  cursor: pointer; font-size: 13px; font-weight: 600; background: #fff;
  transition: background .12s, border-color .12s;
}
.list-quick-action button.compose { border: 1px solid var(--mv); color: var(--mv-700); }
.list-quick-action button.compose:hover { background: var(--mv-50); }
.list-quick-action button.delete-folder { border: 1px solid var(--danger-50); color: var(--danger); }
.list-quick-action button.delete-folder:hover { background: var(--danger-50); border-color: var(--danger); }
.list-body { overflow-y: auto; flex: 1; }

/* Seitigkeit wie in einem Messenger: **gesendet rechts, empfangen links**. Bis zum
 * 20.08.2026 war es umgekehrt, was der eingeübten Leserichtung widersprach — man sucht das
 * Eigene rechts.
 *
 * Beide Kanten sind in der Grundregel durchsichtig angelegt. Ohne das würde eine Zeile beim
 * Wechsel der Richtung um drei Pixel springen: `box-sizing: border-box` hält zwar die Breite,
 * verschiebt aber den Textbereich. */
.mail-item {
  padding: 12px 16px 12px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer;
  border-left: 3px solid transparent; border-right: 3px solid transparent;
  transition: background .1s;
}
.mail-item:hover { background: var(--tint); }
.mail-item.selected { background: var(--mv-50); border-left-color: var(--mv); }
.mail-item.dragging { opacity: .4; }
.mail-item.direction-outgoing { border-left-color: transparent; border-right-color: var(--sent); }
.mail-item.direction-outgoing:hover { background: var(--sent-50); }
.mail-item.direction-outgoing.selected { background: var(--mv-50); border-left-color: transparent; border-right-color: var(--mv-700); }
.mail-item.direction-outgoing .name-line::before { content: '↗ '; color: var(--sent); font-weight: 600; }
.mail-item .line1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mail-item .line1-left { display: flex; gap: 5px; align-items: center; flex-shrink: 1; min-width: 0; }
.mail-item .line1-right { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.enc-badge {
  padding: 2px 5px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; user-select: none; line-height: 1; height: 20px;
  transition: filter .12s;
}
.enc-badge:hover { filter: brightness(.94); }
.enc-badge svg { display: block; }
.enc-badge.bbe { background: var(--mv-100); color: var(--mv-700); }
.enc-badge.bme { background: var(--info-50); color: var(--info); }
.enc-badge.tls_only { background: var(--warn-50); color: var(--warn); }

.att-badge {
  font-size: 10.5px; padding: 2px 7px; border-radius: 999px; font-weight: 600;
  background: #ede9fe; color: #5b21b6;
  display: inline-flex; align-items: center; gap: 3px; line-height: 15px; height: 20px;
}
.lifetime-badge {
  font-size: 10.5px; padding: 2px 8px; border-radius: 999px; font-weight: 600;
  background: var(--line-2); color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 4px; line-height: 15px; height: 20px;
}
.lifetime-badge svg { flex-shrink: 0; display: block; }

.delivery-icon { font-size: 12px; line-height: 16px; }
.delivery-icon.delivered { color: var(--success); }
.delivery-icon.pending { color: var(--warn); }

.datetime { font-size: 11px; color: var(--ink-3); font-feature-settings: "tnum" 1; display: flex; gap: 5px; align-items: baseline; white-space: nowrap; }
.datetime .date { color: var(--ink-3); }
.datetime .time { color: var(--ink-2); font-weight: 600; }

.mail-item .name-line {
  font-size: 13px; color: var(--ink-2); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 5px;
}
.mail-item .subject-line {
  font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px;
}
.mail-item.unread .subject-line { font-weight: 600; color: var(--ink-strong); }
.mail-item.unread .name-line { color: var(--ink); }

.list-empty { padding: 40px 30px; text-align: center; color: var(--ink-3); font-style: italic; font-size: 13px; }

/* encryption popover */
.enc-popover {
  position: fixed; z-index: 250; display: none; max-width: 320px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-md); padding: 14px 16px; font-size: 12.5px; line-height: 1.5; color: var(--ink);
}
.enc-popover.open { display: block; }
.enc-popover h4 { margin: 0 0 8px; font-family: var(--font-display); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.enc-popover .setup-link { display: inline-block; margin-top: 8px; color: var(--mv-700); cursor: pointer; text-decoration: underline; }
.enc-popover .setup-link:hover { color: var(--mv); }
.enc-popover.bbe-tone h4 { color: var(--mv-700); }
.enc-popover.bme-tone h4 { color: var(--info); }
.enc-popover.tls_only-tone h4 { color: var(--warn); }

/* ============================================================
   DETAIL PANE
   ============================================================ */
section.detail { flex: 1; background: var(--bg); overflow-y: auto; padding: 0; }
.detail-empty { text-align: center; color: var(--ink-3); font-style: italic; padding: 90px 0; }
.detail-meta { padding: 24px 32px 20px; border-bottom: 1px solid var(--line); background: #fff; }
.detail-meta h2 { margin: 0 0 12px; font-family: var(--font-display); font-size: 21px; color: var(--ink-strong); letter-spacing: -.01em; font-weight: 600; }
.detail-meta .meta-row {
  color: var(--ink-3); font-size: 12.5px; line-height: 1.7;
  display: grid; grid-template-columns: 118px 1fr; column-gap: 14px; row-gap: 3px; align-items: baseline;
}
.meta-row .meta-key { color: var(--ink-3); text-transform: uppercase; font-size: 10.5px; letter-spacing: .06em; font-weight: 600; }
.meta-row .meta-val { color: var(--ink); word-break: break-word; }
.detail-body {
  padding: 28px 32px; white-space: pre-wrap; font-size: 14.5px; line-height: 1.7; color: var(--ink);
  background: #fff; margin: 0;
}

.lifetime-box {
  margin: 20px 32px 0;
  background: var(--warn-50); border: 1px solid #fcd9a3; border-radius: var(--r-md);
  padding: 12px 16px; display: flex; align-items: center; gap: 14px; font-size: 12.5px;
}
.lifetime-box .icon-wrap { color: var(--warn); flex-shrink: 0; }
.lifetime-box .info { flex: 1; color: var(--warn); line-height: 1.5; }
.lifetime-box .info b { color: #92400e; font-weight: 600; }
.lifetime-box button {
  background: #fff; border: 1px solid var(--warn); color: var(--warn);
  padding: 6px 14px; border-radius: var(--r-sm); cursor: pointer; font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.lifetime-box button:hover { background: var(--warn-50); }

.detail-actions {
  padding: 16px 32px; border-top: 1px solid var(--line); background: #fff;
  display: flex; gap: 10px; flex-wrap: wrap;
}
.detail-actions button {
  background: #fff; border: 1px solid var(--line); padding: 9px 16px; border-radius: var(--r-md);
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px; transition: background .12s, border-color .12s, transform .06s;
}
.detail-actions button:hover { background: var(--tint); border-color: #d6d9de; }
.detail-actions button:active { transform: translateY(1px); }
.detail-actions button.primary { background: var(--mv); color: #fff; border-color: var(--mv); }
.detail-actions button.primary:hover { background: var(--mv-700); border-color: var(--mv-700); }
.detail-actions button.danger { color: var(--danger); border-color: var(--danger-50); }
.detail-actions button.danger:hover { background: var(--danger-50); border-color: var(--danger); }

/* contact-detail pane */
.contact-pane { padding: 48px 32px; text-align: center; }
.contact-pane .avatar {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--mv-100); color: var(--mv-700);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 32px; font-weight: 600; margin: 0 auto 18px;
}
.contact-pane .avatar.unknown { background: var(--line-2); color: var(--ink-3); }
.contact-pane .avatar.pending { background: var(--warn-50); color: var(--warn); }
.contact-pane .avatar.disabled { background: var(--line-2); color: var(--ink-3); filter: grayscale(1); }
.contact-pane h2 { margin: 0 0 6px; font-family: var(--font-display); font-size: 22px; color: var(--ink-strong); }
.contact-pane h2.unknown { color: var(--ink-3); font-style: italic; font-weight: 500; }
.contact-pane .addr { color: var(--ink-3); font-family: var(--font-body); font-size: 13px; margin-bottom: 26px; }
.contact-pane .info-box {
  background: var(--warn-50); border: 1px solid #fcd9a3; color: var(--warn);
  padding: 14px 18px; margin: 18px auto; max-width: 420px; font-size: 13px; line-height: 1.5;
  border-radius: var(--r-md); text-align: left;
}
.contact-pane .info-box.disabled-info { background: var(--tint); border-color: var(--line); color: var(--ink-2); }
.contact-pane .stats {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 22px; margin: 18px auto; max-width: 360px; box-shadow: var(--shadow-sm);
  font-size: 13px; color: var(--ink-2); text-align: left; line-height: 2;
}
.contact-pane .stats b { color: var(--ink-strong); font-weight: 600; font-family: var(--font-display); }
.contact-pane .actions { margin-top: 14px; }
.contact-pane button { padding: 9px 20px; border-radius: var(--r-md); cursor: pointer; font-size: 14px; font-weight: 600; margin: 4px; }
.contact-pane button.primary { background: var(--mv); color: #fff; border: 1px solid var(--mv); }
.contact-pane button.primary:hover { background: var(--mv-700); }
.contact-pane button.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.contact-pane button.secondary:hover { background: var(--tint); }
.contact-pane button.danger { background: #fff; color: var(--danger); border: 1px solid var(--danger-50); }
.contact-pane button.danger:hover { background: var(--danger-50); }

/* attachments */
.attachments { margin: 20px 32px 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: #fff; overflow: hidden; box-shadow: var(--shadow-sm); }
.attachments-header { padding: 12px 16px; border-bottom: 1px solid var(--line-2); font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--tint); text-transform: uppercase; letter-spacing: .05em; }
.attachment { padding: 12px 16px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 14px; }
.attachment:last-child { border-bottom: 0; }
.attachment .ico { font-size: 22px; opacity: .8; flex-shrink: 0; width: 40px; height: 40px; border-radius: var(--r-md); background: var(--tint); display: flex; align-items: center; justify-content: center; }
.attachment .info { flex: 1; min-width: 0; }
.attachment .name { font-size: 13.5px; font-weight: 600; color: var(--ink-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.status-badge { font-size: 10px; padding: 2px 8px; border-radius: 999px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.status-badge.ready { background: var(--success-50); color: var(--success); }
.status-badge.pool { background: var(--info-50); color: var(--info); }
.status-badge.fetching { background: var(--warn-50); color: var(--warn); }
.status-badge.failed { background: var(--danger-50); color: var(--danger); }
.attachment .actions { display: flex; gap: 6px; flex-shrink: 0; }
.attachment .actions button { background: #fff; border: 1px solid var(--line); padding: 5px 11px; border-radius: var(--r-sm); cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink); }
.attachment .actions button:hover { background: var(--tint); }
.attachment .actions button:disabled { opacity: .4; cursor: default; }
.receipt-line { margin-top: 5px; font-size: 11px; color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.receipt-line .dot { width: 6px; height: 6px; border-radius: 50%; }
.dot.ok { background: var(--success); }
.dot.wait { background: var(--warn); }
.dot.miss { background: var(--ink-3); }

/* ============================================================
   DIALOGS
   ============================================================ */
dialog { border: 0; border-radius: var(--r-lg); padding: 0; box-shadow: var(--shadow-md); max-width: 600px; width: 90%; color: var(--ink); }
dialog::backdrop { background: rgba(15,23,42,.45); backdrop-filter: blur(2px); }
dialog .dialog-header {
  padding: 18px 22px; border-bottom: 1px solid var(--line-2); font-family: var(--font-display);
  font-weight: 600; font-size: 16px; color: var(--ink-strong);
  display: flex; justify-content: space-between; align-items: center;
}
dialog .dialog-header .close { background: transparent; border: 0; color: var(--ink-3); font-size: 20px; cursor: pointer; padding: 0 4px; }
dialog .dialog-header .close:hover { color: var(--ink-strong); }
dialog .dialog-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
[hidden] { display: none !important; }
dialog label { font-size: 10.5px; font-weight: 600; color: var(--ink-3); display: block; text-transform: uppercase; letter-spacing: .06em; }
dialog input, dialog textarea, dialog select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 13px; font-family: inherit; background: #fff; color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
dialog textarea { resize: vertical; min-height: 150px; line-height: 1.6; }
dialog input:focus, dialog textarea:focus, dialog select:focus { outline: none; border-color: var(--mv-500); box-shadow: 0 0 0 3px var(--mv-50); }
.hint { font-size: 11.5px; color: var(--ink-3); margin-top: -2px; line-height: 1.5; }

.bt-share-heading { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin: 14px 0 6px; font-weight: 600; }
.bt-share-list { display: flex; flex-direction: column; gap: 2px; }
.bt-share-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; font-weight: 400; color: inherit; text-transform: none; letter-spacing: normal; cursor: pointer; }
.bt-share-row input[type="checkbox"] { margin: 0; flex-shrink: 0; width: 16px; height: 16px; padding: 0; accent-color: var(--mv); appearance: auto; }
.bt-share-row .bt-share-name { width: 160px; flex-shrink: 0; font-weight: 600; }
.bt-share-row .bt-share-hint { font-size: 11px; color: var(--ink-3); flex: 1 1 auto; }
.bt-share-row .bt-share-link { margin-left: auto; font-size: 11px; cursor: pointer; color: var(--mv-700); text-decoration: underline; flex-shrink: 0; }
.bt-share-row.is-disabled { color: var(--ink-3); cursor: default; }
.bt-share-row.is-disabled .bt-share-name { font-weight: 400; }

.dropzone { border: 1.5px dashed var(--line); border-radius: var(--r-md); padding: 18px; text-align: center; color: var(--ink-3); font-size: 12px; transition: border-color .12s, background .12s; }
.dropzone:hover { border-color: var(--mv-400); background: var(--mv-50); }
.dropzone.has-items { border-style: solid; text-align: left; padding: 8px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--tint); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 5px 9px; font-size: 12px; margin: 2px; }
.attachment-chip .remove { cursor: pointer; color: var(--ink-3); margin-left: 4px; }
.attachment-chip .remove:hover { color: var(--danger); }

dialog .dialog-actions { padding: 14px 22px; background: var(--tint); border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; }
dialog button { background: #fff; border: 1px solid var(--line); padding: 8px 16px; border-radius: var(--r-md); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink); transition: background .12s, border-color .12s; }
dialog button.primary { background: var(--mv); color: #fff; border-color: var(--mv); }
dialog button.primary:hover { background: var(--mv-700); border-color: var(--mv-700); }
dialog button.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
dialog button.danger:hover { background: var(--danger-700); border-color: var(--danger-700); }
dialog button:not(.primary):not(.danger):hover { background: var(--tint); border-color: #d6d9de; }

.enc-state-box { padding: 14px; border-radius: var(--r-md); margin-bottom: 12px; font-size: 13px; line-height: 1.5; }
.enc-state-box.active { background: var(--mv-50); color: var(--mv-700); }
.enc-state-box.inactive { background: var(--warn-50); color: var(--warn); }

/* QR card */
.qr-card { display: flex; gap: 22px; align-items: stretch; }
.qr-svg-wrap { background: #fff; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md); flex-shrink: 0; line-height: 0; box-shadow: var(--shadow-sm); }
.qr-svg-wrap svg { display: block; }
.qr-info { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.qr-info .token-row { display: flex; gap: 6px; align-items: stretch; background: var(--tint); border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 10px; }
.qr-info .token-row code { flex: 1; font-family: ui-monospace, monospace; font-size: 11px; color: var(--ink); word-break: break-all; line-height: 1.4; }
.qr-info .token-row button { flex-shrink: 0; font-size: 11px; padding: 3px 9px; }
.qr-info .explainer { font-size: 12px; line-height: 1.5; color: var(--ink-3); }

/* settings + invite tabs */
.settings-tabs, .invite-tabs { display: flex; padding: 0 22px; border-bottom: 1px solid var(--line); gap: 4px; }
.settings-tab, .invite-tab {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  padding: 12px 14px; font-size: 13px; font-weight: 600; color: var(--ink-3); cursor: pointer; transition: color .12s;
}
.settings-tab:hover, .invite-tab:hover { color: var(--ink-strong); }
.settings-tab.is-active, .invite-tab.is-active { color: var(--mv-700); border-bottom-color: var(--mv); }

#settings-devices-list .device-row { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 8px; }
#settings-devices-list .device-row.is-current { border-color: var(--mv); background: var(--mv-50); }
#settings-devices-list .device-row .row-top { display: flex; align-items: center; gap: 8px; }
#settings-devices-list .device-row .name { flex: 1; font-weight: 600; font-size: 14px; color: var(--ink-strong); }
#settings-devices-list .device-row .meta { font-size: 11px; color: var(--ink-3); margin-top: 5px; }
#settings-devices-list .device-row .badge-self { background: var(--mv); color: #fff; font-size: 10px; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
#settings-devices-list .device-row button { font-size: 11px; padding: 4px 10px; }
#settings-devices-list .device-row.is-edit input { flex: 1; padding: 5px 9px; font-size: 13px; border: 1px solid var(--line); border-radius: var(--r-sm); }

#settings-fallback-list .fallback-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
#settings-fallback-list .fallback-row:last-child { border-bottom: 0; }
#settings-fallback-list .fallback-row .addr { flex: 1; font-family: ui-monospace, monospace; font-size: 12px; }
#settings-fallback-list .fallback-row .kind { font-size: 10px; padding: 2px 6px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; background: var(--line-2); color: var(--ink-2); }
#settings-fallback-list .fallback-row .kind.dmail { background: var(--mv-100); color: var(--mv-700); }
#settings-fallback-list .fallback-row button { font-size: 11px; padding: 4px 10px; }
#settings-recovery-regen-result .password-display { background: var(--warn-50); border: 1px solid var(--warn); border-radius: var(--r-md); padding: 12px; font-family: ui-monospace, monospace; font-size: 13px; font-weight: 600; text-align: center; color: var(--warn); user-select: all; }
.empty-hint { color: var(--ink-3); font-style: italic; font-size: 12px; padding: 8px 0; }

#invite-redeem-result { margin-top: 14px; }
#invite-redeem-result .preview-box { background: var(--tint); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; display: flex; flex-direction: column; gap: 4px; }
#invite-redeem-result .preview-box .who { font-family: var(--font-display); font-weight: 600; color: var(--ink-strong); font-size: 14px; background: none; border: 0; padding: 0; }
#invite-redeem-result .preview-box .addr { font-family: ui-monospace, monospace; font-size: 12px; color: var(--ink-3); }
#invite-redeem-result .preview-box .expires { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
#invite-redeem-result .accept-row { margin-top: 10px; display: flex; gap: 8px; }
#invite-redeem-result .err-box { background: var(--danger-50); border: 1px solid #fecaca; border-radius: var(--r-md); padding: 12px 14px; color: var(--danger-700); font-size: 12px; }

/* custom combobox */
.m-select { position: relative; }
.m-select-trigger { width: 100%; padding: 9px 11px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); font-size: 13px; cursor: pointer; text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 8px; transition: border-color .12s; }
.m-select-trigger:hover { border-color: #cbd0d6; }
.m-select-trigger.open { border-color: var(--mv-500); box-shadow: 0 0 0 3px var(--mv-50); }
.m-select-value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.m-select-value.empty { color: var(--ink-3); }
.m-select-caret { color: var(--ink-3); font-size: 10px; flex-shrink: 0; }
.m-select-dropdown { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 350; background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-md); max-height: 280px; display: flex; flex-direction: column; overflow: hidden; }
.m-select-dropdown[hidden] { display: none; }
.m-select-search { margin: 8px; width: calc(100% - 16px); }
.m-select-options { flex: 1; overflow-y: auto; }
.m-select-heading { padding: 6px 12px; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; background: var(--tint); border-top: 1px solid var(--line-2); }
.m-select-heading:first-child { border-top: 0; }
.m-select-option { padding: 9px 12px; cursor: pointer; border-top: 1px solid var(--line-2); }
.m-select-option:hover, .m-select-option.highlight { background: var(--mv-50); }
.m-select-option.is-pending { background: var(--warn-50); }
.m-select-option.is-pending:hover, .m-select-option.is-pending.highlight { background: #fde9c3; }
.m-select-option .opt-label { font-size: 13px; color: var(--ink); font-weight: 600; }
.m-select-option .opt-addr { font-size: 11px; color: var(--ink-3); font-family: ui-monospace, monospace; }
.m-select-option .opt-tag { font-size: 10px; color: var(--warn); margin-top: 2px; }
.m-select-empty { padding: 14px; text-align: center; color: var(--ink-3); font-size: 12px; font-style: italic; }

/* draft editor */
.draft-editor h2 { font-family: var(--font-display); }
.draft-editor textarea, .draft-editor input { border: 1px solid var(--line); border-radius: var(--r-md); }
.draft-editor textarea:focus, .draft-editor input:focus { outline: none; border-color: var(--mv-500); box-shadow: 0 0 0 3px var(--mv-50); }

/* viewer overlay */
.viewer { position: fixed; inset: 0; background: rgba(15,23,42,.85); display: none; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(3px); }
.viewer.open { display: flex; flex-direction: column; padding: 24px; }
.viewer-toolbar { display: flex; align-items: center; gap: 12px; color: #fff; background: rgba(0,0,0,.4); padding: 10px 18px; border-radius: var(--r-md); margin-bottom: 12px; max-width: 90vw; width: 700px; }
.viewer-toolbar .v-name { flex: 1; font-family: ui-monospace, monospace; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-toolbar button { padding: 6px 12px; border-radius: var(--r-sm); cursor: pointer; background: #fff; border: 0; font-size: 12px; font-weight: 600; }
.viewer-frame { flex: 1; width: min(90vw, 1100px); background: #fff; border-radius: var(--r-lg); overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,.4); max-height: 80vh; }
.viewer-frame iframe { width: 100%; height: 100%; border: 0; }
.viewer-frame img { max-width: 100%; max-height: 100%; display: block; margin: auto; }
.viewer-frame .fallback { padding: 60px 40px; text-align: center; color: var(--ink-3); font-style: italic; }

/* settings rows */
.settings-row { padding: 4px 0; }
.settings-row label { display: block; margin-bottom: 5px; font-weight: 600; color: var(--ink); }
.settings-row select { width: 100%; padding: 9px 11px; font-size: 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; }

/* ============================================================
   RESPONSIVE (unchanged behaviour, refreshed values)
   ============================================================ */
.burger { display: none; background: var(--hd-2); color: var(--hd-txt); border: 1px solid var(--hd-3); padding: 8px 11px; border-radius: var(--r-md); font-size: 18px; cursor: pointer; line-height: 1; }
.burger:focus-visible { outline: 2px solid var(--mv-500); outline-offset: 2px; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; touch-action: none; }
.sidebar-backdrop.open { display: block; }
.detail-back-row { display: none; }

@media (max-width: 1023px) {
  header { padding: 0 12px; gap: 8px; }
  header h1 { font-size: 16px; }
  .search { max-width: none; }
  header button { min-height: 44px; }
  .who { display: none; }
  .burger { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
  aside.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 288px; max-width: 85vw; z-index: 95; transform: translateX(-100%); transition: transform .22s ease-out; box-shadow: 0 4px 20px rgba(0,0,0,.2); padding-top: env(safe-area-inset-top,0); padding-bottom: env(safe-area-inset-bottom,0); }
  aside.sidebar.open { transform: translateX(0); }
  .folder-item, .contact-item { padding: 11px 16px; min-height: 44px; font-size: 14px; }
  .side-section .add-link { padding: 12px 18px; min-height: 44px; display: flex; align-items: center; }
  section.list { width: auto; flex: 1; }
  .mail-item { padding: 14px; min-height: 66px; }
  section.detail { flex: 1; min-width: 0; }
}
@media (max-width: 639px) {
  main { position: relative; }
  section.list { display: flex; }
  section.detail { position: absolute; inset: 0; z-index: 50; background: var(--bg); transform: translateX(100%); transition: transform .22s ease-out; padding-top: env(safe-area-inset-top,0); padding-bottom: env(safe-area-inset-bottom,0); }
  section.detail.open { transform: translateX(0); }
  .detail-back-row { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
  .detail-back-row button { background: transparent; border: 0; padding: 8px 10px; font-size: 14px; font-weight: 600; color: var(--mv-700); cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; gap: 4px; }
  section.detail:not(.open) .detail-empty { display: none; }
  dialog#compose-dialog, dialog#settings-dialog, dialog#folder-dialog, dialog#delete-folder-dialog, dialog#invite-dialog, dialog#encryption-dialog, dialog#address-dialog, dialog#business-token-dialog { max-width: 100vw; max-height: 100dvh; width: 100vw; height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  #btn-add-device { display: none; }
}
@media (hover: none) and (pointer: coarse) {
  button, [role="button"], a.btn, .btn, .folder-item, .contact-item, .mail-item, .attachment-card, .opt-card, .method-card, .dialog-actions button { min-height: 44px; }
  select, input[type="text"], input[type="password"], textarea { min-height: 44px; font-size: 16px; }
}
@supports (padding: env(safe-area-inset-top)) {
  body { padding-left: env(safe-area-inset-left,0); padding-right: env(safe-area-inset-right,0); }
}
