/* ShadowMail base layout + components. Colours/shape come from theme variables (themes.css). */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: var(--fs, 14px);
  -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent-2); }
code, kbd { font-family: 'Share Tech Mono', ui-monospace, monospace; }
kbd { border: 1px solid var(--border); border-bottom-width: 2px; padding: 1px 6px; border-radius: 4px; font-size: .85em; background: var(--panel-2); }
.ic { width: 18px; height: 18px; flex: none; }
.ic.xl { width: 46px; height: 46px; opacity: .5; }
.grow { flex: 1; }
.dim { color: var(--dim); }
.small { font-size: .85em; }
.pad { padding: 8px 14px; }
[hidden] { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

.fx-bg { position: fixed; inset: 0; z-index: -2; background: var(--bg-fx, none); pointer-events: none; }
.fx-scan { position: fixed; inset: 0; z-index: 50; pointer-events: none; background: var(--scan, none); opacity: var(--scan-o, 0); }

/* ---------- boot ---------- */
.boot { height: 100vh; display: grid; place-items: center; align-content: center; gap: 14px; }
.boot-logo { width: 72px; height: 72px; background: url(/icons/icon.svg) center/contain no-repeat; animation: pulse 1.4s ease-in-out infinite; }
.boot-text { font-family: var(--font-head); letter-spacing: .3em; color: var(--accent-2); }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }

/* ---------- panel / buttons / inputs ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); clip-path: var(--chamfer, none); backdrop-filter: var(--blur, none); -webkit-backdrop-filter: var(--blur, none); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--border); background: var(--btn-bg, var(--panel-2)); color: var(--text); border-radius: var(--btn-radius, var(--radius));
  font-family: var(--btn-font, inherit); text-transform: var(--btn-case, none); letter-spacing: var(--btn-ls, 0); font-size: var(--btn-fs, .92em); font-weight: 600;
  clip-path: var(--chamfer-sm, none); transition: background .15s, box-shadow .15s, transform .1s; white-space: nowrap;
}
.btn:hover { background: var(--hover); box-shadow: var(--glow-sm, none); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-border, transparent); }
.btn.primary:hover { filter: brightness(1.1); box-shadow: var(--glow, none); }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 28px; padding: 0 10px; font-size: .8em; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; pointer-events: none; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--btn-radius, 8px); color: var(--dim); transition: color .15s, background .15s; flex: none; }
.icon-btn:hover { color: var(--text); background: var(--hover); }
.icon-btn.on { color: var(--warn); }
.link-btn { color: var(--accent-2); text-decoration: underline; font-size: .9em; }
.mini { display: inline-grid; place-items: center; width: 20px; height: 20px; color: var(--dim); }
.mini .ic { width: 14px; height: 14px; }
.input {
  width: 100%; min-height: 38px; padding: 8px 12px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--input-radius, var(--radius));
  color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
select.input { appearance: auto; }
input[type=color].input { padding: 2px; height: 38px; }
.field { display: grid; gap: 6px; margin: 0 0 12px; }
.field > span { font-size: .8em; color: var(--dim); text-transform: var(--label-case, none); letter-spacing: var(--label-ls, 0); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.check-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; cursor: pointer; }
.check-row input { accent-color: var(--accent); width: 16px; height: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.addr-in { display: flex; align-items: center; gap: 6px; }
.addr-in span { color: var(--dim); white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; font-size: .75em; background: var(--panel-2); border: 1px solid var(--border); color: var(--dim); vertical-align: middle; }
.pill .ic { width: 12px; height: 12px; }
.pill.good { color: var(--good); border-color: var(--good); }
.pill.bad { color: var(--bad); border-color: var(--bad); }
.tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--tag-radius, 4px); font-size: .72em; color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 60%, transparent); background: color-mix(in srgb, var(--c) 14%, transparent); text-transform: var(--tag-case, none); letter-spacing: var(--tag-ls, 0); white-space: nowrap; }
.tag.ghost { --c: var(--dim); }
.tag.big { font-size: .85em; padding: 4px 10px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: var(--dot-glow, none); }
.badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; font-size: .72em; text-align: center; background: var(--badge-bg, var(--accent)); color: var(--badge-fg, #fff); font-weight: 700; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; margin: 10px 0; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--panel-2); font-size: .9em; }

.avatar { --h: 270; display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: var(--avatar-radius, 50%); font-weight: 700; font-size: .8em; letter-spacing: .02em;
  color: hsl(var(--h) 90% 88%); background: hsl(var(--h) 55% 28%); border: 1px solid hsl(var(--h) 70% 50% / .6); font-family: var(--font-head); }
.avatar.sm { width: 28px; height: 28px; font-size: .68em; }
.avatar.lg { width: 46px; height: 46px; font-size: .95em; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; overflow: auto; height: 100%; }
.auth-card { width: min(420px, 100%); padding: 28px; }
.auth-card h2 { font-family: var(--font-head); font-size: 1.1em; letter-spacing: var(--head-ls); text-transform: var(--head-case); margin: 18px 0 8px; }
.err { color: var(--bad); margin: 10px 0 0; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-size: 1.05em; letter-spacing: var(--brand-ls, .12em); padding: 4px 6px 14px; white-space: nowrap; }
.brand img { width: 34px; height: 34px; filter: var(--logo-filter, none); }
.brand b { color: var(--accent-2); font-weight: 900; text-shadow: var(--text-glow, none); }
.brand.big { font-size: 1.4em; justify-content: center; }
.brand.big img { width: 52px; height: 52px; }

/* ---------- app layout ---------- */
.app {
  height: 100vh; height: 100dvh; display: grid; gap: var(--gap); padding: var(--gap);
  grid-template-columns: var(--sidebar-w) var(--list-w) 1fr;
  padding-top: max(var(--gap), env(safe-area-inset-top)); padding-bottom: max(var(--gap), env(safe-area-inset-bottom));
  padding-left: max(var(--gap), env(safe-area-inset-left)); padding-right: max(var(--gap), env(safe-area-inset-right));
}
.sidebar { display: flex; flex-direction: column; padding: 14px 10px; min-height: 0; overflow: hidden; }
.compose-btn { margin: 0 4px 12px; min-height: 42px; }
.nav { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.nav-group { display: grid; gap: 2px; margin-bottom: 8px; }
.nav-title { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 12px 10px 6px; font-size: .7em; color: var(--dim); text-transform: uppercase; letter-spacing: .16em; font-family: var(--font-head); }
.nav-title .ic { width: 14px; height: 14px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px; border-radius: var(--nav-radius, 6px); color: var(--nav-fg, var(--dim)); text-align: left; transition: background .15s, color .15s; position: relative; min-height: 36px; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; flex-direction: column; }
.nav-item small { font-size: .72em; color: var(--dim); opacity: .8; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.on { background: var(--nav-on-bg); color: var(--nav-on-fg); box-shadow: var(--nav-on-shadow, none); }
.nav-item.on-soft { color: var(--text); background: var(--hover); }
.nav-item.box { padding-top: 6px; padding-bottom: 6px; }
.side-foot { border-top: 1px solid var(--border); padding-top: 8px; display: grid; gap: 2px; }
.me-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px 2px; font-size: .9em; color: var(--dim); white-space: nowrap; overflow: hidden; }

.list-pane { display: flex; flex-direction: column; min-height: 0; overflow: hidden; position: relative; }
.list-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 6px 16px; }
.list-title, .view-title { margin: 0; font-family: var(--font-head); font-size: 1.05em; letter-spacing: var(--head-ls); text-transform: var(--head-case); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--head-color, var(--text)); text-shadow: var(--text-glow, none); }
.search-row { padding: 4px 12px 10px; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 38px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--input-radius, var(--radius)); color: var(--dim); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.search input { flex: 1; background: none; border: 0; outline: 0; min-width: 0; color: var(--text); }
.bulk { display: flex; align-items: center; gap: 2px; padding: 4px 10px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--panel-2); }
.bulk-count { font-size: .85em; color: var(--dim); margin-left: 6px; }
.list { flex: 1; overflow-y: auto; overflow-x: hidden; outline: none; scrollbar-width: thin; -webkit-overflow-scrolling: touch; padding: var(--list-pad, 0); }
.list-empty { display: grid; place-items: center; gap: 10px; padding: 60px 20px; color: var(--dim); text-align: center; }
.more { margin: 10px auto 20px; display: flex; width: calc(100% - 24px); }

.row-wrap { position: relative; overflow: hidden; transition: height .2s; margin: var(--row-gap, 0); border-radius: var(--row-radius, 0); }
.swipe-bg { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 24px; color: #fff; opacity: 0; }
.swipe-bg.left { background: var(--good); color: #062; justify-content: flex-start; }
.swipe-bg.right { background: var(--bad); justify-content: flex-end; }
.row-wrap.go-left .swipe-bg.left, .row-wrap.go-right .swipe-bg.right { opacity: .55; }
.row-wrap.armed .swipe-bg { opacity: 1 !important; }
.swipe-bg .ic { width: 24px; height: 24px; }

.msg-row {
  position: relative; display: flex; gap: 12px; padding: var(--row-pad, 12px 14px); cursor: pointer; background: var(--row-bg, var(--panel-solid, var(--panel)));
  border-bottom: 1px solid var(--row-border, var(--border)); transition: background .12s, transform .2s; touch-action: pan-y; user-select: none;
  border-radius: var(--row-radius, 0);
}
.msg-row:hover { background: var(--row-hover, var(--hover)); }
.msg-row.open { background: var(--row-open); box-shadow: var(--row-open-shadow, none); }
.msg-row.sel { background: var(--row-sel); }
.msg-row.cursor { outline: 1px solid var(--accent); outline-offset: -1px; }
.msg-row.unread::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; background: var(--accent); box-shadow: var(--glow-sm, none); border-radius: 2px; }
.msg-row .check { display: none; align-self: center; }
.msg-row.sel .check, .bulk:not([hidden]) ~ .list .msg-row .check { display: block; }
.msg-row .check input, .bulk .check input { accent-color: var(--accent); width: 16px; height: 16px; }
.msg-main { flex: 1; min-width: 0; }
.msg-top { display: flex; align-items: baseline; gap: 6px; }
.msg-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
.unread .msg-from { color: var(--text); font-weight: 700; }
.msg-date { font-size: .78em; color: var(--dim); white-space: nowrap; font-family: var(--font-mono-ish, inherit); }
.unread .msg-date { color: var(--accent-2); }
.msg-subj { display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; font-size: .95em; color: var(--dim); }
.unread .msg-subj { color: var(--text); font-weight: 600; }
.msg-snip { font-size: .85em; color: var(--dim); opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; display: var(--snip-display, block); }
.msg-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }
.msg-tags:empty { display: none; }
.imp { color: var(--warn); display: inline-flex; }
.imp .ic { width: 14px; height: 14px; }
.msg-side { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--dim); }
.msg-side .ic { width: 16px; height: 16px; }
.star { color: var(--dim); opacity: .5; }
.star.on { color: var(--warn); opacity: 1; }
.star.on .ic { fill: currentColor; }
.fab { position: absolute; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: var(--fab-radius, 50%); background: var(--primary-bg); color: var(--primary-fg); display: grid; place-items: center; box-shadow: var(--glow, 0 6px 20px rgba(0,0,0,.4)); clip-path: var(--chamfer-sm, none); z-index: 5; }
.fab .ic { width: 24px; height: 24px; }

/* ---------- reader ---------- */
.reader-pane { min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.reader-empty { flex: 1; display: grid; place-items: center; color: var(--dim); text-align: center; }
.empty-art img { width: 110px; opacity: .35; filter: var(--logo-filter, none); }
.reader { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.reader-bar { display: flex; align-items: center; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.reader-scroll, .view-scroll { flex: 1; overflow-y: auto; padding: 18px 22px 40px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.reader-subj { font-family: var(--font-head); font-size: 1.35em; letter-spacing: var(--head-ls); margin: 0 0 8px; line-height: 1.3; text-transform: var(--subj-case, none); color: var(--head-color, var(--text)); word-break: break-word; }
.reader-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }
.reader-from { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.rf-main { flex: 1; min-width: 0; word-break: break-word; }
.rf-date { white-space: nowrap; }
.reader-body { margin: 6px 0 16px; }
.mail-frame { width: 100%; min-height: 200px; border: 0; border-radius: var(--frame-radius, 6px); background: #fff; display: block; box-shadow: var(--frame-shadow, none); }
.text-body { white-space: normal; line-height: 1.6; word-break: break-word; font-family: var(--font-read, inherit); }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; }
.att-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2); color: var(--text); text-decoration: none; max-width: 280px; }
.att-card span { display: flex; flex-direction: column; min-width: 0; }
.att-card b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.att-card small { color: var(--dim); }
.att-card:hover { border-color: var(--accent); }
.thread { margin: 10px 0 18px; display: grid; gap: 4px; }
.thread-item { display: flex; gap: 10px; text-align: left; padding: 8px 10px; border-radius: var(--radius); border: 1px solid transparent; }
.thread-item:hover { background: var(--hover); }
.thread-item.on { border-color: var(--accent); }
.reply-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 22px; }
.notes { border-top: 1px solid var(--border); padding-top: 6px; }
.note { display: flex; gap: 10px; padding: 8px 0; }
.note p { margin: 3px 0 0; white-space: pre-wrap; word-break: break-word; }
.note-form { display: flex; gap: 8px; margin-top: 8px; }
.mention { color: var(--accent-2); background: color-mix(in srgb, var(--accent) 16%, transparent); padding: 0 3px; border-radius: 3px; text-decoration: none; }

/* ---------- views ---------- */
.reader-pane.wide .view-scroll { padding: 18px 22px 60px; }
.tabs { display: flex; gap: 4px; padding: 8px 14px 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { padding: 8px 14px; border-bottom: 2px solid transparent; color: var(--dim); white-space: nowrap; font-family: var(--btn-font, inherit); text-transform: var(--btn-case, none); letter-spacing: var(--btn-ls, 0); font-size: .85em; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.card { padding: 18px 20px; margin-bottom: var(--gap-card, 14px); max-width: 980px; }
.card h3 { margin: 0 0 12px; font-family: var(--font-head); font-size: .95em; letter-spacing: var(--head-ls); text-transform: var(--head-case); display: flex; align-items: center; gap: 8px; color: var(--head-color, var(--text)); }
.form .btn.primary { margin-top: 4px; }
.table { display: grid; }
.tr { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tr:last-child { border-bottom: 0; }
.td { min-width: 180px; word-break: break-word; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 6px; flex-wrap: wrap; }
.seg input { display: none; }
.seg span { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; cursor: pointer; color: var(--dim); }
.seg input:checked + span { background: var(--nav-on-bg); color: var(--nav-on-fg); }
.label-edit { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.label-edit input[type=color] { width: 38px; height: 38px; border: 1px solid var(--border); border-radius: var(--radius); background: none; padding: 2px; flex: none; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.theme-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2); }
.theme-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-card small { color: var(--dim); font-size: .78em; }
.theme-prev { height: 86px; border-radius: 6px; margin-bottom: 6px; display: grid; grid-template-columns: 22% 34% 1fr; gap: 4px; padding: 6px; overflow: hidden; }
.theme-prev i { border-radius: 3px; }
.sig-addr { border-top: 1px solid var(--border); padding: 12px 0; }
.sig-addr-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sig-item { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.sig-prev { background: #fff; color: #111; padding: 12px; max-height: 180px; overflow: auto; }
.sig-meta { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.builder { border: 1px dashed var(--border); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0 14px; }
.builder summary { cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 4px 0 10px; }
.sig-ed .ed-body { background: #fff; color: #111; }

/* dashboard */
.dash-hello h1 { font-family: var(--font-head); margin: 0; font-size: 1.6em; letter-spacing: var(--head-ls); text-transform: var(--head-case); color: var(--head-color, var(--text)); text-shadow: var(--text-glow, none); }
.dash-hello p { margin: 4px 0 18px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap-card, 14px); margin-bottom: var(--gap-card, 14px); max-width: 980px; }
.stat { position: relative; display: flex; flex-direction: column; align-items: flex-start; padding: 16px 18px; text-align: left; overflow: hidden; }
.stat .ic { position: absolute; right: 12px; top: 12px; width: 26px; height: 26px; color: var(--accent); opacity: .7; }
.stat-n { font-family: var(--font-head); font-size: 2em; font-weight: 700; color: var(--accent-2); text-shadow: var(--text-glow, none); line-height: 1.1; }
.stat.warn .stat-n, .stat.warn .ic { color: var(--warn); }
.stat.good .stat-n, .stat.good .ic { color: var(--good); }
.stat-l { color: var(--dim); font-size: .82em; text-transform: var(--label-case, none); letter-spacing: var(--label-ls, 0); }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-card, 14px); max-width: 980px; }
.dash-grid .card { margin: 0; }
.span2 { grid-column: span 2; }
.chart { width: 100%; height: auto; }
.bar-recv { fill: var(--accent); }
.bar-sent { fill: var(--good); opacity: .8; }
.bar-label { fill: var(--dim); font-size: 10px; }
.bar-recv-dot { background: var(--accent); }
.bar-sent-dot { background: var(--good); }
.legend { display: flex; gap: 16px; font-size: .8em; color: var(--dim); margin-top: 6px; }
.legend span { display: flex; gap: 6px; align-items: center; }
.dash-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.dash-row:last-child { border-bottom: 0; }
.dash-row > span:not(.avatar) { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dash-row small { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.dash-row small { color: var(--dim); font-size: .78em; }
.label-cloud { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- editor ---------- */
.editor { border: 1px solid var(--border); border-radius: var(--radius); background: var(--input-bg); position: relative; }
.ed-toolbar { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; padding: 4px 6px; border-bottom: 1px solid var(--border); background: var(--panel-2); border-radius: var(--radius) var(--radius) 0 0; }
.ed-toolbar button, .ed-color { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 4px; color: var(--dim); position: relative; cursor: pointer; }
.ed-toolbar button:hover, .ed-color:hover, .ed-toolbar button.on { color: var(--text); background: var(--hover); }
.ed-toolbar .ic { width: 16px; height: 16px; }
.ed-color input { position: absolute; inset: auto 0 0 0; width: 100%; height: 4px; padding: 0; border: 0; opacity: .9; cursor: pointer; }
.ed-toolbar select { height: 28px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 4px; color: var(--text); font-size: .8em; padding: 0 4px; max-width: 92px; }
.ed-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.ed-body { padding: 12px 14px; outline: none; overflow-wrap: anywhere; line-height: 1.55; font-family: Arial, Helvetica, sans-serif; color: var(--editor-fg, var(--text)); background: var(--editor-bg, transparent); border-radius: 0 0 var(--radius) var(--radius); }
.ed-body:empty::before { content: attr(data-ph); color: var(--dim); }
.ed-body img { max-width: 100%; }
.ed-body blockquote { margin: 0 0 0 .8ex; border-left: 2px solid var(--accent); padding-left: 1ex; }
.ed-source { font-family: 'Share Tech Mono', monospace; font-size: .85em; border: 0; border-radius: 0 0 var(--radius) var(--radius); resize: vertical; }
.ed-pop, .ac-pop { position: absolute; z-index: 30; min-width: 240px; max-width: 360px; background: var(--panel-solid, var(--panel)); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.45); padding: 4px; }
.pop-item { padding: 7px 10px; border-radius: 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9em; }
.pop-item.on, .pop-item:hover { background: var(--hover); }

/* ---------- compose ---------- */
.compose { position: fixed; right: 24px; bottom: 0; z-index: 40; width: min(680px, calc(100vw - 32px)); }
.compose-win { display: flex; flex-direction: column; max-height: min(86vh, 860px); border-bottom-left-radius: 0; border-bottom-right-radius: 0; background: var(--panel-solid, var(--panel)); box-shadow: 0 -6px 40px rgba(0,0,0,.55), var(--glow-sm, none); }
.compose.min .compose-win > :not(.compose-head) { display: none; }
.compose.full { inset: 0; width: auto; display: grid; place-items: center; background: rgba(0,0,0,.55); padding: 20px; }
.compose.full .compose-win { width: min(1000px, 100%); height: 100%; max-height: none; border-radius: var(--radius); }
.compose-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); font-family: var(--font-head); letter-spacing: var(--head-ls); text-transform: var(--head-case); font-size: .9em; cursor: default; }
.compose-fields { position: relative; padding: 4px 14px; }
.cf { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.cf > span { width: 58px; flex: none; color: var(--dim); font-size: .85em; }
.cf .input { border: 0; background: transparent; box-shadow: none !important; padding-left: 0; min-height: 40px; }
.compose-editor { flex: 1; overflow: auto; padding: 10px 14px; min-height: 0; }
.compose-editor .editor { border: 0; background: transparent; }
.compose-editor .ed-toolbar { position: sticky; top: 0; z-index: 2; border-radius: var(--radius); border: 1px solid var(--border); }
.compose-atts { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; }
.compose-atts:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: .82em; background: var(--panel-2); }
.chip .ic { width: 14px; height: 14px; }
.chip-x { width: 22px; height: 22px; border-radius: 50%; color: var(--dim); }
.chip-x:hover { background: var(--hover); color: var(--bad); }
.compose-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.compose-foot label.icon-btn { cursor: pointer; }

/* ---------- modal / toast ---------- */
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(3px); }
.modal { width: min(420px, 100%); padding: 20px; max-height: 86vh; overflow: auto; background: var(--panel-solid, var(--panel)); }
.modal.wide { width: min(620px, 100%); }
.modal h3 { margin: 0 0 12px; display: flex; align-items: center; gap: 8px; font-family: var(--font-head); letter-spacing: var(--head-ls); text-transform: var(--head-case); font-size: 1em; }
.kbd-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; font-size: .9em; }
.kbd-grid kbd { justify-self: start; }
#toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: var(--radius); background: var(--panel-solid, #222); border: 1px solid var(--border); color: var(--text); box-shadow: 0 8px 30px rgba(0,0,0,.5); opacity: 0; transform: translateY(10px); transition: .25s; max-width: min(520px, 92vw); text-align: center; clip-path: var(--chamfer-sm, none); }
.toast.show { opacity: 1; transform: none; }
.toast-good { border-color: var(--good); }
.toast-bad { border-color: var(--bad); color: var(--bad); }

.only-mobile { display: none !important; }
.scrim { display: none; }

/* ---------- iPad / medium: icon-rail sidebar, three columns ---------- */
@media (max-width: 1180px) and (min-width: 700px) {
  .app { grid-template-columns: var(--rail-w, 68px) minmax(280px, 36%) 1fr; }
  .sidebar { padding: 12px 6px; align-items: center; }
  .sidebar .brand span, .nav-item > span, .compose-btn span, .nav-title, .me-card span, .nav-item small { display: none; }
  .brand { padding: 4px 0 12px; }
  .compose-btn { width: 46px; height: 46px; padding: 0; margin: 0 0 12px; }
  .nav-item { justify-content: center; width: 46px; padding: 10px 0; }
  .nav-item .badge { position: absolute; top: 1px; right: -2px; font-size: .6em; padding: 0 4px; min-width: 16px; }
  .nav-group { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
  .me-card { padding: 6px 0 0; justify-content: center; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- iPhone / small: single column ---------- */
@media (max-width: 699px) {
  body { font-size: 15px; }
  .app { grid-template-columns: 1fr; padding: 0; gap: 0; padding-top: env(safe-area-inset-top); padding-bottom: 0; padding-left: 0; padding-right: 0; }
  .app > .panel { border-radius: 0; clip-path: none; border-left: 0; border-right: 0; }
  .only-mobile { display: inline-grid !important; }
  .hide-mobile { display: none !important; }
  .sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: min(300px, 84vw); transform: translateX(-102%); transition: transform .25s ease; padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: calc(10px + env(safe-area-inset-bottom)); border-radius: 0 !important; clip-path: none !important; background: var(--panel-solid, var(--panel)); }
  .app.side-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.5); }
  .app.side-open .scrim { display: block; }
  .list-pane, .reader-pane { grid-area: 1 / 1; height: calc(100dvh - env(safe-area-inset-top)); border: 0 !important; }
  .app[data-pane=list] .reader-pane { visibility: hidden; transform: translateX(100%); }
  .app[data-pane=reader] .list-pane { visibility: hidden; }
  .reader-pane { transition: transform .25s ease; }
  .reader-scroll, .view-scroll { padding: 14px 14px calc(40px + env(safe-area-inset-bottom)); }
  .list { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
  .msg-row { padding: 12px 14px; }
  .reader-subj { font-size: 1.2em; }
  .reader-from { flex-wrap: wrap; }
  .rf-date { width: 100%; order: 3; padding-left: 58px; }
  .reader-bar { padding-top: 4px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .compose { inset: 0; width: auto; right: 0; }
  .compose .compose-win { height: 100%; max-height: none; border-radius: 0; clip-path: none; padding-top: env(safe-area-inset-top); }
  .compose.full { padding: 0; }
  .ed-toolbar select { display: none; }
  .tr .btn.small { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
