/* FantiLabs Mail: mesma base visual do site (cobalto + papel, Bricolage + Geist). */
@font-face { font-family: 'Bricolage Grotesque Variable'; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(/fonts/bricolage-grotesque-latin-wght-normal.woff2) format('woff2-variations'); }
@font-face { font-family: 'Geist Variable'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/fonts/geist-latin-wght-normal.woff2) format('woff2-variations'); }

:root {
  --paper: #F2F2EE;
  --panel: #F8F8F5;
  --card: #FFFFFF;
  --ink: #12141F;
  --ink-2: #4E5269;
  --ink-3: #63677E;
  --line: #D5D7E0;
  --line-2: #E7E8EF;
  --accent: #2B36E6;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3E5FD;
  --warn: #B3261E;
  --ok: #137A43;
  --star: #B07A00;
  --radius: 14px;
  --serif: 'Bricolage Grotesque Variable', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --sans: 'Geist Variable', 'Helvetica Neue', 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0E1020;
    --panel: #12152A;
    --card: #181B33;
    --ink: #EEEFF7;
    --ink-2: #B9BDD6;
    --ink-3: #A7ABC6;
    --line: #2A2E4D;
    --line-2: #20243F;
    --accent: #9CA3FF;
    --accent-ink: #0E1020;
    --accent-soft: #23285A;
    --warn: #FF9A8F;
    --ok: #6FD49B;
    --star: #F0C35A;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--sans); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--warn); }
.btn.wide { width: 100%; }
.btn.small { height: 30px; padding: 0 11px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0;
  background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 13px; }
.link:hover { text-decoration: underline; }

/* ---------- marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 26px; height: 22px; flex: none; background: center / contain no-repeat url(/logo-256.png); }
.brand-name { font-family: var(--serif); font-size: 19px; font-weight: 700; letter-spacing: -.03em; }
.brand.big .brand-mark { width: 38px; height: 32px; }
.brand.big .brand-name { font-size: 26px; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); }
.login-lead { color: var(--ink-2); margin: 18px 0 28px; font-size: 15px; }
.login-card label { display: block; font-weight: 500; margin-bottom: 6px; }
.login-card input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); margin-bottom: 12px; }
.login-card .btn { height: 42px; }
.login-msg { min-height: 1.4em; margin-top: 16px; color: var(--ink-2); word-break: break-all; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 248px minmax(320px, 400px) 1fr; height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  padding: 18px 14px; gap: 6px; overflow-y: auto; }
.sidebar .brand { padding: 2px 6px 14px; }
.compose-btn { margin-bottom: 14px; height: 40px; }
.folders, .aliases { display: flex; flex-direction: column; gap: 1px; }
.folder, .alias-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 7px; cursor: pointer; color: var(--ink-2); }
.folder:hover, .alias-item:hover { background: var(--line-2); color: var(--ink); }
.folder.active, .alias-item.active { background: var(--accent-soft); color: var(--ink); font-weight: 500; }
.alias-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.alias-item.off span { text-decoration: line-through; opacity: .6; }
.count { font-weight: 600; font-size: 12px; color: var(--accent); }
.section-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 10px 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 14px 6px 0; display: flex; flex-direction: column; gap: 12px; font-size: 12px; color: var(--ink-3); }
.quota { display: flex; flex-direction: column; gap: 5px; }
.quota-bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.quota-bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.me { display: flex; justify-content: space-between; gap: 8px; }
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- lista ---------- */
.list-pane { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-width: 0; background: var(--paper); }
.list-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list-head h1 { font-family: var(--serif); font-weight: 700; letter-spacing: -.02em; font-size: 22px; margin: 0; flex: 1; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { flex-basis: 100%; }
.search input { width: 100%; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }
.msg-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.msg { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 16px 12px 20px; border-bottom: 1px solid var(--line-2);
  cursor: pointer; position: relative; }
.msg:hover { background: var(--panel); }
.msg.sel { background: var(--accent-soft); }
.msg.unread::before { content: ''; position: absolute; left: 8px; top: 18px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.msg .who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.unread .who, .msg.unread .subj { font-weight: 600; color: var(--ink); }
.msg .when { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.msg .subj { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.msg .snip { grid-column: 1 / -1; color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .tags { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; margin-top: 3px; }
.tag { font-size: 11px; padding: 2px 9px; border-radius: 20px; background: var(--line-2); color: var(--ink-2); }
.ico-star { color: var(--star); width: 13px; height: 13px; }
.ico-clip { color: var(--ink-3); width: 13px; height: 13px; }
.list-empty { padding: 48px 24px; text-align: center; color: var(--ink-3); }
.list-foot { padding: 10px; text-align: center; }

/* ---------- leitura ---------- */
.reader { overflow-y: auto; background: var(--panel); min-width: 0; }
.reader-empty { height: 100%; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--ink-3); }
.reader-empty svg { width: 64px; height: 48px; fill: none; stroke: var(--line); stroke-width: 2; }
.reader-body { max-width: 860px; margin: 0 auto; padding: 22px 28px 60px; }
.thread-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.thread-head h2 { font-family: var(--serif); font-weight: 700; letter-spacing: -.02em; font-size: 24px; line-height: 1.25; margin: 0; flex: 1; letter-spacing: -.01em; word-break: break-word; }
.thread-actions { display: flex; gap: 2px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.card-head { display: flex; gap: 12px; padding: 14px 18px; align-items: flex-start; cursor: pointer; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px;
  background: var(--accent-soft); color: var(--accent); flex: none; text-transform: uppercase; }
.card-meta { flex: 1; min-width: 0; }
.card-meta .from { font-weight: 600; }
.card-meta .from small { font-weight: 400; color: var(--ink-3); margin-left: 4px; }
.card-meta .to { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta .snip { color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-date { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.card-body { padding: 0 18px 16px; }
.card.collapsed .card-body { display: none; }
.card:not(.collapsed) .card-meta .snip { display: none; }
.mail-frame { width: 100%; border: 0; display: block; min-height: 60px; background: #fff; border-radius: 6px; }
.mail-text { white-space: pre-wrap; word-break: break-word; margin: 0; font: inherit; }
.img-note { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-2); background: var(--line-2);
  padding: 7px 12px; border-radius: 7px; margin-bottom: 10px; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.att { display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; color: var(--ink); font-size: 13px; max-width: 280px; background: var(--panel); }
.att:hover { border-color: var(--ink-3); }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att small { color: var(--ink-3); }
.card-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- dialogs ---------- */
.sheet { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--card); color: var(--ink);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 24px 60px rgba(20, 18, 12, .22); }
.sheet::backdrop { background: rgba(21, 20, 15, .35); }
.sheet.compose { width: min(720px, calc(100vw - 24px)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px 20px; }
.sheet-head h2 { font-family: var(--serif); font-weight: 700; letter-spacing: -.02em; font-size: 20px; margin: 0; }
.field-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line-2); padding: 0 20px; }
.field-row label { width: 56px; color: var(--ink-3); font-size: 13px; flex: none; }
.field-row input, .field-row select { flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; outline: none; }
.compose textarea { display: block; width: 100%; border: 0; resize: vertical; padding: 14px 20px; background: transparent;
  outline: none; line-height: 1.55; min-height: 220px; }
.att-chips { list-style: none; margin: 0; padding: 0 20px; display: flex; flex-wrap: wrap; gap: 6px; }
.att-chips li { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: var(--line-2); padding: 3px 4px 3px 10px; border-radius: 20px; }
.att-chips button { border: 0; background: none; cursor: pointer; color: var(--ink-3); padding: 0 4px; font-size: 15px; line-height: 1; }
.sheet-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px 18px; }
.file-btn { cursor: pointer; }
.compose-err, .form-err { color: var(--warn); font-size: 13px; }
.alias-new { display: flex; flex-direction: column; gap: 10px; padding: 4px 20px 16px; border-bottom: 1px solid var(--line-2); }
.alias-new > input, .addr-input { height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.alias-new > input { padding: 0 12px; }
.addr-input { display: flex; align-items: center; overflow: hidden; }
.addr-input input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; padding: 0 4px 0 12px; outline: none; text-align: right; }
.addr-input span { color: var(--ink-3); }
.addr-input select { height: 100%; border: 0; background: transparent; padding: 0 10px 0 4px; outline: none; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.alias-new .btn { align-self: flex-start; }
.form-err { margin: 0; min-height: 1em; }
.alias-edit { list-style: none; margin: 0; padding: 6px 20px; }
.alias-edit li { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.alias-edit .addr { font-weight: 600; word-break: break-all; }
.alias-edit input[type=text] { grid-column: 1 / -1; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.alias-edit .row { grid-column: 1 / -1; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--ink-3); padding: 6px 20px 20px; margin: 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 10; }

.only-mobile { display: none; }
.reader-back { display: none; }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 220px 1fr; }
  .reader { display: none; }
  .app.reading .list-pane { display: none; }
  .app.reading .reader { display: block; }
  .reader-back { display: inline-grid; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-grid; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 5; transform: translateX(-100%); transition: transform .2s;
    box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .app.menu .sidebar { transform: none; }
  .reader-body { padding: 16px 14px 60px; }
}

/* ---------- admin ---------- */
.admin-page { overflow-y: auto; }
.admin { max-width: 980px; margin: 0 auto; padding: 18px 20px 80px; }
.admin-bar { display: flex; align-items: center; gap: 18px; padding: 6px 0 18px; border-bottom: 1px solid var(--line); }
.admin-bar .brand { flex: 1; }
.admin-sec { padding: 26px 0 8px; }
.admin-sec h2 { font-family: var(--serif); font-weight: 700; font-size: 24px; letter-spacing: -.03em; margin: 0 0 4px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.admin-sec > .muted { margin: 0 0 14px; max-width: 70ch; }
.admin input, .admin select { height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); min-width: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input:first-child { flex: 1 1 220px; }
.grid-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }
.grid-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.pass-row { display: flex; gap: 6px; }
.pass-row input { flex: 1; font-family: ui-monospace, Consolas, monospace; }
.rows { list-style: none; margin: 12px 0 0; padding: 0; }
.rows li { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.link.danger { color: var(--warn); }
.accounts { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.acct { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.acct.off { opacity: .7; }
.acct-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.acct-head b { font-size: 16px; }
.acct-actions { margin-left: auto; display: flex; gap: 14px; }
.tag.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.alias-rows { list-style: none; margin: 10px 0; padding: 0; }
.alias-rows li { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 6px 0; }
.alias-rows .addr { font-weight: 600; word-break: break-all; }
.alias-rows li.off .addr { text-decoration: line-through; opacity: .6; }
.add-alias { padding-top: 10px; border-top: 1px dashed var(--line); }
.add-alias input[name=local] { flex: 0 1 140px; text-align: right; }
@media (max-width: 760px) {
  .grid-form { grid-template-columns: 1fr; }
  .alias-rows li { grid-template-columns: 1fr auto; }
  .alias-rows li input { grid-column: 1 / -1; grid-row: 2; }
  .acct-actions { margin-left: 0; }
}
