:root {
  --page: #dbdbd8;
  --shell: #f9f9f8;
  --card: #ffffff;
  --ink: #1c1c1a;
  --ink-2: #4a4a46;
  --muted: #85857f;
  --line: #e9e9e6;
  --soft: #f1f1ee;
  --accent: #1f7a5c;
  --accent-soft: #e4f1ec;
  --warn: #b4532a;
  --warn-soft: #fbece4;
  --danger: #b3261e;
  --radius: 22px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--page); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }

/* ------------------------------------------------------------ shell */
.shell { height: 100vh; height: 100dvh; padding: 14px; display: grid; grid-template-columns: 78px minmax(0, 1fr); }
.frame { grid-column: 1 / -1; display: grid; grid-template-columns: 78px minmax(0, 1fr); background: var(--shell); border-radius: 30px; overflow: hidden; box-shadow: 0 1px 0 #fff inset, 0 8px 30px rgba(0,0,0,.06); min-height: 0; }
.rail { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 0 14px; overflow-y: auto; }
.logo { width: 42px; height: 42px; border-radius: 13px; background: var(--ink); color: #fff; display: grid; place-items: center; margin-bottom: 14px; }
.rail button { position: relative; width: 48px; height: 48px; border-radius: 15px; color: #6f6f6a; display: grid; place-items: center; }
.rail button:hover { background: var(--soft); color: var(--ink); }
.rail button.on { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 2px 6px rgba(0,0,0,.05); }
.rail .gap { flex: 1; min-height: 8px; }
.rail .sep { width: 26px; height: 1px; background: var(--line); margin: 6px 0; }
.badge { position: absolute; top: 4px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--warn); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; }
.badge.quiet { background: var(--ink); }
.me { width: 38px !important; height: 38px !important; border-radius: 50% !important; background: var(--ink) !important; color: #fff !important; font-size: 13px; font-weight: 600; }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--card); border-left: 1px solid var(--line); border-radius: 26px 0 0 26px; margin: 8px 0 8px; box-shadow: -1px 0 0 rgba(0,0,0,.01); }
.head { display: flex; align-items: center; gap: 14px; padding: 18px 22px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.title { font-size: 21px; font-weight: 500; color: var(--ink-2); letter-spacing: -.01em; white-space: nowrap; }
.title i { font-style: normal; color: #c4c4bf; margin: 0 10px; }
.search { margin-left: auto; display: flex; align-items: center; gap: 8px; background: var(--soft); border-radius: 14px; padding: 0 12px; height: 40px; width: min(340px, 100%); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink); }
.search svg { width: 18px; height: 18px; }

.bar { display: flex; align-items: center; gap: 8px; padding: 12px 22px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.bar::-webkit-scrollbar { display: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 20px; white-space: nowrap; color: var(--ink-2); font-weight: 500; flex: none; }
.pill svg { width: 19px; height: 19px; }
.pill:hover { background: var(--soft); }
.pill.on { background: var(--soft); color: var(--ink); }
.pill.dark { background: var(--ink); color: #fff; padding: 0 20px; box-shadow: 0 2px 0 rgba(255,255,255,.16) inset, 0 3px 8px rgba(0,0,0,.18); }
.pill.dark:hover { background: #33332f; }
.pill small { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.pill .dot { width: 9px; height: 9px; border-radius: 50%; }
.bar .vr { width: 1px; height: 26px; background: var(--line); margin: 0 6px; flex: none; }
.bar select { height: 40px; border-radius: 20px; border: 1px solid var(--line); background: var(--card); padding: 0 12px; }

.body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 430px) minmax(0, 1fr); background: var(--shell); border-radius: 0 0 0 26px; }
.col { min-height: 0; overflow-y: auto; padding: 18px 10px 24px 22px; }
.col.read { padding: 18px 22px 24px 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }

/* ------------------------------------------------------------ AI bar */
.ai { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 14px; }
.ai .spark { width: 40px; height: 40px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.ai b { display: block; font-weight: 600; }
.ai span { color: var(--muted); font-size: 13.5px; }
.ai .grow { flex: 1; min-width: 0; }
.meter { display: flex; gap: 3px; height: 26px; align-items: stretch; }
.meter i { width: 5px; border-radius: 2px; background: var(--line); }
.meter i.high { background: var(--warn); } .meter i.normal { background: var(--accent); } .meter i.low { background: #c9c9c4; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 12px; background: var(--soft); font-weight: 500; white-space: nowrap; }
.btn svg { width: 17px; height: 17px; }
.btn:hover { background: #e7e7e3; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #33332f; }
.btn.accent { background: var(--accent-soft); color: var(--accent); }
.btn.accent:hover { background: #d4e9e1; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; }
.btn.ghost:hover { background: var(--soft); }
.btn.icon { width: 36px; padding: 0; }
.btn[disabled] { opacity: .5; cursor: default; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ list */
.list { overflow: hidden; }
.list-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; min-height: 58px; border-bottom: 1px solid var(--line); }
.list-head .name { font-size: 16px; color: var(--ink-2); flex: 1; }
.list-head .acts { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.check { appearance: none; width: 20px; height: 20px; border-radius: 6px; border: 1.6px solid #c9c9c4; background: #fff; margin: 0; cursor: pointer; flex: none; display: grid; place-items: center; }
.check:checked { background: var(--ink); border-color: var(--ink); }
.check:checked::after { content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translateY(-1px); }
.row { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; background: #fbfbfa; }
.row:last-child { border-bottom: 0; }
.row.unread { background: var(--card); }
.row:hover { background: #f5f5f2; }
.row.open { background: var(--accent-soft); }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 15px; position: relative; }
.row .check { position: absolute; left: 28px; top: 26px; opacity: 0; }
.row:hover .check, .row .check:checked, .list.selecting .row .check { opacity: 1; }
.row:hover .avatar, .list.selecting .avatar { opacity: .25; }
.row .top { display: flex; align-items: baseline; gap: 8px; }
.row .from { font-weight: 500; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.row.unread .from { font-weight: 700; color: var(--ink); }
.row .date { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row.unread .date { color: var(--ink); font-weight: 600; }
.row .subj { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); margin-top: 1px; }
.row.unread .subj { color: var(--ink); font-weight: 600; }
.row .prev { font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.row .tags { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; align-items: center; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 8px; background: var(--soft); color: var(--ink-2); }
.tag.high { background: var(--warn-soft); color: var(--warn); }
.tag.normal { background: var(--accent-soft); color: var(--accent); }
.tag .dot { width: 7px; height: 7px; border-radius: 50%; }
.tag svg { width: 12px; height: 12px; }
.star { color: #c9c9c4; display: inline-grid; }
.star svg { width: 17px; height: 17px; }
.star.on { color: #d79a12; } .star.on svg { fill: #f2c14b; }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink-2); font-size: 16px; margin-bottom: 4px; font-weight: 600; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.notice { margin-bottom: 14px; padding: 12px 16px; border-radius: 16px; background: var(--warn-soft); color: #7c3a1c; font-size: 13.5px; }
.skeleton { height: 86px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, #fafaf9 0%, #f1f1ee 50%, #fafaf9 100%); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ------------------------------------------------------------ reader */
.reader { padding: 22px 26px 26px; }
.reader h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 14px; line-height: 1.25; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.tools .sp { flex: 1; }
.who { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.who > div:nth-child(2) { flex: 1; min-width: 180px; }
.who .n { font-weight: 600; }
.who .a { color: var(--muted); font-size: 13.5px; word-break: break-word; }
.who .d { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.aibox { background: var(--accent-soft); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px; white-space: pre-wrap; font-size: 14.5px; color: #17513e; }
.aibox b { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
.aibox svg { width: 15px; height: 15px; }
.imgbar { display: flex; align-items: center; gap: 10px; background: var(--soft); border-radius: 12px; padding: 8px 8px 8px 14px; font-size: 13.5px; color: var(--ink-2); margin-bottom: 12px; }
.imgbar span { flex: 1; }
.mailframe { width: 100%; border: 0; display: block; min-height: 80px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 13.5px; color: var(--ink); text-decoration: none; max-width: 100%; }
.file:hover { background: var(--soft); }
.file small { color: var(--muted); }
.file svg { width: 16px; height: 16px; }
.file button { color: var(--muted); display: grid; }
.placeholder { height: 100%; min-height: 300px; display: grid; place-items: center; color: var(--muted); text-align: center; }
.placeholder svg { width: 46px; height: 46px; stroke-width: 1.2; color: #c9c9c4; margin-bottom: 8px; }
.back { display: none; }

/* ------------------------------------------------------------ follow-ups */
.fu h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 10px; font-weight: 600; }
.fu h2:first-child { margin-top: 0; }
.fu-row { display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.fu-row:last-child { border-bottom: 0; }
.fu-row .grow { flex: 1; min-width: 200px; }
.fu-row .s { font-weight: 600; }
.fu-row .m { color: var(--muted); font-size: 13.5px; }
.fu-row .acts { display: flex; gap: 4px; flex-wrap: wrap; }

/* ------------------------------------------------------------ overlays */
#layer:empty { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(28,28,26,.32); display: grid; place-items: center; padding: 18px; z-index: 20; }
.modal { background: var(--card); border-radius: 26px; width: min(760px, 100%); max-height: calc(100dvh - 36px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.22); overflow: hidden; }
.modal.narrow { width: min(430px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px 24px; }
.modal-head h2 { font-size: 18px; margin: 0; flex: 1; font-weight: 600; }
.modal-body { padding: 4px 24px 22px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .sp { flex: 1; }
.modal-foot select { height: 36px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 0 10px; max-width: 100%; }
.tabs { display: flex; gap: 4px; padding: 0 20px 10px; border-bottom: 1px solid var(--line); overflow-x: auto; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--ink-2); font-weight: 500; margin-bottom: 5px; }
.field small { display: block; color: var(--muted); margin-top: 4px; font-size: 12.5px; }
.input, .field input:not([type=checkbox]), .field select, .field textarea { width: 100%; height: 42px; border: 1px solid #dcdcd8; border-radius: 12px; padding: 0 12px; background: #fff; outline: none; }
.field textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--ink); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.checkline { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0 14px; font-size: 14px; }
.error { background: #fdecea; color: var(--danger); padding: 10px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; } .item .s { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.hint { color: var(--muted); font-size: 13.5px; margin: 6px 0 14px; }
details.adv { margin: 4px 0 12px; } details.adv summary { cursor: pointer; color: var(--ink-2); font-size: 14px; margin-bottom: 10px; }

/* compose */
.compose { width: min(820px, 100%); height: min(760px, calc(100dvh - 36px)); }
.crow { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 0 22px; min-height: 46px; }
.crow label { color: var(--muted); font-size: 14px; width: 62px; flex: none; }
.crow input, .crow select { flex: 1; min-width: 0; border: 0; outline: none; background: none; height: 44px; }
.crow button { color: var(--muted); font-size: 13.5px; }
.cbar { display: flex; gap: 2px; align-items: center; padding: 6px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.cbar .btn { height: 32px; padding: 0 9px; background: none; }
.cbar .btn:hover { background: var(--soft); }
.cbar select { height: 32px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 0 8px; max-width: 170px; font-size: 13.5px; }
.cbar .vr { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.aiwrite { display: flex; gap: 8px; align-items: center; padding: 8px 16px; background: var(--accent-soft); flex-wrap: wrap; }
.aiwrite svg { color: var(--accent); width: 18px; height: 18px; }
.aiwrite input { flex: 1; min-width: 160px; height: 34px; border: 0; border-radius: 10px; padding: 0 12px; outline: none; background: #fff; }
.aiwrite select { height: 34px; border: 0; border-radius: 10px; padding: 0 8px; background: #fff; }
.aiwrite .btn { height: 34px; background: var(--accent); color: #fff; }
.aiwrite .btn.ghost { background: none; color: var(--accent); }
.editor { flex: 1; min-height: 140px; overflow-y: auto; padding: 16px 22px; outline: none; line-height: 1.55; }
.editor:empty::before { content: "Write your message"; color: #b3b3ad; }
.editor blockquote { margin: 0 0 0 .6em; padding-left: 1em; border-left: 2px solid var(--line); color: var(--ink-2); }
.quoted { margin: 0 22px 10px; padding: 8px 8px 8px 14px; border-radius: 12px; background: var(--soft); font-size: 13.5px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.quoted span { flex: 1; }
.cfiles { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 22px 10px; }

/* auth */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(420px, 100%); padding: 30px 30px 26px; border-radius: 28px; box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.auth h1 { font-size: 23px; margin: 16px 0 4px; font-weight: 600; letter-spacing: -.01em; }
.auth p { color: var(--muted); margin: 0 0 20px; }
.auth .btn { width: 100%; height: 44px; margin-top: 6px; }

/* menus and toasts */
.menu { position: fixed; z-index: 30; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 6px; box-shadow: 0 12px 34px rgba(0,0,0,.16); min-width: 190px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; text-align: left; }
.menu button:hover { background: var(--soft); }
.menu .lbl { padding: 8px 12px 4px; font-size: 12px; color: var(--muted); }
#toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 40; align-items: center; width: max-content; max-width: calc(100vw - 30px); }
.toast { background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 560px; }
.toast.bad { background: var(--danger); }

.body.wide { grid-template-columns: minmax(0, 1fr); }
.body.wide .col.read { display: none; }
.body.wide .col { padding-right: 22px; max-width: 980px; }
@media (max-width: 1500px) { .tools .lbl { display: none; } }

/* ------------------------------------------------------------ small screens */
@media (max-width: 980px) {
  .body { grid-template-columns: minmax(0, 1fr); }
  .col { padding: 14px; }
  .col.read { display: none; padding: 14px; }
  .body.reading .col.listcol { display: none; }
  .body.reading .col.read { display: block; }
  .back { display: inline-flex; }
}
@media (max-width: 640px) {
  .shell { padding: 0; }
  .frame { border-radius: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .rail { grid-row: 2; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); overflow-x: auto; border-top: 1px solid var(--line); gap: 2px; justify-content: space-between; }
  .rail .logo, .rail .gap, .rail .sep { display: none; }
  .rail button { width: 36px; height: 40px; flex: none; }
  .rail button.opt { display: none; }
  .rail .me { width: 32px !important; height: 32px !important; align-self: center; }
  .main { margin: 0; border-radius: 0; border-left: 0; }
  .body { border-radius: 0; }
  .head { padding: 14px 14px 10px; gap: 10px; }
  .title { font-size: 19px; }
  .search { width: 100%; margin: 0; order: 3; }
  .bar { padding: 10px 14px; }
  .col, .col.read { padding: 12px; }
  .reader { padding: 18px 16px 20px; }
  .scrim { padding: 0; place-items: end center; }
  .modal, .compose { width: 100%; max-height: 100dvh; border-radius: 22px 22px 0 0; }
  .compose { height: 100dvh; border-radius: 0; }
  .two, .three { grid-template-columns: 1fr; }
  .crow, .editor { padding-left: 16px; padding-right: 16px; }
  .ai .meter { display: none; }
}
@media (max-width: 640px) { .who .d { margin-left: 56px; width: 100%; } }

/* undo toast, tracking, import, domains */
.toast { display: flex; align-items: center; gap: 14px; }
.toast-act { color: #9fe0c6; font-weight: 700; padding: 2px 4px; }
.toast-act:hover { text-decoration: underline; }
.trackline { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.trackline svg { width: 16px; height: 16px; }
.trackline .check:disabled + svg { opacity: .4; }
.trackinfo { display: flex; align-items: center; gap: 8px; background: var(--soft); border-radius: 12px; padding: 8px 12px; font-size: 13.5px; color: var(--ink-2); margin-bottom: 14px; }
.trackinfo svg { width: 16px; height: 16px; color: var(--accent); }
.importbox { background: var(--soft); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; }
.importbox .t { font-weight: 600; font-size: 14px; }
.importbox .s { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.bar2 { height: 6px; border-radius: 3px; background: #e2e2de; margin-top: 8px; overflow: hidden; }
.bar2 i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.statusline { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; padding: 6px 0; color: var(--warn); }
.statusline svg { width: 18px; height: 18px; margin-top: 1px; }
.statusline.ok { color: var(--accent); }
.item > svg { color: var(--muted); }
