/* avr mail — layout on top of /brand/avr.css (colours, type, shapes and motion come from there) */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
[hidden] { display: none !important; }
.boot { height: 100vh; display: grid; place-items: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- small parts ---------- */
.icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ibtn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--r-full); background: transparent;
  color: var(--on-surface-variant); cursor: pointer; transition: background .2s, border-radius .35s var(--ease-spring), transform .25s var(--ease-spring); flex: none; }
.ibtn:hover { background: var(--surface-high); border-radius: 12px; }
.ibtn:active { transform: scale(.9); }
.ibtn[aria-pressed="true"] { color: var(--primary); }
.ibtn:focus-visible, .row:focus-visible, .folder:focus-visible { outline: 2px solid var(--outline); outline-offset: 2px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font: 620 13px/18px var(--font); color: var(--on-surface-variant); }
.input, select.input, textarea.input { width: 100%; height: 48px; padding: 0 16px; border: 1px solid var(--outline-variant); border-radius: var(--r-sm);
  background: var(--surface-lowest); color: var(--on-surface); outline: none; transition: border-color .2s, box-shadow .2s; }
textarea.input { height: auto; min-height: 120px; padding: 12px 16px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 22%, transparent); }
.hint { font: 400 13px/18px var(--font); color: var(--on-surface-variant); }
.err { color: var(--error); font: 500 14px/20px var(--font); min-height: 20px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.avr-btn[disabled] { opacity: .55; pointer-events: none; }
.avr-btn.danger { background: var(--error-container); color: var(--on-error-container); }
.avr-btn.small { height: 36px; padding: 0 16px; font-size: 14px; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: var(--r-full); font: 620 12px/1 var(--font);
  background: var(--surface-high); color: var(--on-surface-variant); }
.pill.on { background: var(--secondary-container); color: var(--on-secondary-container); }
.pill.warn { background: var(--tertiary-container); color: var(--on-tertiary-container); }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }

#toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 100;
  display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: var(--r-md); max-width: min(92vw, 520px);
  background: var(--on-surface); color: var(--surface); font: 500 14px/20px var(--font); box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: toast-in .45s var(--ease-spring); }
.toast button { border: 0; background: none; color: var(--avr-pink); font: 620 14px/1 var(--font); cursor: pointer; padding: 4px; }
.toast.error { background: var(--error-container); color: var(--on-error-container); }
@keyframes toast-in { from { transform: translateY(20px) scale(.9); opacity: 0; } }

/* ---------- sign-in, invite ---------- */
.gate { height: 100vh; overflow: auto; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(420px, 100%); padding: 36px 32px 28px; border-radius: var(--r-xl); background: var(--surface-low); position: relative; z-index: 1; }
.gate-card h1 { margin: 18px 0 6px; }
.gate-card .avr-word { font-size: 40px; }
.gate-sign { width: 96px; height: auto; display: block; }
.gate .avr-btn { width: 100%; margin-top: 4px; }
.addr-pick { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; }
.addr-pick .at { color: var(--on-surface-variant); font-weight: 600; }
.addr-pick select { width: auto; }

/* ---------- the mail screen ---------- */
.shell { height: 100vh; height: 100dvh; display: grid; grid-template-rows: 64px 1fr; background: var(--background); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding-right: 12px; flex: none; }
.brand img { width: 46px; height: auto; }
.brand .avr-word { font-size: 26px; }
.search { flex: 1; max-width: 680px; display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 8px 0 16px; border-radius: var(--r-full);
  background: var(--surface-high); color: var(--on-surface-variant); transition: background .2s, border-radius .35s var(--ease-spring); }
.search:focus-within { background: var(--surface-lowest); border-radius: var(--r-md); box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.search input { flex: 1; border: 0; background: none; outline: none; height: 100%; color: var(--on-surface); min-width: 0; }
.topbar .spacer { flex: 1; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; font: 700 15px/1 var(--font);
  background: var(--primary-container); color: var(--on-primary-container); border: 0; cursor: pointer; }
.menu { position: absolute; z-index: 60; min-width: 220px; padding: 8px; border-radius: var(--r-md); background: var(--surface-highest);
  box-shadow: 0 10px 30px rgba(0,0,0,.28); animation: menu-in .3s var(--ease-spring); transform-origin: top right; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 12px; padding: 10px 12px; border: 0; border-radius: var(--r-sm); background: none;
  text-align: left; cursor: pointer; color: var(--on-surface); text-decoration: none; font: 500 14px/20px var(--font); }
.menu button:hover, .menu a:hover { background: color-mix(in oklab, var(--on-surface) 8%, transparent); }
.menu .who { padding: 8px 12px 10px; font: 400 13px/18px var(--font); color: var(--on-surface-variant); border-bottom: 1px solid var(--outline-variant); margin-bottom: 6px; }
@keyframes menu-in { from { transform: scale(.85); opacity: 0; } }

.panes { display: grid; grid-template-columns: 248px minmax(300px, 400px) 1fr; gap: 0 8px; padding: 0 8px 8px 0; min-height: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 8px 16px 12px; overflow: auto; min-height: 0; }
.compose-btn { margin: 4px 0 14px; height: 56px; justify-content: flex-start; padding: 0 22px; border-radius: 18px; gap: 12px;
  background: var(--primary-container); color: var(--on-primary-container); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.compose-btn:hover { border-radius: 26px; }
.folder { display: flex; align-items: center; gap: 14px; height: 44px; padding: 0 14px; border: 0; border-radius: var(--r-full); background: none;
  color: var(--on-surface-variant); cursor: pointer; text-align: left; font: 560 14px/1 var(--font); transition: background .2s, border-radius .35s var(--ease-spring); }
.folder:hover { background: var(--surface-high); }
.folder[aria-current="true"] { background: var(--secondary-container); color: var(--on-secondary-container); font-weight: 700; border-radius: 14px; }
.folder .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .count { font: 700 12px/1 var(--font); }
.folder.drop { outline: 2px dashed var(--primary); }
.nav-sep { height: 1px; background: var(--outline-variant); margin: 10px 12px; }
.nav .label { padding: 8px 14px 4px; font: 620 12px/16px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--on-surface-variant); display: flex; align-items: center; }
.nav .label .ibtn { width: 28px; height: 28px; margin-left: auto; }
.quota { margin: auto 14px 0; padding-top: 18px; font: 400 12px/16px var(--font); color: var(--on-surface-variant); }
.quota .bar { height: 4px; border-radius: 99px; background: var(--surface-highest); overflow: hidden; margin-bottom: 6px; }
.quota .bar i { display: block; height: 100%; background: var(--avr-gradient); border-radius: 99px; }

.listpane, .reader { background: var(--surface-low); border-radius: var(--r-lg); min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.listhead { display: flex; align-items: center; gap: 4px; padding: 10px 10px 6px 16px; min-height: 56px; }
.listhead h2 { margin: 0; flex: 1; font: 680 19px/24px var(--font); font-variation-settings: "wght" 680, "wdth" 106, "ROND" 80; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list { flex: 1; overflow: auto; padding: 0 6px 12px; overscroll-behavior: contain; }
.row { position: relative; display: grid; grid-template-columns: 40px 1fr auto; gap: 2px 12px; align-items: center; padding: 10px 10px 10px 8px;
  border-radius: var(--r-md); cursor: pointer; transition: background .15s, border-radius .35s var(--ease-spring); user-select: none; }
.row:hover { background: var(--surface-mid); }
.row[aria-selected="true"] { background: var(--secondary-container); color: var(--on-secondary-container); border-radius: 22px; }
.row.checked { background: color-mix(in oklab, var(--primary) 14%, transparent); }
.row .av { grid-row: span 2; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font: 700 15px/1 var(--font); color: #fff; }
.row .av.check { background: var(--primary) !important; }
.row .who { font: 500 14px/20px var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 6px; align-items: center; min-width: 0; }
.row .who b { overflow: hidden; text-overflow: ellipsis; }
.row .when { font: 500 12px/16px var(--font); color: var(--on-surface-variant); white-space: nowrap; }
.row .subj { grid-column: 2 / 4; font: 400 13px/18px var(--font); color: var(--on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.row.unread .who, .row.unread .subj { font-weight: 720; color: var(--on-surface); }
.row.unread::before { content: ""; position: absolute; left: 2px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--primary); }
.row .tick { display: inline-flex; gap: 4px; color: var(--on-surface-variant); }
.row .tick .icon { width: 15px; height: 15px; }
.row .star.on { color: #E8A33D; fill: #E8A33D; }
.row .n { font: 700 11px/1 var(--font); color: var(--on-surface-variant); }
.more { display: block; margin: 8px auto; }

.empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 32px; text-align: center; color: var(--on-surface-variant); }
.empty .avr-star { width: 56px; height: 56px; opacity: .85; }
.empty p { margin: 0; max-width: 260px; font: 400 15px/22px var(--font); }

.readhead { display: flex; align-items: center; gap: 2px; padding: 8px 12px; min-height: 56px; border-bottom: 1px solid var(--outline-variant); flex-wrap: wrap; }
.readhead .spacer { flex: 1; }
.readbody { flex: 1; overflow: auto; padding: 18px 24px 40px; overscroll-behavior: contain; }
.readbody h1 { margin: 0 0 18px; font: 700 23px/30px var(--font); font-variation-settings: "wght" 700, "wdth" 104, "ROND" 60; overflow-wrap: anywhere; }
.meta { display: grid; grid-template-columns: 44px 1fr auto; gap: 2px 14px; align-items: center; margin-bottom: 16px; }
.meta .av { grid-row: span 2; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font: 700 17px/1 var(--font); color: #fff; }
.meta .from { font: 600 15px/20px var(--font); overflow-wrap: anywhere; }
.meta .from small { font-weight: 400; color: var(--on-surface-variant); }
.meta .to { font: 400 13px/18px var(--font); color: var(--on-surface-variant); overflow-wrap: anywhere; }
.meta .date { font: 500 12px/16px var(--font); color: var(--on-surface-variant); grid-row: 1; grid-column: 3; white-space: nowrap; }
.notice { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border-radius: var(--r-sm);
  background: var(--surface-high); font: 400 13px/18px var(--font); }
.notice.spam { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.mailframe { width: 100%; border: 0; display: block; min-height: 80px; background: transparent; color-scheme: normal; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.att { display: inline-flex; align-items: center; gap: 10px; max-width: 280px; padding: 8px 14px 8px 10px; border-radius: var(--r-sm); background: var(--surface-high);
  color: var(--on-surface); text-decoration: none; font: 500 13px/18px var(--font); transition: border-radius .35s var(--ease-spring); }
.att:hover { border-radius: 20px; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att small { color: var(--on-surface-variant); white-space: nowrap; }
.thread { display: grid; gap: 4px; margin: -4px 0 18px; }
.thread button { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border: 0; border-radius: var(--r-sm); background: var(--surface-mid); cursor: pointer; text-align: left; font: 400 13px/18px var(--font); color: var(--on-surface-variant); }
.thread button[aria-current="true"] { background: var(--secondary-container); color: var(--on-secondary-container); }
.thread button b { color: var(--on-surface); font-weight: 600; }
.thread button span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick { display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; }

/* ---------- compose ---------- */
.compose { position: fixed; right: 24px; bottom: 0; z-index: 40; width: min(600px, calc(100vw - 32px)); height: min(640px, calc(100vh - 80px));
  display: flex; flex-direction: column; border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--surface-lowest); color: var(--on-surface);
  box-shadow: 0 12px 40px rgba(0,0,0,.35); animation: compose-in .5s var(--ease-spring); transform-origin: bottom right; }
.compose.min { height: 56px; width: 340px; overflow: hidden; }
.compose.max { right: 50%; transform: translateX(50%); bottom: 4vh; width: min(980px, 92vw); height: 90vh; border-radius: var(--r-lg); }
@keyframes compose-in { from { transform: translateY(40px) scale(.94); opacity: 0; } }
.compose-head { display: flex; align-items: center; gap: 4px; height: 56px; padding: 0 8px 0 20px; flex: none; cursor: default;
  background: var(--surface-high); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.compose-head b { flex: 1; font: 620 15px/1 var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-head .saved { font: 400 12px/1 var(--font); color: var(--on-surface-variant); margin-right: 6px; }
.cline { display: flex; align-items: center; gap: 8px; padding: 0 16px; min-height: 46px; border-bottom: 1px solid var(--outline-variant); }
.cline > label { width: 56px; flex: none; font: 500 14px/1 var(--font); color: var(--on-surface-variant); }
.cline input, .cline select { flex: 1; min-width: 0; border: 0; background: none; outline: none; height: 44px; color: var(--on-surface); }
.cline select { cursor: pointer; }
.cline .ibtn { width: 32px; height: 32px; }
.editor { flex: 1; overflow: auto; padding: 14px 18px; outline: none; font: 400 15px/1.55 var(--font); overflow-wrap: anywhere; }
.editor:empty::before { content: attr(data-placeholder); color: var(--on-surface-variant); }
.editor blockquote { margin: 0 0 0 .4em; padding-left: .9em; border-left: 3px solid var(--outline-variant); color: var(--on-surface-variant); }
.ctools { display: flex; align-items: center; gap: 4px; padding: 10px 12px; flex-wrap: wrap; border-top: 1px solid var(--outline-variant); }
.ctools .spacer { flex: 1; }
.ctools .avr-btn { height: 44px; }
.files { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; }
.files .att { padding: 6px 6px 6px 12px; }
.files .att .ibtn { width: 26px; height: 26px; }
.sending .env-flap { animation: flap 1s var(--ease-spring) infinite alternate; transform-origin: 120px 43px; }
@keyframes flap { to { transform: scaleY(-1); } }

/* ---------- settings / admin ---------- */
.page { overflow: auto; padding: 8px 24px 64px; min-height: 0; }
.page-inner { max-width: 880px; margin: 0 auto; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 20px; }
.card { padding: 22px 24px; border-radius: var(--r-lg); background: var(--surface-low); margin-bottom: 16px; }
.card h3 { margin: 0 0 6px; font: 680 18px/24px var(--font); }
.card > p.hint { margin: 0 0 16px; }
.table { width: 100%; border-collapse: collapse; font: 400 14px/20px var(--font); }
.table th { text-align: left; font: 620 12px/16px var(--font); color: var(--on-surface-variant); padding: 8px 10px; border-bottom: 1px solid var(--outline-variant); }
.table td { padding: 10px; border-bottom: 1px solid color-mix(in oklab, var(--outline-variant) 60%, transparent); vertical-align: middle; overflow-wrap: anywhere; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font: 400 14px/20px var(--font); }
.kv dt { color: var(--on-surface-variant); }
.kv dd { margin: 0; }
.secret { padding: 14px 16px; border-radius: var(--r-sm); background: var(--surface-highest); font: 600 18px/1.3 ui-monospace, Consolas, monospace; letter-spacing: .04em; word-break: break-all; user-select: all; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.rule { display: grid; grid-template-columns: 110px 120px 1fr 150px 1fr 40px; gap: 8px; align-items: center; margin-bottom: 8px; }
.rule .input { height: 42px; padding: 0 10px; }
.qr svg { width: 180px; height: 180px; border-radius: var(--r-sm); }
.stat { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat div { padding: 14px 16px; border-radius: var(--r-md); background: var(--surface-mid); }
.stat b { display: block; font: 720 24px/30px var(--font); }
.stat span { font: 400 13px/18px var(--font); color: var(--on-surface-variant); }
.switch { position: relative; width: 52px; height: 32px; flex: none; appearance: none; border-radius: 99px; background: var(--surface-highest);
  box-shadow: inset 0 0 0 2px var(--outline); cursor: pointer; transition: background .25s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 8px; left: 8px; width: 16px; height: 16px; border-radius: 50%; background: var(--outline);
  transition: all .35s var(--ease-spring); }
.switch:checked { background: var(--primary); box-shadow: none; }
.switch:checked::after { left: 24px; top: 4px; width: 24px; height: 24px; background: var(--on-primary); }
.toggle-line { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }

/* ---------- phones: one pane at a time ---------- */
.only-phone { display: none; }
@media (max-width: 1100px) { .panes { grid-template-columns: 220px minmax(280px, 340px) 1fr; } }
@media (max-width: 900px) {
  .only-phone { display: inline-grid; }
  .no-phone { display: none !important; }
  .shell { grid-template-rows: 60px 1fr; }
  .topbar { padding: 0 8px; gap: 6px; }
  .brand .avr-word { display: none; }
  .brand { padding-right: 0; }
  .brand img { width: 40px; }
  .panes { display: block; position: relative; padding: 0; }
  .nav { position: fixed; inset: 0 auto 0 0; z-index: 50; width: 290px; background: var(--surface-low); padding-top: 16px; border-radius: 0 var(--r-lg) var(--r-lg) 0;
    transform: translateX(-105%); transition: transform .45s var(--ease-spring); box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .nav.open { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.4); }
  .listpane, .reader { position: absolute; inset: 0; border-radius: 0; }
  .reader { z-index: 5; animation: slide-in .4s var(--ease-out); }
  .shell:not(.reading) .reader { display: none; }
  .readbody { padding: 14px 16px 90px; }
  .fab { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 30; width: 60px; height: 60px; padding: 0; border-radius: 20px;
    box-shadow: 0 6px 18px rgba(0,0,0,.3); }
  .compose, .compose.max { inset: 0; width: auto; height: auto; transform: none; border-radius: 0; }
  .compose.min { inset: auto 8px 8px 8px; height: 56px; width: auto; border-radius: var(--r-lg); }
  .page { padding: 8px 12px 64px; }
  .grid2 { grid-template-columns: 1fr; }
  .rule { grid-template-columns: 1fr 1fr; }
  .rule .input:nth-child(3), .rule .input:nth-child(5) { grid-column: span 2; }
  .table.responsive thead { display: none; }
  .table.responsive tr { display: grid; padding: 8px 0; border-bottom: 1px solid var(--outline-variant); }
  .table.responsive td { border: 0; padding: 3px 4px; }
  .table.responsive .actions { text-align: left; }
}
@keyframes slide-in { from { transform: translateX(30%); opacity: 0; } }
@media (min-width: 901px) { .fab { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
