:root {
  --bg: #F3F6F4; --surface: #FFFFFF; --sunk: #EBF1ED;
  --ink: #0E1C17; --ink-2: #4E5E57; --ink-3: #84928B; --line: #DCE5E0;
  --brand: #02BE56; --brand-2: #3EE089; --brand-text: #04803D; --brand-soft: #DAF5E5;
  --forest: #071C16; --forest-2: #0C2B22; --on-forest: #E9F6EF; --on-forest-2: #9DC2B2;
  --danger: #D9364A; --danger-soft: #FCE6E9;
  --shadow: 0 1px 2px rgba(7,28,22,.06), 0 10px 30px -16px rgba(7,28,22,.22);
  --shadow-lg: 0 2px 6px rgba(7,28,22,.08), 0 26px 56px -24px rgba(7,28,22,.34);
  --f-display: "Bricolage Grotesque", "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --f-body: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --r-sm: 10px; --r: 16px; --r-lg: 26px; --ease: cubic-bezier(.22,1,.36,1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #050F0C; --surface: #0B1A15; --sunk: #0E211A;
    --ink: #E7F1EC; --ink-2: #A1B3AB; --ink-3: #6B7F77; --line: #1B332B;
    --brand-text: #46DE8E; --brand-soft: #0F3826;
    --forest: #04120E; --forest-2: #0A251C; --on-forest-2: #8DB5A5;
    --danger-soft: #3A1419;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 14px 34px -16px rgba(0,0,0,.6);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.5), 0 28px 60px -24px rgba(0,0,0,.72);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #050F0C; --surface: #0B1A15; --sunk: #0E211A;
  --ink: #E7F1EC; --ink-2: #A1B3AB; --ink-3: #6B7F77; --line: #1B332B;
  --brand-text: #46DE8E; --brand-soft: #0F3826;
  --forest: #04120E; --forest-2: #0A251C; --on-forest-2: #8DB5A5;
  --danger-soft: #3A1419;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 14px 34px -16px rgba(0,0,0,.6);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.5), 0 28px 60px -24px rgba(0,0,0,.72);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 500 14.5px/1.5 var(--f-body); -webkit-font-smoothing: antialiased;
  caret-color: var(--brand);
}
::selection { background: var(--brand-soft); color: var(--ink); }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.err { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; font-size: 13px; }

/* botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px; border: 0; font-weight: 650;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .2s;
  white-space: nowrap;
}
.btn.sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn-brand { background: linear-gradient(180deg, var(--brand-2), var(--brand)); color: #03210F; box-shadow: 0 1px 0 rgba(255,255,255,.35) inset, 0 8px 22px -10px rgba(2,190,86,.7); }
.btn-brand:hover { transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255,255,255,.35) inset, 0 14px 28px -12px rgba(2,190,86,.8); }
.btn-brand:active { transform: translateY(0) scale(.98); }
.btn-soft { background: var(--sunk); color: var(--ink); }
.btn-soft:hover { background: var(--brand-soft); color: var(--brand-text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 999px; border: 0; background: transparent; color: var(--ink-2); transition: background .2s, color .2s, transform .4s var(--ease); }
.icon-btn:hover { background: var(--sunk); color: var(--ink); }
.ghost { background: transparent; border: 0; color: var(--on-forest-2); display: inline-flex; gap: 8px; align-items: center; padding: 8px 12px; border-radius: 999px; font-weight: 600; }
.ghost:hover { background: rgba(255,255,255,.06); color: var(--on-forest); }

/* login */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(600px 380px at 50% 18%, rgba(2,190,86,.22), transparent 70%),
    radial-gradient(circle at 1px 1px, rgba(255,255,255,.07) 1px, transparent 0) 0 0 / 22px 22px,
    var(--forest);
}
.login-card {
  width: min(400px, 100%); padding: 36px 30px 26px; border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.09); color: var(--on-forest);
  box-shadow: 0 2px 6px rgba(0,0,0,.3), 0 40px 80px -30px rgba(0,0,0,.7);
  backdrop-filter: blur(14px); text-align: center;
}
.login-card h1 { font: 800 30px/1.1 var(--f-display); letter-spacing: -.03em; margin: 18px 0 4px; }
.login-card .muted { color: var(--on-forest-2); margin: 0 0 24px; }
.login .field { display: grid; gap: 6px; text-align: left; margin-bottom: 14px; }
.login .field span { font-size: 12.5px; color: var(--on-forest-2); font-weight: 600; }
.login input {
  height: 46px; border-radius: 14px; border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.25);
  padding: 0 16px; color: var(--on-forest); outline: none; transition: border-color .2s, box-shadow .2s;
}
.login input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(2,190,86,.18); }
.login-foot { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 18px 0 0; font-size: 12.5px; color: var(--on-forest-2); }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; box-shadow: 0 6px 18px -8px rgba(2,190,86,.6); flex: none; }
.brand-mark img { width: 100%; height: 100%; display: block; }
.brand-mark.big { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto; }

/* layout */
.app { display: grid; grid-template-columns: 252px minmax(300px, 380px) 1fr; height: 100dvh; }
.side {
  background:
    radial-gradient(320px 260px at 0% 0%, rgba(2,190,86,.18), transparent 70%),
    radial-gradient(circle at 1px 1px, rgba(255,255,255,.05) 1px, transparent 0) 0 0 / 20px 20px,
    var(--forest);
  color: var(--on-forest); display: flex; flex-direction: column; padding: 20px 14px; gap: 22px; min-height: 0;
}
.brand-row { display: flex; gap: 12px; align-items: center; padding: 2px 6px 18px; }
.brand-row strong { font: 800 19px/1 var(--f-display); letter-spacing: -.02em; display: block; }
.brand-row span { font-size: 12px; color: var(--on-forest-2); letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
.folders { display: grid; gap: 4px; }
.folder {
  display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 14px; border-radius: 999px;
  border: 0; background: transparent; color: var(--on-forest-2); font-weight: 600; text-align: left;
  transition: background .2s, color .2s;
}
.folder span { flex: 1; }
.folder b { font: 600 12px var(--f-mono); color: var(--on-forest-2); }
.folder b.hot { background: var(--brand); color: #03210F; padding: 2px 8px; border-radius: 999px; }
.folder:hover { background: rgba(255,255,255,.05); color: var(--on-forest); }
.folder.on { background: rgba(2,190,86,.16); color: var(--on-forest); box-shadow: inset 0 0 0 1px rgba(62,224,137,.22); }
.eyebrow { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--on-forest-2); font-weight: 700; margin: 0 8px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px; }
.chip {
  border: 1px solid rgba(255,255,255,.1); background: transparent; color: var(--on-forest-2);
  border-radius: 999px; padding: 6px 12px; font: 600 12px var(--f-mono); transition: all .2s;
}
.chip:hover { color: var(--on-forest); border-color: rgba(255,255,255,.2); }
.chip.on { background: var(--on-forest); color: var(--forest); border-color: transparent; }
.side-foot { margin-top: auto; display: flex; justify-content: space-between; }

.list-pane { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.list-head { padding: 22px 18px 14px; display: grid; gap: 14px; border-bottom: 1px solid var(--line); }
.list-title { display: flex; align-items: center; justify-content: space-between; }
.list-title h2 { font: 800 28px/1 var(--f-display); letter-spacing: -.03em; margin: 0; }
.list-title .icon-btn.spin { transform: rotate(360deg); }
.search { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 14px; border-radius: 999px; background: var(--sunk); color: var(--ink-3); transition: box-shadow .2s; }
.search:focus-within { box-shadow: 0 0 0 2px var(--brand); }
.search input { flex: 1; border: 0; background: transparent; outline: none; min-width: 0; color: var(--ink); }

.list { list-style: none; margin: 0; padding: 8px; overflow: auto; flex: 1; }
.item {
  display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 12px; border-radius: 14px;
  cursor: pointer; position: relative; transition: background .2s, transform .3s var(--ease), box-shadow .3s var(--ease);
}
.item:hover { background: var(--sunk); }
.item.on { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.item .top { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; min-width: 0; }
.item .who { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item time { font: 500 11.5px var(--f-mono); color: var(--ink-3); flex: none; }
.item .subj { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-weight: 550; }
.item .snip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-3); font-size: 13px; }
.item .tags { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.tag { font: 600 10.5px var(--f-mono); color: var(--brand-text); background: var(--brand-soft); padding: 2px 8px; border-radius: 999px; }
.item.unread .who, .item.unread .subj { font-weight: 800; }
.item.unread::after { content: ""; position: absolute; right: 12px; bottom: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px rgba(2,190,86,.15); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font: 700 14px var(--f-display); color: var(--forest); background: var(--av, var(--brand-soft));
}
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }
.list-empty { text-align: center; padding: 56px 20px; color: var(--ink-3); }
.list-empty .ic { width: 34px; height: 34px; color: var(--brand); margin-bottom: 8px; }

.reader { min-width: 0; display: flex; flex-direction: column; background: var(--bg); min-height: 0;
  background-image: radial-gradient(circle at 1px 1px, color-mix(in oklab, var(--ink) 7%, transparent) 1px, transparent 0); background-size: 22px 22px; }
.empty { margin: auto; text-align: center; padding: 24px; }
.empty h3 { font: 800 22px var(--f-display); letter-spacing: -.02em; margin: 16px 0 4px; }
.empty-art { width: 92px; height: 92px; border-radius: 28px; margin: 0 auto; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow-lg); color: var(--brand); }
.empty-art .ic { width: 40px; height: 40px; stroke-width: 1.5; }
#reader-view { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.reader-bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 12px 20px;
  background: color-mix(in oklab, var(--bg) 78%, transparent); backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.reader-scroll { overflow: auto; flex: 1; padding: 28px clamp(16px, 4vw, 48px) 48px; }
.r-subject { font: 800 clamp(24px, 3vw, 34px)/1.12 var(--f-display); letter-spacing: -.03em; margin: 0 0 20px; overflow-wrap: anywhere; }
.r-meta { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 16px; }
.r-who { flex: 1; display: grid; min-width: 0; }
.r-who strong { font-weight: 750; }
.r-who > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-who .mono { font-size: 12.5px; color: var(--ink-2); }
.r-who .muted { font-size: 12.5px; }
.r-meta time { font-size: 12px; align-self: flex-start; }
.guard { display: flex; gap: 10px; align-items: center; padding: 10px 12px 10px 16px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-text); font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.guard span { flex: 1; }
.r-body-wrap { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
#r-frame { width: 100%; border: 0; display: block; min-height: 200px; background: #fff; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.att { display: inline-flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 600; transition: transform .25s var(--ease), box-shadow .25s; }
.att:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.att small { font-family: var(--f-mono); color: var(--ink-3); }
.only-mobile { display: none; }

/* compose */
.compose-wrap { position: fixed; inset: 0; z-index: 20; display: grid; place-items: end end; padding: 24px; background: rgba(4,14,11,.32); backdrop-filter: blur(3px); animation: fade .25s var(--ease); }
.compose {
  width: min(560px, 100%); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg), 0 0 0 1px var(--line);
  padding: 8px 20px 18px; display: grid; animation: pop .45s var(--ease);
}
.compose header { display: flex; align-items: center; justify-content: space-between; padding: 10px 0 6px; }
.compose h3 { font: 800 20px var(--f-display); letter-spacing: -.02em; margin: 0; }
.compose .row { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); height: 46px; }
.compose .row span { width: 64px; color: var(--ink-3); font-size: 13px; font-weight: 600; }
.compose .row input, .compose .row select { flex: 1; border: 0; background: transparent; outline: none; height: 100%; min-width: 0; }
.compose .row select { font-family: var(--f-mono); font-size: 13px; }
.compose textarea { border: 0; outline: none; background: var(--sunk); border-radius: var(--r); padding: 14px 16px; margin-top: 14px; resize: vertical; min-height: 200px; line-height: 1.6; }
.compose footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.compose footer .err { margin: 0; flex: 1; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; background: var(--forest); color: var(--on-forest); padding: 12px 20px; border-radius: 999px; box-shadow: var(--shadow-lg); font-weight: 600; animation: pop .4s var(--ease); max-width: calc(100% - 32px); }

/* movimento */
.rise { animation: rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* responsivo */
@media (max-width: 1080px) { .app { grid-template-columns: 220px minmax(280px, 340px) 1fr; } }
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .list-pane { min-width: 0; }
  .brand-row span { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .compose-btn { height: 38px; padding: 0 14px; }
  .r-meta { flex-wrap: wrap; }
  .r-meta time { order: 3; width: 100%; padding-left: 62px; margin-top: -6px; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 10px; }
  .side-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: 1; min-width: 0; order: 0; }
  .brand-row { padding: 0; }
  .compose-btn { width: auto; }
  .side-foot { order: 1; margin: 0; gap: 2px; }
  .side-foot .ghost { padding: 8px; }
  .side-foot .ghost:last-child { font-size: 0; gap: 0; }
  .folders { order: 2; display: flex; width: 100%; overflow-x: auto; }
  .folder { flex: none; height: 38px; }
  .boxes { display: none; }
  .list-pane { border-right: 0; }
  .reader { position: fixed; inset: 0; z-index: 10; transform: translateX(100%); transition: transform .45s var(--ease); }
  .app.reading .reader { transform: none; }
  .only-mobile { display: grid; }
  .bar-actions .btn span, .bar-actions .btn-soft:nth-child(3) { display: none; }
  .bar-actions { margin-left: auto; }
  .reader-bar { padding: 10px 16px; }
  .reader-scroll { padding: 20px 16px 40px; }
  .compose-wrap { padding: 0; place-items: end stretch; }
  .compose { border-radius: var(--r-lg) var(--r-lg) 0 0; width: 100%; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
}
