/* app.css — the page's look: a dense, quiet mail client in the system font, light and dark. */
*, *::before, *::after { box-sizing: border-box }
:root {
  color-scheme: light dark;
  --bg: #fff; --fg: #1f1f1f; --muted: #5f6368; --line: #e0e3e7; --nav: #f6f8fc; --hover: #f1f3f4; --sel: #e8f0fe;
  --accent: #1a73e8; --accent-fg: #fff; --read: #f6f8fc; --chip: #e8eaed; --danger: #d93025; --star: #f4b400; --ok: #188038;
  --shadow: 0 1px 3px rgba(0,0,0,.22), 0 4px 12px rgba(0,0,0,.08); --radius: 8px;
  --c-primary: #5f6368; --c-social: #1a73e8; --c-promotions: #188038; --c-updates: #e37400; --c-forums: #8430ce; --c-spam: #d93025;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111214; --fg: #e8eaed; --muted: #9aa0a6; --line: #2d2f33; --nav: #18191c; --hover: #202124; --sel: #26324a;
    --accent: #8ab4f8; --accent-fg: #0b1a33; --read: #16171a; --chip: #2d2f33; --danger: #f28b82; --star: #fdd663; --ok: #81c995;
    --shadow: 0 1px 3px rgba(0,0,0,.6), 0 4px 16px rgba(0,0,0,.4); --c-primary: #9aa0a6; --c-social: #8ab4f8; --c-promotions: #81c995; --c-updates: #fcad70; --c-forums: #c58af9; --c-spam: #f28b82 }
}
html, body { margin: 0; height: 100% }
body { font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--fg); overflow: hidden }
a { color: var(--accent); text-decoration: none }
button, input, textarea, select { font: inherit; color: inherit }
button { cursor: pointer }
.muted { color: var(--muted) }
.spacer { flex: 1 }
[hidden] { display: none !important }
h1, h2, h3 { font-weight: 500; margin: 0 }

/* --- buttons */
.btn { border: 1px solid var(--line); background: var(--bg); border-radius: 18px; padding: 6px 14px; line-height: 1.2 }
.btn:hover { background: var(--hover) }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent }
.btn.primary:hover { filter: brightness(1.08) }
.btn.small { padding: 3px 10px; font-size: 13px }
.btn.danger { color: var(--danger) }
.icon { border: 0; background: none; border-radius: 50%; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; color: var(--muted) }
.icon:hover { background: var(--hover); color: var(--fg) }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input:not([type]), textarea, select {
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: var(--bg); color: var(--fg); min-width: 0 }
textarea { width: 100%; resize: vertical; font: inherit }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 0 }
.chip { display: inline-block; background: var(--chip); border-radius: 4px; padding: 0 6px; font-size: 11px; line-height: 18px; margin-right: 4px; font-weight: 500; color: var(--fg); cursor: pointer; vertical-align: middle }
.err { color: var(--danger); min-height: 1.2em; margin: 6px 0 0 }

/* --- login */
.login { height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--nav) }
.login-box { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 32px; width: 340px; max-width: 92vw; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow) }
.login-box h1 { font-size: 28px; margin-bottom: 4px }
.login-box input { padding: 10px }
.login-box .adena { padding: 12px; font-size: 15px }
.login-box .wrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap }
.login-box .wrow .wname { flex: 1; min-width: 120px; padding: 8px }
.login-box .pwlink, .login-box .step, .login-box .gw { font-size: 13px; text-align: center }
.login-box .pwform { display: flex; flex-direction: column; gap: 10px }
.apppw code.pw, code.wallet { font-size: 14px; word-break: break-all; user-select: all }

/* --- the shell */
#app { height: 100vh; display: flex; flex-direction: column }
.top { height: 56px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-bottom: 1px solid var(--line) }
.logo { font-size: 20px; font-weight: 500; color: var(--fg); padding: 0 6px }
.menu-btn { display: none }
.search { display: flex; align-items: center; background: var(--nav); border-radius: 24px; padding: 2px 4px 2px 12px; width: 560px; max-width: 48vw }
.search input { flex: 1; border: 0; background: none; padding: 8px 4px }
.search input:focus { outline: none }
.account { position: relative }
.acct-btn { border: 0; background: none; padding: 6px 10px; border-radius: 16px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.acct-btn:hover { background: var(--hover) }
.account .menu { position: absolute; right: 0; top: 40px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); min-width: 160px; z-index: 30; padding: 4px 0 }
.account .menu a { display: block; padding: 8px 14px; color: var(--fg) }
.account .menu a:hover { background: var(--hover) }
.shell { flex: 1; display: flex; min-height: 0 }
.nav { width: 232px; flex: none; background: var(--nav); overflow-y: auto; padding: 8px 8px 20px }
.compose-btn { width: 100%; padding: 12px; border-radius: 16px; font-weight: 500; margin: 4px 0 12px; box-shadow: var(--shadow); border: 0; background: var(--bg) }
.compose-btn:hover { background: var(--hover) }
.navitem { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 0 16px 16px 0; color: var(--fg); margin-right: 8px }
.navitem:hover { background: var(--hover) }
.navitem.active { background: var(--sel); font-weight: 600 }
.navitem .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.navitem .count { font-size: 12px; font-weight: 600 }
.navitem.small { font-size: 13px; color: var(--muted) }
.dot { width: 10px; height: 10px; border-radius: 3px; background: var(--chip); display: inline-block; flex: none }
.navhead { font-size: 12px; color: var(--muted); padding: 14px 12px 4px; text-transform: uppercase; letter-spacing: .04em }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden }
.loading, .empty { padding: 40px; text-align: center; color: var(--muted) }

/* --- the list */
.listhead { display: flex; align-items: center; gap: 4px; padding: 6px 12px; border-bottom: 1px solid var(--line); min-height: 48px; flex: none }
.listhead .chk { display: inline-flex; padding: 6px }
.viewtitle { font-weight: 500; padding: 0 8px }
.bulk { display: flex; gap: 2px; align-items: center }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; overflow-x: auto }
.tab { padding: 10px 18px; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; display: flex; gap: 8px; align-items: center; min-width: 120px }
.tab:hover { background: var(--hover) }
.tab.active { color: var(--fg); font-weight: 600 }
.tab[data-cat=primary].active { border-color: var(--c-primary) } .tab[data-cat=social].active { border-color: var(--c-social) }
.tab[data-cat=promotions].active { border-color: var(--c-promotions) } .tab[data-cat=updates].active { border-color: var(--c-updates) } .tab[data-cat=forums].active { border-color: var(--c-forums) }
.tab .count { font-size: 12px; background: var(--chip); border-radius: 10px; padding: 0 7px; font-weight: 600 }
.rows { flex: 1; overflow-y: auto; outline: none }
.row { display: flex; align-items: center; gap: 6px; padding: 0 8px 0 12px; height: 40px; border-bottom: 1px solid var(--line); cursor: pointer; background: var(--read); position: relative }
.row.unread { background: var(--bg); font-weight: 600 }
.row:hover { box-shadow: inset 0 -1px 0 var(--line), 0 1px 3px rgba(0,0,0,.25); z-index: 1 }
.row.cursor { box-shadow: inset 3px 0 0 var(--accent) }
.row.selected { background: var(--sel) }
.row .chk { display: inline-flex; padding: 6px }
.row .star { border: 0; background: none; color: var(--muted); font-size: 18px; width: 28px; height: 28px; border-radius: 50%; opacity: .55 }
.row .star.on, .msg .star.on { color: var(--star); opacity: 1 }
.row .star:hover { opacity: 1; background: var(--hover) }
.row .from { width: 190px; flex: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis }
.row .from .n { color: var(--muted); font-weight: 400; font-size: 12px }
.row .imp { color: var(--c-updates); font-size: 16px; width: 12px; opacity: 0 }
.row .imp.on { opacity: 1 }
.row .text { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis }
.row .snippet { color: var(--muted); font-weight: 400 }
.row .needs { width: 8px; height: 8px; border-radius: 50%; background: var(--c-social); flex: none; margin-right: 2px }
.row .clip { color: var(--muted); font-size: 13px; width: 16px; flex: none }
.row .date { flex: none; width: 76px; text-align: right; font-size: 12px; white-space: nowrap }
.row:hover::after { content: attr(data-catname); position: absolute; right: 90px; top: 11px; font-size: 11px; color: var(--muted); font-weight: 400; display: none }
.row[data-cat]:hover::after { display: block }
.row.draft .from { color: var(--danger) }
.sentinel { height: 1px }

/* --- the thread */
.thread { flex: 1; overflow-y: auto; padding-bottom: 40px }
.threadbar { display: flex; align-items: center; gap: 2px; padding: 6px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 2 }
.thread .subject { font-size: 22px; padding: 16px 24px 8px; font-weight: 400 }
.thread .subject .chip { font-size: 12px; vertical-align: middle }
.msgs { padding: 0 8px }
.msg { border: 1px solid var(--line); border-radius: 8px; margin: 8px 8px; background: var(--bg) }
.msg.collapsed .msgbody, .msg.collapsed .atts, .msg.collapsed .ailine, .msg.collapsed .to { display: none }
.msg.collapsed .msghead { cursor: pointer }
.msg.collapsed .snip { display: inline }
.msghead { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px }
.msghead .snip { display: none; flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); padding-top: 2px }
.avatar { width: 36px; height: 36px; border-radius: 50%; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; flex: none }
.who { flex: 1; min-width: 0 }
.who .addr { font-size: 12px }
.who .to { font-size: 12px }
.msgdate { font-size: 12px; white-space: nowrap; padding-top: 2px }
.msg .star { border: 0; background: none; font-size: 18px; color: var(--muted); width: 28px; height: 28px; opacity: .55 }
.ailine { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 0 14px 8px 60px; font-size: 12px; color: var(--muted) }
.ailine .cat { font-weight: 600; text-transform: uppercase; letter-spacing: .03em; font-size: 11px }
.cat-primary { color: var(--c-primary) } .cat-social { color: var(--c-social) } .cat-promotions { color: var(--c-promotions) } .cat-updates { color: var(--c-updates) } .cat-forums { color: var(--c-forums) } .cat-spam { color: var(--c-spam) }
.ailine .needs { color: var(--c-social); font-weight: 600 }
.ailine .movecat { font-size: 12px; padding: 2px 6px; border-radius: 12px; margin-left: auto }
.ailine .summary { width: 100%; font-style: italic }
.msgbody { padding: 0 14px 8px 60px }
.msgbody iframe { width: 100%; border: 0; height: 80px; display: block; background: #fff; border-radius: 4px }
.btn-images { margin-top: 6px }
.atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 14px 14px 60px }
.atts .att { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; color: var(--fg); font-size: 13px; display: inline-flex; gap: 8px; align-items: center }
.atts .att:hover { background: var(--hover) }
.atts .att .sz { color: var(--muted); font-size: 12px }
.ai-out { margin: 8px 24px; padding: 12px 16px; background: var(--nav); border-radius: 8px; font-size: 14px }
.ai-out ul { margin: 6px 0 0; padding-left: 18px }
.ai-out .rchip { margin: 6px 6px 0 0; padding: 6px 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg); text-align: left }
.ai-out .rchip:hover { background: var(--hover) }
.threadfoot { padding: 8px 24px }
.replybtns { display: flex; gap: 8px; padding: 8px 0 }

/* --- popups, toasts, sheets */
.popup { position: absolute; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); z-index: 40; min-width: 180px; max-height: 60vh; overflow-y: auto; padding: 4px 0 }
.popup .mitem { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 14px }
.popup .mitem:hover { background: var(--hover) }
.popup .mhead { padding: 6px 14px; font-size: 12px; color: var(--muted) }
.popup .mrow { padding: 6px 10px }
.popup hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0 }
#toasts { position: fixed; left: 24px; bottom: 24px; z-index: 50; display: flex; flex-direction: column; gap: 8px }
.toast { background: #202124; color: #fff; border-radius: 8px; padding: 10px 8px 10px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); max-width: 420px }
.toast .taction { border: 0; background: none; color: #8ab4f8; font-weight: 600; padding: 4px 8px }
.toast .tclose { color: #ccc; width: 26px; height: 26px }
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 45; display: flex; align-items: center; justify-content: center }
.sheet { background: var(--bg); border-radius: 12px; padding: 20px 24px; width: 560px; max-width: 94vw; max-height: 85vh; overflow: auto; box-shadow: var(--shadow) }
.sheet h2 { margin-bottom: 10px }
.sheet table { border-collapse: collapse; width: 100% }
.sheet td { padding: 3px 8px; border-bottom: 1px solid var(--line) }
.sheet kbd { background: var(--chip); border-radius: 4px; padding: 1px 6px; font-family: inherit; font-size: 12px; margin-right: 2px }

/* --- the composer */
#dock { position: fixed; right: 24px; bottom: 0; display: flex; gap: 12px; align-items: flex-end; z-index: 35 }
.composer { width: 540px; max-width: 96vw; background: var(--bg); border: 1px solid var(--line); border-radius: 8px 8px 0 0; box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: 85vh }
.composer.inline { width: auto; max-width: none; border-radius: 8px; box-shadow: none; margin-top: 4px }
.chead { display: flex; align-items: center; padding: 6px 8px 6px 14px; background: var(--nav); border-radius: 8px 8px 0 0; font-weight: 500 }
.composer.inline .chead { background: var(--nav) }
.frow { display: flex; align-items: center; gap: 8px; padding: 4px 14px; border-bottom: 1px solid var(--line); position: relative }
.frow .flabel { color: var(--muted); width: 54px; flex: none; font-size: 13px }
.frow input { flex: 1; border: 0; background: none; padding: 6px 0 }
.frow input:focus { outline: none }
.frow .reveals { font-size: 13px }
.composer .body { flex: 1; border: 0; border-radius: 0; min-height: 180px; padding: 10px 14px; resize: none }
.composer .body:focus { outline: none }
.catts { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px }
.catt { border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center }
.catt button { border: 0; background: none; color: var(--muted); padding: 0 }
.cfoot { display: flex; align-items: center; gap: 8px; padding: 10px 14px }
.cfoot .status { font-size: 12px; color: var(--muted); margin-left: auto }
.ac { position: absolute; left: 70px; top: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); z-index: 60; min-width: 260px; padding: 4px 0 }
.acitem { padding: 8px 12px; cursor: pointer }
.acitem.active, .acitem:hover { background: var(--sel) }

/* --- settings and admin */
.page { flex: 1; overflow-y: auto; padding: 16px 32px 60px; max-width: 920px }
.page h1 { font-size: 22px; padding: 8px 0 16px }
.page h2 { font-size: 16px; padding: 24px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 12px }
.srow { display: flex; gap: 16px; padding: 8px 0; align-items: flex-start }
.srow .slabel { width: 200px; flex: none; padding-top: 6px; color: var(--muted) }
.srow .sfield { flex: 1; min-width: 0 }
.srow .sfield input:not([type=checkbox]), .srow .sfield select { width: 100%; max-width: 420px }
.hint { font-size: 12px; margin-top: 4px }
.rule { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line) }
.rule .desc { flex: 1 }
.rule .rtext { display: block; font-size: 12px }
.rule.off .desc { color: var(--muted); text-decoration: line-through }
.addrule { display: flex; gap: 8px; margin: 12px 0 }
.addrule input { flex: 1 }
.rulepreview, .ruleform { background: var(--nav); border-radius: 8px; padding: 12px 16px; margin: 8px 0 }
.ruleform .grid { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; align-items: center; margin-top: 8px }
.ruleform .grid input[type=text], .ruleform .grid select { width: 100% }
.ruleform .acts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px }
.ruleform .acts label { display: inline-flex; gap: 4px; align-items: center }
.ruleform .fbtns { display: flex; gap: 8px; margin-top: 12px }
.explain { font-style: italic; margin-bottom: 6px }
table.plain { border-collapse: collapse; width: 100% }
table.plain th, table.plain td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top }
table.plain th { color: var(--muted); font-weight: 500; font-size: 12px }
.rec.ok .st { color: var(--ok) } .rec.missing .st { color: var(--danger) }
.rec .val { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; max-width: 420px }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px }
.stat { background: var(--nav); border-radius: 8px; padding: 10px 12px }
.stat b { display: block; font-size: 20px; font-weight: 500 }
.stat span { font-size: 12px; color: var(--muted) }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 }
.labels-list .lrow { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line) }

/* --- phones */
@media (max-width: 700px) {
  .menu-btn { display: inline-flex }
  .nav { position: fixed; left: 0; top: 56px; bottom: 0; transform: translateX(-100%); transition: transform .2s; z-index: 20; box-shadow: var(--shadow); width: 260px }
  .nav.open { transform: none }
  .logo { display: none }
  .search { flex: 1; max-width: none }
  .acct-btn { max-width: 90px }
  .row { padding-left: 4px }
  .row .from { width: 110px }
  .row .date { width: 54px }
  .row .chk, .row .imp { display: none }
  .thread .subject { font-size: 18px; padding: 12px 16px 6px }
  .msgs { padding: 0 }
  .msg { margin: 6px 4px }
  .msghead { padding: 10px }
  .ailine, .msgbody, .atts { padding-left: 10px }
  .msgdate { display: none }
  .threadfoot { padding: 8px 10px }
  .tab { min-width: 0; padding: 10px 12px }
  .tab .tabname { font-size: 13px }
  .viewtitle { display: none }
  #dock { right: 0; left: 0 }
  .composer:not(.inline) { position: fixed; inset: 0; width: auto; max-width: none; max-height: none; border-radius: 0 }
  .composer:not(.inline) .body { min-height: 0 }
  .page { padding: 12px 16px 60px }
  .srow { flex-direction: column; gap: 4px }
  .srow .slabel { width: auto; padding-top: 0 }
  #toasts { left: 12px; right: 12px; bottom: 12px }
}
