/* Keep the workspace inside the viewport; each column owns its scroll. */
body.is-app { height: 100dvh; overflow: hidden; }
.app-shell { height: 100dvh; min-height: 0; grid-template-columns: 252px minmax(0, 1fr); }
.sidebar { min-height: 0; min-width: 0; overflow: hidden; padding: 24px 14px 14px; }
.wordmark { flex-shrink: 0; padding-bottom: 24px; }
.nav-label, .add-domain, .sidebar-bottom { flex-shrink: 0; }
.mailbox-list { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; padding-bottom: 12px; }
.sidebar-bottom { margin-top: 14px; }
.domain-group { margin: 0 0 9px; }
.domain-heading { display: flex; align-items: center; gap: 7px; cursor: pointer; list-style: none; padding: 12px 6px; font-size: 12px; user-select: none; }
.domain-heading::-webkit-details-marker { display: none; }
.domain-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.domain-count { color: var(--muted); font-size: 10px; font-weight: 400; }
.domain-chevron { color: var(--muted); transform: rotate(-90deg); }
.domain-group[open] .domain-chevron { transform: rotate(0); }
.domain-mailboxes { padding-bottom: 4px; }
.mailbox-button { min-height: 38px; padding-left: 13px; border-left: 2px solid transparent; }
.mailbox-button.active { border-left-color: var(--ink); background: #e8e8df; font-weight: 600; }
.mailbox-button.active .unread-mark { background: var(--green); border: 1px solid var(--ink); width: 7px; height: 7px; }
.mail-area { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.topbar { flex-shrink: 0; padding: 0 28px; }
.crumb { min-width: 0; }
.crumb b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-content { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; padding: 24px 28px 10px; max-width: none; width: 100%; margin: 0; }
.heading-row { flex-shrink: 0; margin-bottom: 20px; }
.heading-row .eyebrow { margin: 0 0 8px; }
.heading-row h1 { font-size: 28px; }
.error-box { flex-shrink: 0; margin: 0 0 12px; }
.mail-workspace { display: grid; grid-template-columns: minmax(310px, 0.85fr) minmax(0, 1.35fr); flex: 1; min-height: 0; min-width: 0; border: 1px solid var(--line); background: var(--white); }
.inbox-panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; border: 0; background: var(--white); overflow: hidden; }
.inbox-toolbar { flex-shrink: 0; min-height: 48px; padding: 12px 18px; gap: 10px; border-bottom: 1px solid var(--line); }
.toolbar-mailbox { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messages { min-height: 0; overflow-y: auto; overflow-x: hidden; flex: 1; overscroll-behavior: contain; scrollbar-gutter: stable; }
.message-card { border-bottom: 1px solid var(--line); }
.message-row { width: 100%; min-width: 0; padding: 20px 16px; border: 0; border-left: 3px solid transparent; gap: 12px; text-align: left; }
.message-row:hover { background: #f8f8f3; }
.message-row.active { background: var(--paper); border-left-color: var(--ink); }
.message-row.active .sender-avatar { background: var(--ink); color: var(--green); }
.sender-avatar { width: 32px; height: 32px; flex-shrink: 0; font-size: 12px; }
.message-main { gap: 7px; }
.message-top { align-items: center; gap: 8px; }
.message-top strong { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-top time { font-size: 9px; }
.subject { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; font-size: 13px; line-height: 1.45; }
.is-unread .subject { font-weight: 700; }
.is-unread .message-top strong::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 6px; background: var(--ink); vertical-align: middle; }
.preview:empty { display: none; }
.preview { font-size: 11px; line-height: 1.5; }
.row-arrow { font-size: 18px; flex-shrink: 0; }
.message-row.active .row-arrow { color: var(--ink); }
.reader-panel { min-height: 0; min-width: 0; overflow: auto; border-left: 1px solid var(--line); overscroll-behavior: contain; scrollbar-gutter: stable; }
.message-reader { min-height: 100%; min-width: 0; display: flex; flex-direction: column; }
.reader-empty { margin: auto; padding: 40px; max-width: 420px; text-align: center; }
.reader-empty-icon { display: inline-grid; place-items: center; height: 58px; width: 58px; background: var(--green); font-size: 28px; margin-bottom: 22px; }
.reader-empty .eyebrow { font-size: 9px; line-height: 1.6; margin: 0 0 10px; }
.reader-empty h2 { font-size: 27px; line-height: 1.2; letter-spacing: -1px; margin: 0 0 14px; }
.reader-empty > p:last-child { color: var(--muted); font-size: 13px; line-height: 1.6; }
.reader-header { padding: 24px 26px 0; }
.reader-kicker { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 18px; }
.reader-kicker .eyebrow { margin: 0; font-size: 9px; overflow-wrap: anywhere; }
.reader-close { flex-shrink: 0; width: 30px; height: 30px; display: grid; place-items: center; background: transparent; border: 1px solid var(--line); font-size: 23px; color: var(--muted); }
.reader-close:hover { color: var(--ink); border-color: var(--ink); }
.reader-header h2 { font-size: clamp(21px, 1.8vw, 29px); line-height: 1.3; letter-spacing: -0.7px; margin: 0 0 18px; overflow-wrap: anywhere; }
.detail-from { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 0; padding-bottom: 18px; }
.detail-from strong { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.reader-content { padding: 0 26px 24px; min-width: 0; flex: 1; }
.detail-text { max-height: none; overflow: visible; padding: 24px 0; line-height: 1.8; color: var(--ink); }
.detail-html-note { font-size: 10px; line-height: 1.6; margin: 14px 0; }
.detail-html { height: 62dvh; min-height: 320px; border: 0; }
.inline-reader { display: none; }
.privacy-note { flex-shrink: 0; font-size: 9px; line-height: 1.5; margin: 10px 0 0; }
.domain-heading:focus-visible, .message-row:focus-visible, .reader-close:focus-visible, .mailbox-button:focus-visible { outline: 2px solid var(--ink); outline-offset: -3px; }
@media (max-width: 1100px) {
  .mail-workspace { grid-template-columns: minmax(0, 1fr); }
  .reader-panel { display: none; }
  .inline-reader:not(:empty) { display: block; }
  .inline-reader .message-reader { min-height: 0; border-top: 1px solid var(--line); background: #fff; }
  .reader-header { padding: 20px 22px 0; }
  .reader-header h2 { font-size: 23px; }
  .reader-content { padding: 0 22px 24px; }
  .message-row.active .row-arrow { transform: rotate(90deg); }
}
@media (max-width: 780px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(160px, 28dvh) minmax(0, 1fr); }
  .sidebar { display: flex; flex-direction: column; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .wordmark { font-size: 16px; padding: 0 4px 8px; }
  .wordmark .brand-mark { width: 25px; height: 25px; }
  .nav-label, .sidebar-bottom { display: none; }
  .mailbox-list { display: block; padding-bottom: 0; }
  .domain-group { display: block; margin-bottom: 0; }
  .domain-heading { display: flex; padding: 9px 6px; }
  .domain-mailboxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .mailbox-button { width: 100%; max-width: none; background: transparent; padding: 8px 13px; }
  .add-domain { margin: 5px 2px 0; padding: 5px 8px; font-size: 11px; }
  .topbar { height: 48px; min-height: 48px; padding: 0 14px; gap: 8px; }
  .crumb { display: flex; gap: 8px; font-size: 10px; }
  .crumb > span { display: none; }
  .top-actions { flex-shrink: 0; }
  #sync-label { display: none; }
  .mail-content { padding: 16px 12px 8px; }
  .heading-row { margin-bottom: 13px; gap: 10px; }
  .heading-row h1 { font-size: 22px; }
  .heading-row .eyebrow { font-size: 8px; margin-bottom: 5px; }
  .count-pill { padding: 7px 9px; font-size: 9px; white-space: nowrap; }
  .inbox-toolbar { min-height: 40px; padding: 10px 12px; }
  .message-row { padding: 16px 12px; gap: 10px; }
  .sender-avatar { width: 28px; height: 28px; }
  .subject { font-size: 12px; }
  .message-top strong { font-size: 11px; }
  .reader-header { padding: 18px 14px 0; }
  .reader-header h2 { font-size: 20px; }
  .reader-content { padding: 0 14px 18px; }
  .reader-kicker { gap: 8px; }
  .privacy-note { display: none; }
  .empty-state { min-height: 180px; }
}
