/* App shell, mail list, reader, compose */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-rows: var(--top) minmax(0, 1fr); height: 100%; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 0; border-bottom: 1px solid var(--line); background: var(--panel); position: relative; z-index: 3; }
.top .brandcell { width: var(--rail); flex: none; height: 100%; display: flex; align-items: center; gap: 10px; padding: 0 14px 0 16px; border-right: 1px solid var(--line); color: var(--text); }
.top .brandcell:hover { text-decoration: none; }
.top .brandcell img { width: 26px; height: 26px; }
.top .brandcell .nm { font: 500 17px/1 var(--serif); letter-spacing: -.005em; white-space: nowrap; }
.top .brandcell .nm small { display: block; margin-top: 3px; font: 500 9.5px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.top .burger { display: none; }
.search { flex: 1 1 auto; max-width: 640px; margin: 0 18px; position: relative; }
.search input { width: 100%; height: 34px; padding: 0 70px 0 38px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); }
.search input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.search .ic.si { position: absolute; left: 11px; top: 8px; color: var(--dim); pointer-events: none; }
.search .adv { position: absolute; right: 3px; top: 3px; }
.search .kbd { position: absolute; right: 38px; top: 7px; pointer-events: none; }
.tabs { display: flex; height: 100%; margin-left: auto; }
.tabs a { display: flex; align-items: center; padding: 0 16px; height: 100%; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--gold); }
.top .acct { display: flex; align-items: center; gap: 2px; padding: 0 10px 0 6px; }
.top .acct .av { cursor: pointer; margin-left: 4px; }
.announce { background: color-mix(in srgb, var(--gold) 14%, var(--panel)); border-bottom: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line)); color: var(--text); font-size: 13px; padding: 7px 16px; display: flex; gap: 12px; align-items: center; }

.rail { grid-row: 2; grid-column: 1; overflow: auto; border-right: 1px solid var(--line); background: var(--panel); padding: 14px 0 12px; display: flex; flex-direction: column; min-height: 0; }
.rail .cta { padding: 0 14px 14px; }
.rail .cta .btn { height: 42px; width: 100%; justify-content: flex-start; padding: 0 16px; font-size: 14.5px; }
.nav { display: grid; }
.nav a, .nav button { display: flex; align-items: center; gap: 12px; height: 34px; padding: 0 16px; color: var(--muted); width: 100%; text-align: left; border-left: 2px solid transparent; position: relative; }
.nav a:hover, .nav button:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"], .nav button[aria-current="page"] { color: var(--text); background: var(--sel); border-left-color: var(--gold); font-weight: 600; }
.nav .n { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav a.unread .n { color: var(--text); font-weight: 600; }
.nav .sw { width: 10px; height: 10px; border-radius: 1px; flex: none; margin: 0 4px; }
.rail .sect { display: flex; align-items: center; padding: 18px 16px 6px; }
.rail .sect .tag { flex: 1; }
.rail .spacer { flex: 1; min-height: 14px; }
.storage { margin: 0 16px; padding-top: 14px; border-top: 1px solid var(--line2); font-size: 12.5px; color: var(--muted); display: grid; gap: 7px; }
.storage a { font-weight: 600; color: var(--accent-text); }

.view { grid-row: 2; grid-column: 2; min-width: 0; min-height: 0; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.scrollpage { overflow: auto; flex: 1; }

/* ------- mail layout ------- */
.mail { display: flex; flex: 1; min-height: 0; }
.mail[data-pane="bottom"] { flex-direction: column; }
.ml { display: flex; flex-direction: column; min-width: 0; min-height: 0; flex: 1 1 auto; background: var(--bg); }
.mail[data-pane="right"] .ml { flex: 0 0 clamp(340px, 38%, 480px); border-right: 1px solid var(--line); }
.mail[data-pane="bottom"] .ml { flex: 0 0 42%; border-bottom: 1px solid var(--line); }
.mr { display: flex; flex-direction: column; min-width: 0; min-height: 0; flex: 1 1 0; background: var(--bg); }
.mail[data-pane="none"] .mr { display: none; }
.mail[data-pane="none"].reading .ml { display: none; }
.mail[data-pane="none"].reading .mr { display: flex; }
.mtool { display: flex; align-items: center; gap: 2px; padding: 0 10px; height: 44px; flex: none; border-bottom: 1px solid var(--line); background: var(--bg); }
.mtool .pg { margin-left: auto; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.mtool .vsep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }
.mtool .check { padding: 0 8px 0 10px; }
.mtool .selinfo { font-size: 13px; color: var(--muted); margin-left: 6px; }
.mlist { overflow: auto; flex: 1; min-height: 0; }
.banner { padding: 9px 16px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line2); background: var(--panel); display: flex; gap: 10px; align-items: center; }
.banner b { color: var(--text); }

.mrow { display: grid; grid-template-columns: 32px 30px minmax(110px, 190px) minmax(0, 1fr) auto 78px; align-items: center; min-height: 40px; padding: 0 10px 0 6px; border-bottom: 1px solid var(--line2); cursor: pointer; position: relative; background: var(--bg); }
.mrow:hover { background: var(--hover); }
.mrow.read { background: color-mix(in srgb, var(--panel) 55%, var(--bg)); }
.mrow.read:hover { background: var(--hover); }
.mrow.unread::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--gold); }
.mrow.cur { background: var(--sel); }
.mrow.sel { background: color-mix(in srgb, var(--blue) 18%, var(--bg)); }
.mrow .cb { display: grid; place-items: center; }
.mrow .star { color: var(--dim); display: grid; place-items: center; height: 30px; }
.mrow .star:hover { color: var(--text); }
.mrow .star.on { color: var(--gold); }
.mrow .who { font-size: 13.5px; padding-right: 14px; }
.mrow .who .cnt { color: var(--dim); font-size: 12px; margin-left: 4px; }
.mrow.unread .who, .mrow.unread .subj b { font-weight: 700; color: var(--text); }
.mrow .who .u { font-weight: 700; color: var(--text); }
.mrow .subj { font-size: 13.5px; display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.mrow .subj b { font-weight: 400; white-space: nowrap; max-width: 62%; overflow: hidden; text-overflow: ellipsis; }
.mrow .snip { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mrow .chips { display: flex; gap: 4px; padding-left: 8px; }
.mrow .chips .chip { height: 17px; font-size: 11px; padding: 0 6px; }
.mrow .when { text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.mrow.unread .when { color: var(--text); font-weight: 600; }
.mrow .qa { display: none; position: absolute; right: 6px; top: 0; bottom: 0; align-items: center; background: inherit; padding-left: 14px; box-shadow: -12px 0 10px -4px var(--hover); }
.mrow:hover .qa { display: flex; }
.mrow:hover .qa::before { content: ""; }
.mrow .qa .ibtn { width: 30px; height: 30px; }
@media (hover: none) { .mrow:hover .qa { display: none; } }
.mrow .att { color: var(--dim); }
.mail:not([data-pane="none"]) .mrow { grid-template-columns: 28px 26px minmax(0, 1fr) auto; grid-template-areas: "cb star who when" "cb star subj subj" "cb star snip snip"; padding: 8px 12px 9px 4px; row-gap: 1px; min-height: 0; align-items: start; }
.mail:not([data-pane="none"]) .mrow .cb { grid-area: cb; padding-top: 3px; }
.mail:not([data-pane="none"]) .mrow .star { grid-area: star; height: 24px; }
.mail:not([data-pane="none"]) .mrow .who { grid-area: who; padding-right: 8px; }
.mail:not([data-pane="none"]) .mrow .when { grid-area: when; }
.mail:not([data-pane="none"]) .mrow .subj { grid-area: subj; }
.mail:not([data-pane="none"]) .mrow .subj b { max-width: 100%; }
.mail:not([data-pane="none"]) .mrow .subj .snip { display: none; }
.mail:not([data-pane="none"]) .mrow .snip3 { grid-area: snip; display: block; }
.mail:not([data-pane="none"]) .mrow .chips { display: none; }
.mail:not([data-pane="none"]) .mrow .qa { display: none !important; }
.mrow .snip3 { display: none; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
[data-density="compact"] .mrow { min-height: 32px; }
[data-density="compact"] .mail:not([data-pane="none"]) .mrow { padding-top: 5px; padding-bottom: 6px; }

.empty { padding: 56px 24px; max-width: 460px; margin: 0 auto; text-align: left; color: var(--muted); }
.empty h3 { font: 400 26px/1.15 var(--serif); color: var(--text); margin-bottom: 8px; }
.empty .rule { width: 28px; height: 2px; background: var(--gold); margin-bottom: 18px; }
.mr .empty { margin: auto; }

/* reader */
.rtool { display: flex; align-items: center; gap: 2px; padding: 0 10px; height: 44px; flex: none; border-bottom: 1px solid var(--line); }
.rtool .sp { flex: 1; }
.rscroll { overflow: auto; flex: 1; min-height: 0; }
.rhead { padding: 22px 28px 10px; max-width: 920px; }
.rhead h1 { font: 400 26px/1.22 var(--serif); letter-spacing: -.005em; word-break: break-word; }
.rhead .lbls { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.rhead .lbls .chip button { display: inline-grid; place-items: center; color: var(--dim); }
.rhead .lbls .chip button:hover { color: var(--text); }
.msg { max-width: 920px; margin: 0 28px; border-top: 1px solid var(--line2); padding: 14px 0; }
.msg:first-of-type { border-top: 1px solid var(--line); }
.msg .mh { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.msg .mh .who { flex: 1; min-width: 0; }
.msg .mh .nm { font-weight: 600; }
.msg .mh .ad { color: var(--dim); font-size: 12.5px; margin-left: 6px; }
.msg .mh .to { font-size: 12.5px; color: var(--muted); }
.msg .mh .dt { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.msg.collapsed .mh .to { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
.msg .mb { padding-left: 46px; }
.msg .details { margin: 8px 0 0 46px; padding: 10px 12px; border: 1px solid var(--line2); background: var(--panel); font-size: 12.5px; display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; color: var(--muted); }
.msg .details dt { color: var(--dim); }
.msg .details dd { margin: 0; word-break: break-all; }
.msg iframe.body { display: block; width: 100%; border: 0; background: transparent; min-height: 40px; color-scheme: normal; }
.msg .warn { margin: 10px 0 10px 46px; }
.msg .warn.inl { margin-left: 0; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px 46px; }
.att-tile { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--panel); padding: 8px 10px 8px 12px; min-width: 200px; max-width: 280px; border-radius: var(--r); }
.att-tile .ic.lg { color: var(--dim); }
.att-tile .meta { min-width: 0; flex: 1; }
.att-tile .meta .n { font-size: 13px; font-weight: 500; }
.att-tile .meta .s { font-size: 11.5px; color: var(--dim); }
.replybar { display: flex; gap: 8px; padding: 18px 28px 40px 74px; max-width: 920px; }

/* ------- compose ------- */
.docks { position: fixed; right: 18px; bottom: 0; display: flex; flex-direction: row-reverse; align-items: flex-end; gap: 12px; z-index: 40; pointer-events: none; max-width: calc(100vw - 36px); }
.cw { pointer-events: auto; width: 520px; max-width: calc(100vw - 20px); height: min(580px, calc(100vh - 80px)); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r) var(--r) 0 0; box-shadow: var(--shadow); animation: rise .18s var(--ease); }
.cw.min { height: 40px; width: 260px; }
.cw.min .cwb { display: none; }
.cw.max { position: fixed; inset: 6vh 8vw 0 8vw; width: auto; height: auto; max-width: none; z-index: 41; }
.cw > .cwh { display: flex; align-items: center; height: 40px; flex: none; padding: 0 4px 0 14px; background: var(--panel2); border-bottom: 1px solid var(--line); cursor: pointer; gap: 2px; border-radius: var(--r) var(--r) 0 0; }
.cw > .cwh .t { flex: 1; font-weight: 600; font-size: 13.5px; }
.cwb { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cwf { display: flex; align-items: center; gap: 8px; padding: 0 12px; min-height: 36px; border-bottom: 1px solid var(--line2); position: relative; }
.cwf > label { color: var(--dim); font-size: 13px; width: 52px; flex: none; }
.cwf > .fld { flex: 1; min-width: 0; padding: 4px 0; }
.cwf input.bare, .cwf select.bare { width: 100%; height: 30px; background: transparent; border: 0; padding: 0; }
.cwf input.bare:focus { outline: none; }
.cwf select.bare { appearance: none; color: var(--text); }
.cwf .ccl { display: flex; gap: 8px; font-size: 12.5px; color: var(--muted); }
.cwf .ccl button:hover { color: var(--text); text-decoration: underline; }
.rc { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.rc .rcp { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 3px 0 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); font-size: 13px; max-width: 100%; }
.rc .rcp.bad { border-color: var(--danger); color: var(--danger); }
.rc .rcp button { display: grid; place-items: center; color: var(--dim); width: 18px; height: 18px; }
.rc .rcp button:hover { color: var(--text); }
.rc input { flex: 1; min-width: 120px; height: 28px; border: 0; background: transparent; padding: 0; }
.rc input:focus { outline: none; }
.sugg { position: absolute; left: 64px; right: 12px; top: 100%; z-index: 4; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); max-height: 220px; overflow: auto; }
.sugg button { display: flex; gap: 10px; width: 100%; padding: 7px 12px; text-align: left; align-items: baseline; }
.sugg button:hover, .sugg button.on { background: var(--hover); }
.sugg .a { color: var(--dim); font-size: 12.5px; }
.edbar { display: flex; align-items: center; gap: 0; padding: 3px 8px; border-bottom: 1px solid var(--line2); flex-wrap: wrap; }
.edbar .ibtn { width: 30px; height: 30px; }
.edbar .vs { width: 1px; height: 16px; background: var(--line); margin: 0 5px; }
.ed { flex: 1; min-height: 120px; overflow: auto; padding: 12px 14px; outline: none; line-height: 1.55; font-size: 14px; word-break: break-word; }
.ed blockquote { margin: 0 0 0 .8ex; padding-left: 1ex; border-left: 2px solid var(--line); color: var(--muted); }
.ed a { color: var(--blue-text); text-decoration: underline; }
.ed ul, .ed ol { margin: 0; padding-left: 24px; }
.ed pre { font-family: var(--mono); background: var(--bg); padding: 8px; overflow: auto; }
.ed:empty::before { content: attr(data-ph); color: var(--dim); }
.cwatt { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line2); max-height: 96px; overflow: auto; }
.cwatt .at { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 9px; border: 1px solid var(--line); background: var(--bg); font-size: 12.5px; border-radius: var(--r); }
.cwatt .at .prog { width: 40px; height: 3px; background: var(--line); }
.cwatt .at .prog i { display: block; height: 100%; background: var(--gold); }
.cwfoot { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--line); }
.cwfoot .status { margin-left: auto; font-size: 12px; color: var(--dim); padding-right: 6px; }
.splitbtn { display: inline-flex; }
.splitbtn .btn:first-child { border-radius: var(--r) 0 0 var(--r); padding: 0 16px; }
.splitbtn .btn:last-child { border-radius: 0 var(--r) var(--r) 0; border-left: 1px solid color-mix(in srgb, var(--gold-ink) 30%, var(--gold)); padding: 0 8px; }
.cw.drop::after { content: "Drop files to attach"; position: absolute; inset: 40px 0 0 0; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 82%, transparent); border: 2px dashed var(--gold); font: 400 20px var(--serif); pointer-events: none; }

/* ------- small screens ------- */
.scrimnav { display: none; }
@media (max-width: 900px) {
  .top .burger { display: grid; }
  .top .brandcell { width: auto; border-right: 0; padding-left: 4px; }
  .top .brandcell .nm small { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; z-index: 30; top: var(--top); bottom: 0; left: 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform .2s var(--ease); box-shadow: var(--shadow); }
  .shell.nav-open .rail { transform: none; }
  .shell.nav-open .scrimnav { display: block; position: fixed; inset: var(--top) 0 0 0; background: rgba(0, 0, 0, .5); z-index: 29; }
  .view { grid-column: 1; }
  .search { margin: 0 6px; }
  .search .kbd { display: none; }
  .tabs a { padding: 0 10px; }
  .mail[data-pane] { flex-direction: column; }
  .mail[data-pane="right"] .ml, .mail[data-pane="bottom"] .ml { flex: 1 1 auto; border: 0; }
  .mail[data-pane="right"] .mr, .mail[data-pane="bottom"] .mr { display: none; }
  .mail[data-pane].reading .ml { display: none; }
  .mail[data-pane].reading .mr { display: flex; }
  .rhead { padding: 16px 16px 8px; }
  .msg { margin: 0 16px; }
  .msg .mb, .atts, .msg .details, .msg .warn { padding-left: 0; margin-left: 0; }
  .replybar { padding: 14px 16px 40px; flex-wrap: wrap; }
  .docks { right: 0; left: 0; max-width: none; }
  .cw:not(.min) { position: fixed; inset: 0; width: auto; height: auto; max-width: none; border: 0; border-radius: 0; z-index: 60; }
  .cw.min { width: 200px; }
}
@media (max-width: 640px) {
  .tabs a:not([aria-current="page"]) span { display: none; }
  .top .brandcell .nm { display: none; }
  .mtool .hide-s { display: none; }
}

/* keyboard cursor and the back button, which only shows when the list is hidden */
.mrow.kb { outline: 1px solid var(--gold); outline-offset: -1px; }
.hide-wide { display: none; }
.mail[data-pane="none"] .hide-wide { display: grid; }
@media (max-width: 900px) { .hide-wide { display: grid; } }

/* phones: one tidy top bar, a floating Write button, and a roomier message header */
.fab { display: none; }
@media (max-width: 900px) {
  .shell[data-tab="mail"] .fab { display: inline-flex; position: fixed; right: 16px; bottom: 18px; z-index: 20; height: 48px; padding: 0 18px 0 14px; align-items: center; gap: 8px; background: var(--gold); color: #1a1409; border: 1px solid var(--gold); border-radius: var(--r); font-weight: 600; box-shadow: var(--shadow); }
  .shell[data-tab="mail"]:has(.mail.reading) .fab, .shell.nav-open .fab { display: none; }
}
@media (max-width: 640px) {
  .top .brandcell { display: none; }
  .top .burger { margin-left: 2px; }
  .top .acct > button[aria-label="Settings"] { display: none; }
  .top .acct { padding-right: 8px; }
  .search { min-width: 0; margin: 0 6px; }
  .tabs a { padding: 0 11px; }
  .msg .mh { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 12px; }
  .msg .mh > :first-child { grid-row: 1 / span 2; }
  .msg .mh .who { grid-column: 2; grid-row: 1; }
  .msg .mh .dt { grid-column: 2; grid-row: 2; white-space: normal; }
  .msg .mh > .row-flex { grid-column: 3; grid-row: 1; }
  .msg .mh .ad { display: block; margin-left: 0; overflow-wrap: anywhere; }
}
