:root {
  color-scheme: light;
  --bg: #eee9e1;
  --surface: #fbf9f5;
  --surface-2: #f5f1ea;
  --surface-3: #ebe5db;
  --ink: #211f1c;
  --muted: #77716a;
  --line: #ddd6cc;
  --line-strong: #cbc1b5;
  --accent: #c9656f;
  --accent-deep: #9e3f4a;
  --accent-soft: #f5dde0;
  --violet: #6d5bd0;
  --violet-soft: #e9e4ff;
  --mint: #258f79;
  --mint-soft: #dcf2ec;
  --amber: #a87317;
  --amber-soft: #f7e9c9;
  --danger: #b53a45;
  --shadow: 0 18px 48px rgba(50, 38, 24, .12);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(109, 91, 208, .22);
  outline-offset: 2px;
}

.candidate-banner {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #24211e;
  color: #f8f3ec;
  font-size: 11px;
  letter-spacing: .04em;
}

.candidate-banner span {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .12em;
}

.candidate-banner strong { font-weight: 560; opacity: .84; }

.topbar {
  height: 70px;
  display: grid;
  grid-template-columns: 250px minmax(320px, 720px) 1fr;
  align-items: center;
  gap: 22px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 249, 245, .93);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-size: 19px;
  letter-spacing: -.03em;
}

.brand img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 13px;
  border: 1px solid rgba(201, 101, 111, .35);
  box-shadow: 0 5px 14px rgba(92, 53, 50, .14);
}

.brand b { font-weight: 850; }

.global-search {
  height: 42px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--muted);
  transition: .2s ease;
}

.global-search:focus-within {
  border-color: rgba(109, 91, 208, .45);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(109, 91, 208, .08);
}

.global-search > span { font-size: 21px; line-height: 1; }
.global-search input { border: 0; outline: 0; background: transparent; color: var(--ink); min-width: 0; }
.global-search input::placeholder { color: #9b958e; }
.global-search kbd {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font: 10px ui-monospace, monospace;
  color: #918981;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.icon-button,
.avatar {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 17px;
}

.icon-button:hover { background: var(--surface-3); }
.recovery-trigger { color: var(--accent-deep); }
.avatar { border: 0; background: #28231f; color: #fff; font-weight: 800; }

.workspace-switcher {
  display: grid;
  gap: 2px;
  min-width: 122px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.workspace-switcher span {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .1em;
  color: var(--muted);
  text-transform: uppercase;
}

.workspace-switcher select { border: 0; outline: 0; background: transparent; font-size: 12px; font-weight: 760; }

.app-shell {
  height: calc(100vh - 98px);
  display: grid;
  grid-template-columns: 238px minmax(410px, 600px) minmax(420px, 1fr);
  gap: 1px;
  background: var(--line);
}

.sidebar,
.mail-column,
.reading-pane { background: var(--surface); min-width: 0; }

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  overflow: auto;
}

.compose-button {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 780;
  box-shadow: 0 10px 24px rgba(33, 31, 28, .15);
}

.compose-button span { color: #f0a9b0; font-size: 20px; }
.compose-button:hover { transform: translateY(-1px); background: #151412; }

.folder-nav { display: grid; gap: 3px; margin-top: 22px; }
.folder-nav button,
.label-section > button {
  width: 100%;
  height: 38px;
  display: grid;
  grid-template-columns: 25px 1fr auto;
  align-items: center;
  gap: 3px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #5f5952;
  text-align: left;
  font-size: 13px;
  font-weight: 630;
}

.folder-nav button:hover,
.label-section > button:hover { background: var(--surface-2); }

.folder-nav button.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 800;
}

.folder-nav button > span { text-align: center; font-size: 15px; }
.folder-nav button b { font-size: 11px; }

.label-section { margin-top: 24px; }
.aside-title {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.aside-title button { border: 0; background: transparent; color: var(--muted); font-size: 15px; }
.label-dot { width: 8px; height: 8px; border-radius: 50%; justify-self: center; }
.label-dot.coral { background: var(--accent); }
.label-dot.violet { background: var(--violet); }
.label-dot.amber { background: #d39a32; }
.label-dot.mint { background: var(--mint); }

.sidebar-footer { margin-top: auto; padding: 18px 10px 2px; border-top: 1px solid var(--line); }
.storage-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.storage-row b { color: var(--ink); }
.storage-meter { height: 5px; margin: 8px 0 10px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.storage-meter i { display: block; width: 8%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--violet)); }
.sidebar-footer small { display: block; color: #918a83; font-size: 9px; line-height: 1.5; }

.mail-column { display: flex; flex-direction: column; overflow: hidden; }
.mail-header { height: 82px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 4px; color: var(--accent-deep); font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.mail-header h1, .dialog-head h2, .side-dialog-head h2 { margin: 0; font-size: 23px; letter-spacing: -.04em; }

.view-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.view-switch button { min-width: 53px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; }
.view-switch button.active { background: #fff; color: var(--ink); box-shadow: 0 3px 9px rgba(40, 35, 30, .08); }

.mail-toolbar { height: 48px; display: flex; align-items: center; gap: 3px; padding: 0 13px; border-bottom: 1px solid var(--line); }
.mail-toolbar > button { height: 31px; min-width: 31px; padding: 0 9px; border: 0; border-radius: 8px; background: transparent; color: #6f6861; font-size: 12px; }
.mail-toolbar > button:hover { background: var(--surface-2); }
.mail-toolbar .push-right { margin-left: auto; }
.toolbar-divider { width: 1px; height: 19px; margin: 0 5px; background: var(--line); }
.select-all { width: 30px; display: flex; justify-content: center; }
.select-all input, .mail-check input { position: absolute; opacity: 0; pointer-events: none; }
.select-all span, .mail-check span { width: 15px; height: 15px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; }
.select-all input:checked + span, .mail-check input:checked + span { border-color: var(--violet); background: var(--violet); box-shadow: inset 0 0 0 3px #fff; }
.filter-select { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.filter-select select { border: 0; background: transparent; color: var(--ink); font-size: 11px; font-weight: 700; }

.mail-list { flex: 1; overflow: auto; background: #faf8f4; }
.mail-row {
  min-height: 86px;
  display: grid;
  grid-template-columns: 25px 39px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 16px 10px 12px;
  border-bottom: 1px solid #e6e0d7;
  background: rgba(255, 255, 255, .42);
  cursor: pointer;
  transition: .16s ease;
}

.mail-row:hover { background: #fff; }
.mail-row.selected { background: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.mail-row.unread .mail-sender, .mail-row.unread .mail-subject { font-weight: 850; }
.mail-row.unread::after { content: ""; position: absolute; }
.mail-check { display: flex; justify-content: center; }
.sender-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--surface-3);
  color: #6a625a;
  font-weight: 850;
  text-transform: uppercase;
}

.sender-avatar.coral { background: var(--accent-soft); color: var(--accent-deep); }
.sender-avatar.violet { background: var(--violet-soft); color: #5040ab; }
.sender-avatar.mint { background: var(--mint-soft); color: #1a7462; }
.sender-avatar.amber { background: var(--amber-soft); color: #875a0b; }
.mail-copy { min-width: 0; }
.mail-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
.mail-sender { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.secure-mini { flex: 0 0 auto; padding: 2px 5px; border-radius: 999px; background: var(--mint-soft); color: #1c7664; font-size: 8px; font-weight: 850; }
.mail-subject { margin: 5px 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #413d38; }
.mail-preview { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8b847c; font-size: 10px; }
.mail-meta { align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; padding: 3px 0; }
.mail-time { color: #8f8880; font-size: 9px; }
.mail-markers { display: flex; gap: 5px; color: #9a928a; font-size: 12px; }
.mail-markers .starred { color: #cf901a; }
.empty-list { padding: 50px 24px; text-align: center; color: var(--muted); }
.empty-list b { display: block; margin-bottom: 7px; color: var(--ink); }

.reading-pane { position: relative; overflow: auto; background: #fff; }
.empty-reader { min-height: 100%; display: grid; place-content: center; justify-items: center; padding: 60px; text-align: center; color: var(--muted); }
.empty-reader > span { width: 70px; height: 70px; display: grid; place-items: center; border-radius: 24px; background: var(--surface-2); color: var(--accent); font-size: 28px; }
.empty-reader h2 { margin: 20px 0 7px; color: var(--ink); font-size: 20px; letter-spacing: -.03em; }
.empty-reader p { max-width: 420px; margin: 0; font-size: 12px; line-height: 1.65; }

.reader-toolbar { position: sticky; top: 0; z-index: 2; height: 54px; display: flex; align-items: center; gap: 5px; padding: 0 20px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .92); backdrop-filter: blur(14px); }
.reader-toolbar button { height: 31px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.reader-toolbar button:hover { background: var(--surface-2); color: var(--ink); }
.reader-toolbar .reader-back { display: none; }
.reader-toolbar .reader-more { margin-left: auto; }
.reader-content { max-width: 880px; margin: 0 auto; padding: 34px 42px 70px; }
.reader-subject-row { display: flex; gap: 12px; align-items: flex-start; }
.reader-subject-row h2 { flex: 1; margin: 0; font-size: clamp(23px, 2.2vw, 34px); line-height: 1.12; letter-spacing: -.045em; }
.encryption-badge { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; background: var(--mint-soft); color: #176b59; font-size: 9px; font-weight: 850; }
.reader-sender { display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; margin: 28px 0; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.reader-sender .sender-avatar { width: 42px; height: 42px; }
.reader-sender strong { display: block; font-size: 13px; }
.reader-sender small { color: var(--muted); font-size: 10px; }
.reader-sender time { color: var(--muted); font-size: 10px; }
.reader-body { color: #393530; font-size: 14px; line-height: 1.78; white-space: pre-wrap; }
.attachment-card { display: flex; align-items: center; gap: 11px; width: min(360px, 100%); margin-top: 28px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.attachment-card i { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: #fff; color: var(--accent); font-style: normal; }
.attachment-card span { flex: 1; min-width: 0; }
.attachment-card b, .attachment-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-card b { font-size: 11px; }
.attachment-card small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.attachment-card button { border: 0; background: transparent; color: var(--muted); }
.reply-box { margin-top: 38px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; }
.reply-box textarea { width: 100%; min-height: 75px; resize: vertical; border: 0; outline: 0; background: transparent; color: var(--ink); }
.reply-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.reply-actions span { color: var(--muted); font-size: 9px; }

.primary, .secondary { min-height: 38px; padding: 0 15px; border-radius: 10px; font-weight: 760; }
.primary { border: 0; background: var(--ink); color: #fff; }
.primary:hover { background: #0e0d0c; }
.secondary { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.secondary:hover { background: var(--surface-2); }

.flow-board { flex: 1; overflow: auto; padding: 16px; background: #f6f2ec; }
.flow-note { display: flex; align-items: baseline; gap: 8px; margin: 0 3px 14px; }
.flow-note b { font-size: 11px; }
.flow-note span { color: var(--muted); font-size: 9px; }
.flow-columns { min-width: 760px; display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 10px; }
.flow-column { min-height: calc(100vh - 250px); padding: 10px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255, 255, 255, .58); }
.flow-column.drag-over { border-color: var(--violet); background: var(--violet-soft); }
.flow-column-head { display: flex; justify-content: space-between; align-items: center; padding: 3px 3px 10px; }
.flow-column-head b { font-size: 10px; }
.flow-column-head span { min-width: 21px; height: 21px; display: grid; place-items: center; border-radius: 999px; background: var(--surface-3); font-size: 9px; }
.flow-card { margin-bottom: 8px; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 5px 14px rgba(49, 38, 27, .05); cursor: grab; }
.flow-card:active { cursor: grabbing; }
.flow-card strong { display: block; margin-bottom: 5px; font-size: 10px; }
.flow-card p { margin: 0 0 9px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.flow-card footer { display: flex; justify-content: space-between; color: #968e86; font-size: 8px; }

dialog { color: var(--ink); }
dialog::backdrop { background: rgba(31, 27, 23, .28); backdrop-filter: blur(2px); }
.compose-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  margin: auto;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .52);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(34, 26, 18, .26);
  overflow: hidden;
}

.compose-dialog form { display: flex; flex-direction: column; min-height: min(720px, calc(100vh - 44px)); }
.dialog-head { min-height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.dialog-actions { display: flex; gap: 5px; }
.dialog-actions button, .side-dialog-head > button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 19px; }
.dialog-actions button:hover, .side-dialog-head > button:hover { background: var(--surface-3); color: var(--ink); }
.field-row { min-height: 47px; display: grid; grid-template-columns: 65px 1fr auto; align-items: center; gap: 8px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.field-row label { color: var(--muted); font-size: 10px; font-weight: 700; }
.field-row input, .field-row select { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.field-row button { border: 0; background: transparent; color: var(--muted); font-size: 10px; }
.cc-fields { border-bottom: 1px solid var(--line); }
.cc-fields .field-row:last-child { border-bottom: 0; }
.subject-row input { font-weight: 760; }
.compose-body { flex: 1; min-height: 190px; padding: 22px; border: 0; outline: 0; resize: vertical; color: var(--ink); line-height: 1.65; }
.delivery-panel { display: grid; grid-template-columns: 1fr 220px; gap: 15px; align-items: center; margin: 0 18px 14px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.delivery-switch { display: flex; gap: 5px; }
.delivery-switch label input { position: absolute; opacity: 0; }
.delivery-switch label span { display: block; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 9px; font-weight: 720; }
.delivery-switch label input:checked + span { border-color: var(--ink); background: var(--ink); color: #fff; }
.delivery-status { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: center; padding: 9px; border-radius: 10px; background: #fff; }
.delivery-status i { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: var(--mint-soft); color: var(--mint); font-style: normal; font-weight: 900; }
.delivery-status.protected i { background: var(--amber-soft); color: var(--amber); }
.delivery-status.e2ee i { background: var(--violet-soft); color: var(--violet); }
.delivery-status b, .delivery-status small { display: block; }
.delivery-status b { font-size: 9px; }
.delivery-status small { margin-top: 2px; color: var(--muted); font-size: 8px; line-height: 1.35; }
.compose-footer { min-height: 64px; display: flex; align-items: center; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--line); }
.format-actions { display: flex; gap: 3px; }
.format-actions button { min-width: 31px; height: 31px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.format-actions button:hover { background: var(--surface-2); }
#draftState { margin-left: auto; color: var(--muted); font-size: 9px; }

.side-dialog {
  width: min(460px, calc(100vw - 24px));
  height: calc(100vh - 40px);
  max-height: 840px;
  margin: 20px 20px 20px auto;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: auto;
}

.side-dialog-head { position: sticky; top: 0; z-index: 2; min-height: 82px; display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .94); backdrop-filter: blur(14px); }
.dialog-intro { margin: 0; padding: 16px 18px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.provider-cards { display: grid; gap: 9px; padding: 0 16px 16px; }
.provider-card { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.provider-logo { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); font-weight: 900; }
.provider-logo.google { color: #3b73d9; }
.provider-logo.proton { color: #6853d4; background: var(--violet-soft); }
.provider-logo.vietnix { color: #d26b2e; background: #fae5d8; }
.provider-logo.cloudflare { color: #e96d2f; background: #fae7dc; }
.provider-card strong, .provider-card small { display: block; }
.provider-card strong { font-size: 11px; }
.provider-card small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.provider-card button { min-width: 76px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 9px; font-weight: 760; }
.provider-card button.connected { border-color: #aad6c9; background: var(--mint-soft); color: #176d5b; }
.provider-policy { margin: 0 16px 18px; padding: 14px; border-radius: 13px; background: #24211e; color: #fff; }
.provider-policy b, .provider-policy span { display: block; }
.provider-policy b { margin-bottom: 5px; color: #efadb4; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.provider-policy span { font-size: 9px; line-height: 1.55; opacity: .78; }

.audit-list { display: grid; gap: 1px; margin: 0 16px 16px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--line); }
.audit-item { display: grid; grid-template-columns: 32px 1fr auto; gap: 9px; align-items: center; padding: 11px; background: #fff; }
.audit-item i { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-2); color: var(--accent); font-style: normal; }
.audit-item b, .audit-item small { display: block; }
.audit-item b { font-size: 10px; }
.audit-item small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.audit-item time { color: var(--muted); font-size: 8px; }
.full-width { width: calc(100% - 32px); margin: 0 16px 18px; }

.recovery-dialog { background: #fcfaf6; }
.recovery-state { display: flex; align-items: center; gap: 12px; margin: 16px; padding: 14px; border: 1px solid #b9ddd3; border-radius: 14px; background: var(--mint-soft); }
.recovery-pulse { width: 11px; height: 11px; border-radius: 50%; background: #2aae88; box-shadow: 0 0 0 5px rgba(42, 174, 136, .13); }
.recovery-state b, .recovery-state small { display: block; }
.recovery-state b { font-size: 11px; }
.recovery-state small { margin-top: 3px; color: #377568; font-size: 8px; }
.recovery-layers { display: grid; gap: 7px; padding: 0 16px; }
.recovery-layers article { display: grid; grid-template-columns: 29px 1fr auto; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.recovery-layers article > i { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-2); color: var(--accent-deep); font-style: normal; font-size: 8px; font-weight: 900; }
.recovery-layers b, .recovery-layers span { display: block; }
.recovery-layers b { font-size: 10px; }
.recovery-layers span { margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.35; }
.recovery-layers em { padding: 4px 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-style: normal; font-size: 7px; font-weight: 900; }
.readonly-toggle { display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 10px; margin: 14px 16px; padding: 13px; border: 1px solid #ecc7ca; border-radius: 13px; background: #fff5f5; }
.readonly-toggle input { width: 34px; height: 20px; accent-color: var(--danger); }
.readonly-toggle b, .readonly-toggle small { display: block; }
.readonly-toggle b { font-size: 10px; }
.readonly-toggle small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.recovery-actions { display: flex; gap: 8px; padding: 0 16px; }
.recovery-actions button { flex: 1; }
.recovery-rule { margin: 14px 16px 18px; padding: 10px; border-radius: 10px; background: #28231f; color: #f3bcc1; text-align: center; font: 800 8px ui-monospace, monospace; letter-spacing: .08em; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; max-width: min(480px, calc(100vw - 24px)); padding: 12px 16px; border-radius: 12px; background: #25221f; color: #fff; box-shadow: 0 15px 45px rgba(0, 0, 0, .23); font-size: 11px; line-height: 1.45; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .22s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

body.readonly .compose-button,
body.readonly #trashButton,
body.readonly #archiveButton { opacity: .45; pointer-events: none; }
body.readonly .candidate-banner { background: #7c2f37; }

@media (max-width: 1160px) {
  .topbar { grid-template-columns: 210px 1fr auto; }
  .workspace-switcher { display: none; }
  .app-shell { grid-template-columns: 205px minmax(390px, 520px) 1fr; }
  .sidebar { padding-inline: 10px; }
}

@media (max-width: 900px) {
  .topbar { grid-template-columns: auto 1fr auto; padding: 0 14px; gap: 12px; }
  .brand span { display: none; }
  .brand { width: 40px; }
  .global-search kbd { display: none; }
  .app-shell { grid-template-columns: 75px minmax(335px, 1fr) minmax(360px, 1.2fr); }
  .sidebar { align-items: center; padding: 14px 8px; }
  .compose-button { width: 48px; padding: 0; font-size: 0; }
  .compose-button span { font-size: 20px; }
  .folder-nav, .label-section { width: 100%; }
  .folder-nav button, .label-section > button { grid-template-columns: 1fr; justify-items: center; padding: 0; font-size: 0; }
  .folder-nav button > span { font-size: 16px; }
  .folder-nav button b, .aside-title span, .aside-title button, .sidebar-footer { display: none; }
  .label-dot { width: 10px; height: 10px; }
  .reader-content { padding-inline: 28px; }
}

@media (max-width: 720px) {
  body { overflow: auto; }
  .candidate-banner strong { max-width: 73vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar { position: sticky; top: 0; z-index: 5; height: 62px; }
  .global-search { height: 38px; }
  .top-actions .icon-button:not(.recovery-trigger), .avatar { display: none; }
  .app-shell { height: calc(100vh - 90px); grid-template-columns: 58px 1fr; }
  .sidebar { grid-column: 1; }
  .mail-column { grid-column: 2; }
  .reading-pane { position: fixed; z-index: 8; inset: 90px 0 0 58px; display: none; }
  .reading-pane.mobile-open { display: block; }
  .reader-toolbar .reader-back { display: inline-block; }
  .mail-header { height: 72px; }
  .mail-row { grid-template-columns: 21px 35px minmax(0, 1fr) auto; padding-inline: 8px 11px; }
  .mail-meta { max-width: 58px; }
  .reader-content { padding: 25px 20px 55px; }
  .reader-sender { grid-template-columns: 40px 1fr; }
  .reader-sender time { grid-column: 2; }
  .delivery-panel { grid-template-columns: 1fr; }
  .compose-dialog form { min-height: calc(100vh - 28px); }
  .compose-footer { flex-wrap: wrap; }
  #draftState { display: none; }
  .side-dialog { height: calc(100vh - 16px); margin: 8px; max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Shared mailbox and work review: one customer-facing shell. */
[hidden] { display: none !important; }
.summary-stats {display:grid;grid-template-columns:repeat(3,1fr);gap:8px;padding:10px 15px;border-bottom:1px solid var(--line)}
.summary-stats div {display:flex;align-items:center;gap:8px;font-size:11px;color:var(--muted)}
.summary-stats b {font-size:19px;color:var(--ink)}
.mail-column {min-width:0}
.mail-list {min-height:0;flex:1;overflow:auto}
.workflow-badge {font-size:10px;padding:3px 7px;border-radius:7px;background:var(--mint-soft);white-space:nowrap;color:#176d5b}
.workflow-badge.pending {background:var(--amber-soft);color:#7e570e}
.star-button {border:0;background:none;color:var(--accent-deep);padding:5px;font-size:17px}
.message-actions,.work-controls {display:flex;gap:10px;flex-wrap:wrap;margin:20px 0}
.message-actions p,.local-approval-note,.recipient-line {font-size:12px;color:var(--muted);line-height:1.6;overflow-wrap:anywhere}
.work-controls label {display:grid;gap:6px;font-size:11px;flex:1;min-width:120px}
.work-controls select,.flow-select-label select {width:100%;padding:8px;border:1px solid var(--line);border-radius:8px;background:var(--surface);font-size:12px}
.message-history {margin:20px 0;border-top:1px solid var(--line);padding-top:15px}
.message-history summary {font-size:13px;font-weight:700;margin-bottom:12px;cursor:pointer}
.message-history .audit-item {padding:10px 0;border-bottom:1px solid var(--line);background:transparent}
.message-history .audit-item b {font-size:11px}
.approval-choice {display:flex;align-items:center;gap:8px;padding:12px 22px;font-size:12px;background:var(--surface-2)}
.compose-attachments {display:flex;flex-wrap:wrap;gap:6px;padding:0 22px}
.compose-attachments span {font-size:11px;background:var(--surface-2);padding:6px;border-radius:6px;overflow-wrap:anywhere}
.compose-attachments button {background:none;border:0}
.flow-open {border:0;background:none;font-weight:700;text-align:left;padding:0;width:100%;overflow-wrap:anywhere}
.flow-select-label {display:grid;gap:4px;font-size:10px;margin-top:10px}
.flow-board {overflow:auto;min-height:0;flex:1}
.flow-columns {min-width:0;grid-template-columns:repeat(2,minmax(0,1fr))}
.reader-body {overflow-wrap:anywhere}
.mail-row:focus-visible {outline:2px solid var(--accent);outline-offset:-2px}
.compose-dialog {max-height:calc(100dvh - 24px);overflow:auto}
.compose-dialog form {min-height:0}
.compose-body {min-height:160px}
.topbar {grid-template-columns:220px minmax(180px,1fr) auto;gap:16px}
.app-shell {grid-template-columns:210px minmax(300px,420px) minmax(0,1fr)}
.workspace-switcher {display:flex}
.provider-card {grid-template-columns:35px 1fr}
.provider-card > span {grid-column:2;font-size:11px;color:var(--muted)}
.format-actions button {width:auto;min-width:35px;font-size:12px}
button:disabled {cursor:not-allowed;opacity:.45}
@media(max-width:1100px) {
 .topbar {grid-template-columns:auto minmax(100px,1fr) auto;gap:10px;padding-inline:12px}
 .brand span {display:none}
 .app-shell {grid-template-columns:160px minmax(0,1fr)}
 .reading-pane {position:fixed;inset:98px 0 0 160px;z-index:8;display:none;background:var(--surface)}
 .reading-pane.mobile-open {display:block}
 .reader-toolbar .reader-back {display:inline-block}
 .sidebar {align-items:stretch;padding:12px 8px}
 .compose-button {width:100%;font-size:12px}
 .folder-nav button,.label-section > button {grid-template-columns:20px 1fr auto;font-size:11px;justify-items:start;padding:8px}
 .folder-nav button b {display:inline}
 .folder-nav button > span {font-size:14px}
 .workspace-switcher span {display:none}
}
@media(max-width:720px) {
 .candidate-banner {justify-content:flex-start;padding:0 8px;font-size:10px;gap:6px}
 .candidate-banner span {display:none}
 .candidate-banner strong {max-width:100%;font-size:10px}
 .app-shell {grid-template-columns:58px minmax(0,1fr);height:calc(100dvh - 90px)}
 .sidebar {align-items:center}
 .compose-button {font-size:0;width:44px}
 .folder-nav button,.label-section > button {font-size:0;grid-template-columns:1fr;justify-items:center;position:relative}
 .folder-nav button b {font-size:8px;position:absolute;right:0;top:0}
 .folder-nav button > span {font-size:17px}
 .reading-pane {inset:90px 0 0 0}
 .top-actions {gap:3px}
 .top-actions .icon-button:not(.recovery-trigger) {display:inline-grid;width:27px}
 .workspace-switcher {display:flex}
 .workspace-switcher select {width:66px;font-size:10px;padding:2px}
 .global-search {min-width:0}
 .global-search input {min-width:0;width:100%;font-size:11px}
 .topbar {gap:5px;padding:0 6px}
 .brand {width:28px}
 .brand img {width:27px;height:27px}
 .summary-stats {padding:8px;gap:5px}
 .summary-stats div {font-size:9px;gap:4px}
 .summary-stats b {font-size:16px}
 .flow-columns {grid-template-columns:minmax(0,1fr)}
 .reader-content {padding:20px 16px}
 .reader-toolbar {flex-wrap:wrap;height:auto;min-height:48px}
 .approval-choice {padding:10px;font-size:11px}
}

.account-link{font:inherit;font-size:12px;text-decoration:none;color:inherit;padding:8px;border:1px solid #ddd;border-radius:8px;white-space:nowrap}
@media(max-width:720px){
 .topbar{grid-template-columns:28px minmax(0,1fr) auto}
 .account-link{width:28px;height:32px;padding:5px;text-align:center;font-size:0}
 .account-link::before{content:'◎';font-size:18px}
 .global-search{padding-inline:6px;grid-template-columns:minmax(0,1fr)}
 .global-search>span,.global-search kbd{display:none}
}

.root-storage-link{display:block;margin:12px 0 20px;padding:12px 14px;border:1px solid #ddd4e8;border-radius:10px;color:#6c4c8e;text-decoration:none;font-size:13px;font-weight:650;background:#f6f2fa}.root-storage-link:hover{background:#ece4f4}
@media(max-width:720px){.root-storage-link{font-size:0;padding:10px;margin:8px 0}.root-storage-link::before{content:"◇";font-size:18px}}

.mail-connection-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.mail-connection-actions button{padding:8px 12px;border:1px solid #d8d5d0;border-radius:8px;background:#fff;color:#222}.mail-connection-actions details{font-size:12px;max-width:320px}.mail-connection-actions p{overflow-wrap:anywhere}

.language-switcher{display:flex;flex-direction:column;gap:2px;flex:none;min-width:108px;padding:5px 9px;border:1px solid var(--line);border-radius:9px;background:var(--surface)}
.language-switcher>span{font-size:10px;font-weight:650;letter-spacing:.02em;color:var(--muted)}
.language-switcher select{border:0;background:transparent;color:var(--ink);font-size:12px;font-weight:600;max-width:125px;min-height:24px;outline-offset:1px}
.translate-message{white-space:nowrap}
.translation-dialog{width:min(720px,calc(100vw - 24px));max-height:calc(100dvh - 32px);overflow:auto;border:1px solid var(--line);border-radius:16px;padding:22px;background:var(--surface);color:var(--ink)}
.translation-dialog::backdrop{background:rgba(20,18,15,.4)}
.translation-dialog .dialog-head{padding:0 0 12px}.translation-dialog h2{font-size:22px;margin:0}.translation-dialog p,.translation-dialog small{font-size:13px;line-height:1.5;color:var(--muted)}
.translation-languages{display:flex;gap:12px;flex-wrap:wrap}.translation-languages label{flex:1;min-width:160px;font-size:12px}.translation-languages select{display:block;width:100%;padding:9px;margin-top:5px;border:1px solid var(--line);border-radius:8px;background:var(--surface)}
.translation-text-label{display:block;font-size:12px;margin:14px 0}.translation-text-label textarea{display:block;width:100%;min-height:130px;padding:12px;margin-top:5px;border:1px solid var(--line);border-radius:8px;background:white;color:var(--ink);resize:vertical;line-height:1.5}
.translation-pages,.translation-external{display:flex;gap:10px;align-items:center;justify-content:space-between;margin:14px 0;flex-wrap:wrap}.translation-pages button{padding:7px 10px;border:1px solid var(--line);background:var(--surface);border-radius:7px}.translation-external a{padding:10px 14px;text-decoration:none;display:inline-block}.translation-dialog button:disabled{opacity:.5;cursor:default}
@media(max-width:720px){
 .language-switcher{min-width:80px;padding:2px 5px}.language-switcher>span{font-size:9px}.language-switcher select{max-width:86px;font-size:11px;min-height:24px}
 .topbar{height:92px;grid-template-columns:28px minmax(0,1fr);grid-template-rows:30px 42px;padding:6px;gap:4px}
 .topbar>.brand{grid-row:1;grid-column:1}.global-search{grid-row:1;grid-column:2;min-width:24px}
 .top-actions{grid-row:2;grid-column:1/-1;justify-content:space-between;gap:4px}.top-actions .icon-button{display:inline-grid!important}.workspace-switcher select{width:61px}
 .app-shell{height:calc(100dvh - 120px)}.reading-pane{inset:120px 0 0 0}
 .translation-dialog{padding:16px}.translation-external{align-items:stretch;flex-direction:column}
}

.language-control{position:relative;display:flex;align-items:center;gap:4px;min-width:160px}.language-control select{max-width:175px}.language-control>small:empty{display:none}.language-control>small:not(:empty){position:absolute;top:100%;right:0;z-index:90;background:#fff;color:#222;border:1px solid #ddd;padding:10px;border-radius:8px;box-shadow:0 4px 18px #0001;width:260px;max-width:80vw;font-size:12px}.language-control>button{border:0;background:transparent;cursor:pointer;padding:8px;color:inherit}html[dir=rtl] .app-shell,html[dir=rtl] .topbar{direction:rtl}.translation-text-label textarea{unicode-bidi:plaintext}

@media(max-width:720px){.language-control{min-width:0;gap:0;max-width:150px}.language-control .language-switcher{min-width:0;max-width:124px}.language-control select{width:110px;max-width:110px}.language-control>button{padding:5px}.language-control>small:not(:empty){left:0;right:auto}}
