/* ---------- tokens ---------- */
:root {
  --paper: #f3eee4;
  --card: #fbf8f1;
  --sunk: #ebe5d8;
  --ink: #1d1a15;
  --ink2: #5b5548;
  --ink3: #8b8372;
  --line: #dcd3c1;
  --line2: #e8e1d2;
  --accent: #c4402a;
  --accent-h: #a93220;
  --accent-ink: #fffaf3;
  --accent-soft: #f5dcd3;
  --ok: #2d6b58;
  --ok-soft: #d8e8e0;
  --warn: #9a6a14;
  --warn-soft: #f1e3c3;
  --bad: #b3261e;
  --shadow: 0 1px 0 rgba(40, 30, 10, .04), 0 8px 24px -12px rgba(40, 30, 10, .25);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "DejaVu Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper:#14120e; --card:#1b1814; --sunk:#100e0b; --ink:#efe8da; --ink2:#b3aa98; --ink3:#857d6c; --line:#332f27; --line2:#27231d; --accent:#e5694f; --accent-h:#f07c63; --accent-ink:#1a0f0b; --accent-soft:#3a1e17; --ok:#6fbfa4; --ok-soft:#1a2c26; --warn:#d9a441; --warn-soft:#342a14; --bad:#f08a80; --shadow:0 8px 28px -12px rgba(0,0,0,.7); color-scheme: dark; }
}
:root[data-theme="dark"] { --paper:#14120e; --card:#1b1814; --sunk:#100e0b; --ink:#efe8da; --ink2:#b3aa98; --ink3:#857d6c; --line:#332f27; --line2:#27231d; --accent:#e5694f; --accent-h:#f07c63; --accent-ink:#1a0f0b; --accent-soft:#3a1e17; --ok:#6fbfa4; --ok-soft:#1a2c26; --warn:#d9a441; --warn-soft:#342a14; --bad:#f08a80; --shadow:0 8px 28px -12px rgba(0,0,0,.7); color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14.5px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--ink2); }
.faint { color: var(--ink3); }
.serif { font-family: var(--serif); }

/* ---------- icons ---------- */
.ic { width: 18px; height: 18px; flex: none; overflow: visible; }
.ic * { transform-box: fill-box; transform-origin: center; }
.ic.lg { width: 22px; height: 22px; }
.ic.sm { width: 15px; height: 15px; }
.ic-star.on .st { fill: currentColor; }
.ic-star.on { color: #d49a1c; }

@media (prefers-reduced-motion: no-preference) {
  /* inbox: стрелка падает в лоток */
  .ico-host:hover .ic-inbox .a, .ic-inbox.play .a { animation: inDrop 1s ease-in-out infinite; }
  @keyframes inDrop { 0% { transform: translateY(-2px); opacity: .2 } 50% { transform: translateY(2px); opacity: 1 } 100% { transform: translateY(3px); opacity: 0 } }
  /* send: самолётик улетает */
  .ico-host:hover .ic-send .plane, .ic-send.play .plane { animation: fly .9s ease-in-out infinite; }
  .ic-send .trail { opacity: 0; }
  .ico-host:hover .ic-send .trail, .ic-send.play .trail { animation: trail .9s ease-in-out infinite; }
  @keyframes fly { 0%,100% { transform: translate(0,0) } 45% { transform: translate(4px,-4px) } 55% { transform: translate(-1px,1px) } }
  @keyframes trail { 0%,100% { opacity: 0; transform: translateX(0) } 45% { opacity: 1; transform: translateX(-2px) } }
  /* trash: крышка */
  .ic-trash .lid { transform-origin: 20% 80%; transition: transform .22s cubic-bezier(.3,1.6,.5,1); }
  .ico-host:hover .ic-trash .lid { transform: rotate(-22deg) translateY(-1px); }
  /* star */
  .ic-star .st { transition: transform .3s cubic-bezier(.3,1.8,.5,1); }
  .ico-host:hover .ic-star .st { transform: scale(1.18) rotate(18deg); }
  .ic-star.on.pop .st { animation: pop .45s cubic-bezier(.3,1.8,.5,1); }
  @keyframes pop { 0% { transform: scale(.4) rotate(-40deg) } 100% { transform: scale(1) rotate(0) } }
  /* mail: клапан открывается */
  .ic-mail .flap, .ic-mailopen .flap { transition: transform .3s cubic-bezier(.3,1.4,.5,1); transform-origin: 50% 0; }
  .ico-host:hover .ic-mail .flap { transform: scaleY(-.9) translateY(-1.5px); }
  .ico-host:hover .ic-mailopen .flap { transform: scaleY(.7); }
  /* edit: карандаш пишет */
  .ico-host:hover .ic-edit .pen, .ic-edit.play .pen { animation: write .7s ease-in-out infinite; }
  .ic-edit .ln { stroke-dasharray: 9; stroke-dashoffset: 0; }
  .ico-host:hover .ic-edit .ln { animation: lnDraw .7s ease-in-out infinite; }
  @keyframes write { 0%,100% { transform: translate(0,0) } 50% { transform: translate(2px,1.5px) rotate(4deg) } }
  @keyframes lnDraw { 0% { stroke-dashoffset: 9 } 60%,100% { stroke-dashoffset: 0 } }
  /* вращения */
  .ico-host:hover .ic-refresh .spin { animation: rot .8s cubic-bezier(.5,0,.3,1); }
  .ic-refresh.busy .spin, .ic-spin .loop { animation: rot .9s linear infinite; }
  .ico-host:hover .ic-cog .spin { animation: rot 2.4s linear infinite; }
  .ico-host:hover .ic-sun .spin { animation: rot 3s linear infinite; }
  .ic-moon .rock { transition: transform .4s; }
  .ico-host:hover .ic-moon .rock { transform: rotate(-24deg); }
  @keyframes rot { to { transform: rotate(360deg) } }
  /* поиск */
  .ico-host:hover .ic-search .lens { animation: look 1s ease-in-out infinite; }
  @keyframes look { 0%,100% { transform: translate(0,0) } 25% { transform: translate(1.5px,-1.5px) } 75% { transform: translate(-1.5px,1.5px) } }
  /* пользователи */
  .ico-host:hover .ic-user .hd, .ico-host:hover .ic-users .hd { animation: bob .6s ease-in-out infinite alternate; }
  .ico-host:hover .ic-users .hd2 { animation: bob .6s .15s ease-in-out infinite alternate; }
  @keyframes bob { to { transform: translateY(-1.5px) } }
  /* щит: галочка рисуется */
  .ic-shield .ck, .ic-check .ck { stroke-dasharray: 14; stroke-dashoffset: 0; }
  .ico-host:hover .ic-shield .ck, .ic-check.play .ck, .ic-shield.play .ck { animation: draw .6s ease-out; }
  @keyframes draw { from { stroke-dashoffset: 14 } to { stroke-dashoffset: 0 } }
  /* облако */
  .ico-host:hover .ic-cloud .float, .ic-cloud.play .float { animation: floaty 1.4s ease-in-out infinite; }
  .ico-host:hover .ic-cloud .up, .ic-cloud.play .up { animation: upArrow 1.4s ease-in-out infinite; }
  @keyframes floaty { 50% { transform: translateY(-1.5px) } }
  @keyframes upArrow { 0% { transform: translateY(2px); opacity: 0 } 50% { opacity: 1 } 100% { transform: translateY(-2px); opacity: 0 } }
  /* БД */
  .ic-db .l1, .ic-db .l2 { transition: transform .25s; }
  .ico-host:hover .ic-db .l1 { transform: translateY(-1.2px); }
  .ico-host:hover .ic-db .l2 { transform: translateY(1.2px); }
  /* стрелки */
  .ico-host:hover .ic-back .nudge { animation: nudgeL .5s ease-in-out infinite alternate; }
  .ico-host:hover .ic-reply .nudge, .ico-host:hover .ic-replyall .nudge, .ico-host:hover .ic-undo .nudge { animation: nudgeL .5s ease-in-out infinite alternate; }
  .ico-host:hover .ic-fwd .nudge2, .ico-host:hover .ic-logout .nudge2 { animation: nudgeR .5s ease-in-out infinite alternate; }
  @keyframes nudgeL { to { transform: translateX(-2px) } }
  @keyframes nudgeR { to { transform: translateX(2.5px) } }
  .ico-host:hover .ic-clip .wig { animation: wig .5s ease-in-out infinite alternate; }
  @keyframes wig { from { transform: rotate(-8deg) } to { transform: rotate(8deg) } }
  .ico-host:hover .ic-globe .mer { animation: mer 1.6s ease-in-out infinite; }
  @keyframes mer { 0%,100% { transform: scaleX(1) } 50% { transform: scaleX(.12) } }
  .ico-host:hover .ic-key .turn { animation: turn .7s ease-in-out; }
  @keyframes turn { 40% { transform: rotate(-25deg) } 100% { transform: rotate(0) } }
  .ico-host:hover .ic-download .dn { animation: dn .7s ease-in-out infinite; }
  @keyframes dn { 50% { transform: translateY(2px) } }
  .ico-host:hover .ic-eye .pup { animation: look .9s ease-in-out infinite; }
  .ico-host:hover .ic-route .dash, .ic-route.play .dash { stroke-dasharray: 3 3; animation: dashMove .6s linear infinite; }
  @keyframes dashMove { to { stroke-dashoffset: -6 } }
  .ico-host:hover .ic-flag .fl { animation: wave .8s ease-in-out infinite alternate; }
  @keyframes wave { to { transform: skewY(6deg) } }
  .ico-host:hover .ic-plus, .ico-host:hover .ic-x { transform: rotate(90deg); }
  .ic-plus, .ic-x { transition: transform .25s; }
  .ico-host:hover .ic-warn { animation: wob .5s ease-in-out; }
  @keyframes wob { 25% { transform: rotate(-8deg) } 75% { transform: rotate(8deg) } }
  .ico-host:hover .ic-link { animation: wob .5s; }
  /* логотип */
  .brand:hover .stamp-ring { animation: rot 6s linear infinite; transform-origin: 16px 16px; }
  /* пустые состояния */
  .art-float { animation: floaty 3.2s ease-in-out infinite; }
  .art-float .flapA { animation: flapB 3.2s ease-in-out infinite; transform-origin: 60px 42px; }
  @keyframes flapB { 0%,100% { transform: scaleY(1) } 50% { transform: scaleY(.88) } }
  .art-spark { animation: spark 2.4s ease-in-out infinite; }
  @keyframes spark { 50% { opacity: .35; transform: scale(.9) } }
  .art .f { fill: var(--card); }
  /* появление */
  .fade-in { animation: fadeIn .25s ease-out both; }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(4px) } }
  .row-in { animation: fadeIn .22s ease-out both; }
}
.art { color: var(--ink3); }
.art .f { fill: var(--card); }

/* ---------- buttons / inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s; }
.btn:hover { background: var(--sunk); border-color: var(--ink3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--sunk); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; height: 34px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field > label, .lbl { font-size: 12.5px; font-weight: 600; color: var(--ink2); letter-spacing: .01em; }
.field .hint { font-size: 12.5px; color: var(--ink3); }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=search], select, textarea {
  width: 100%; min-height: 38px; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); outline: none; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; line-height: 1.5; }
.suffix { display: flex; align-items: stretch; }
.suffix input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.suffix span { display: flex; align-items: center; padding: 0 11px; border: 1px solid var(--line); border-left: 0; border-radius: 0 8px 8px 0; background: var(--sunk); color: var(--ink2); font-family: var(--mono); font-size: 13px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch .tr { width: 38px; height: 22px; border-radius: 99px; background: var(--line); position: relative; transition: background .18s; flex: none; }
.switch .tr::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .2s cubic-bezier(.3,1.5,.5,1); }
.switch input:checked + .tr { background: var(--ok); }
.switch input:checked + .tr::after { transform: translateX(16px); }
.switch input:focus-visible + .tr { outline: 2px solid var(--accent); outline-offset: 2px; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--sunk); color: var(--ink2); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--accent-soft); color: var(--bad); }
.tag.acc { background: var(--accent-soft); color: var(--accent); }

/* ---------- auth / setup ---------- */
#app { min-height: 100vh; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.paper-card { position: relative; width: min(440px, 100%); background: var(--card); padding: 32px 30px 26px; box-shadow: var(--shadow); border-radius: 4px; }
.paper-card::before { content: ""; position: absolute; inset: 6px; border: 1px dashed var(--line); border-radius: 2px; pointer-events: none; }
.paper-card.wide { width: min(560px, 100%); }
.paper-card h1 { font: 600 26px/1.15 var(--serif); margin: 14px 0 4px; letter-spacing: -.01em; }
.paper-card .sub { color: var(--ink2); margin: 0 0 22px; }
.brandline { display: flex; align-items: center; gap: 10px; color: var(--accent); font: 600 17px var(--serif); }
.err { display: flex; gap: 8px; align-items: flex-start; padding: 9px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--bad); font-size: 13.5px; margin-bottom: 14px; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--ink); font-size: 13.5px; margin-bottom: 14px; }
.note .ic { color: var(--warn); margin-top: 1px; }
.note.ok { background: var(--ok-soft); } .note.ok .ic { color: var(--ok); }
.switchline { margin-top: 18px; font-size: 13.5px; color: var(--ink2); text-align: center; }
.help { font-size: 12.5px; color: var(--ink3); line-height: 1.5; }
.help code, code.k { font-family: var(--mono); font-size: 12px; background: var(--sunk); padding: 1px 5px; border-radius: 4px; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(300px, 380px) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.shell.admin { grid-template-columns: 232px minmax(0, 1fr); }
.side { background: var(--sunk); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 12px; min-height: 0; }
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 8px 14px; color: var(--accent); font: 600 19px var(--serif); text-decoration: none; letter-spacing: -.01em; }
.brand small { display: block; font: 500 11.5px var(--sans); color: var(--ink3); letter-spacing: 0; margin-top: -2px; }
.side .btn.compose { width: 100%; height: 40px; margin-bottom: 14px; }
.nav { display: grid; gap: 2px; }
.nav a, .nav button { display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border-radius: 8px; color: var(--ink2); text-decoration: none; border: 0; background: none; width: 100%; text-align: left; font-weight: 500; }
.nav a:hover, .nav button:hover { background: var(--line2); color: var(--ink); }
.nav a.on { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; }
.nav a.on .ic { color: var(--accent); }
.nav .cnt { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--accent); }
.nav .cnt.dim { color: var(--ink3); font-weight: 500; }
.side h6 { margin: 18px 10px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink3); font-weight: 700; }
.side .grow { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; position: relative; }
.me .who { min-width: 0; flex: 1; }
.me .who b { display: block; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who span { display: block; font-size: 12px; color: var(--ink3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font: 600 14px var(--serif); color: #fff; flex: none; text-transform: uppercase; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; border-radius: 7px; }

/* list pane */
.listpane { border-right: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.lhead { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px; border-bottom: 1px solid var(--line2); }
.lhead h2 { font: 600 20px var(--serif); margin: 0 auto 0 4px; letter-spacing: -.01em; }
.searchbox { position: relative; padding: 8px 12px; border-bottom: 1px solid var(--line2); }
.searchbox .ic { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); color: var(--ink3); pointer-events: none; }
.searchbox input { padding-left: 34px; background: var(--paper); }
.mlist { overflow: auto; flex: 1; min-height: 0; }
.msg { display: grid; grid-template-columns: 34px 1fr auto; gap: 2px 11px; padding: 11px 14px 11px 16px; border-bottom: 1px solid var(--line2); cursor: pointer; position: relative; text-decoration: none; color: inherit; }
.msg:hover { background: var(--paper); }
.msg.sel { background: var(--paper); box-shadow: inset 3px 0 0 var(--accent); }
.msg .avatar { grid-row: 1 / span 3; margin-top: 2px; }
.msg .from { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .when { font-size: 12px; color: var(--ink3); white-space: nowrap; align-self: center; }
.msg .subj { grid-column: 2 / span 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.msg .snip { grid-column: 2 / span 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink3); font-size: 13px; }
.msg.unread .from, .msg.unread .subj { font-weight: 700; }
.msg.unread::before { content: ""; position: absolute; left: 5px; top: 22px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.msg .badges { display: inline-flex; gap: 4px; margin-left: 6px; color: var(--ink3); vertical-align: -3px; }
.msg .badges .ic { width: 14px; height: 14px; }
.more { padding: 12px; text-align: center; }

/* reader */
.reader { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--paper); }
.rbar { display: flex; align-items: center; gap: 4px; padding: 10px 14px; border-bottom: 1px solid var(--line2); background: var(--card); min-height: 56px; }
.rbar .sp { flex: 1; }
.rbar .btn.back { display: none; }
.rbody { overflow: auto; flex: 1; padding: 26px clamp(16px, 4vw, 44px) 40px; }
.rbody > .inner { max-width: 820px; margin: 0 auto; }
.rsubj { font: 600 27px/1.2 var(--serif); letter-spacing: -.015em; margin: 0 0 18px; overflow-wrap: anywhere; }
.rhead { display: flex; gap: 13px; align-items: flex-start; padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.rhead .avatar { width: 42px; height: 42px; font-size: 17px; border-radius: 11px; }
.rhead .meta { min-width: 0; flex: 1; }
.rhead .nm { font-weight: 650; }
.rhead .ad { color: var(--ink3); font-family: var(--mono); font-size: 12.5px; }
.rhead .dt { color: var(--ink3); font-size: 12.5px; white-space: nowrap; }
.rhead .tos { font-size: 13px; color: var(--ink2); margin-top: 3px; overflow-wrap: anywhere; }
.textbody { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.6; }
.htmlwrap { background: #fff; color: #111; border-radius: 8px; border: 1px solid var(--line); overflow: hidden; }
.htmlwrap iframe { display: block; width: 100%; border: 0; min-height: 200px; background: #fff; }
.imgbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--warn-soft); font-size: 13px; margin-bottom: 10px; border-radius: 8px; }
.imgbar .btn { margin-left: auto; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--line); }
.att { display: inline-flex; align-items: center; gap: 9px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); text-decoration: none; color: var(--ink); max-width: 100%; }
.att:hover { border-color: var(--accent); }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att small { color: var(--ink3); }
.empty { display: grid; place-items: center; text-align: center; padding: 48px 24px; color: var(--ink2); flex: 1; align-content: center; gap: 6px; }
.empty h3 { font: 600 20px var(--serif); margin: 8px 0 0; color: var(--ink); }
.empty p { margin: 0; max-width: 36ch; }
.reader > .empty { background: var(--paper); }

/* compose */
.scrim { position: fixed; inset: 0; background: rgba(20, 15, 5, .35); z-index: 40; display: flex; align-items: flex-end; justify-content: flex-end; padding: 0 24px; }
.composer { width: min(640px, 100%); max-height: min(720px, calc(100dvh - 24px)); background: var(--card); border: 1px solid var(--line); border-radius: 12px 12px 0 0; box-shadow: 0 -10px 50px -10px rgba(0,0,0,.35); display: flex; flex-direction: column; animation: rise .22s cubic-bezier(.2,.9,.3,1) both; }
@keyframes rise { from { transform: translateY(24px); opacity: 0 } }
.chead { display: flex; align-items: center; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line2); }
.chead b { font: 600 16px var(--serif); margin-right: auto; }
.crow { display: flex; align-items: center; border-bottom: 1px solid var(--line2); padding: 0 14px; min-height: 42px; }
.crow label { width: 58px; color: var(--ink3); font-size: 13px; flex: none; }
.crow input { border: 0; box-shadow: none !important; background: transparent; padding-left: 0; min-height: 40px; }
.crow .lnk { background: none; border: 0; color: var(--ink3); font-size: 13px; padding: 4px 6px; }
.crow .lnk:hover { color: var(--accent); }
.composer textarea { flex: 1; min-height: 240px; border: 0; border-radius: 0; box-shadow: none !important; padding: 14px 16px; resize: none; background: transparent; font-size: 15px; line-height: 1.55; }
.composer textarea:focus-visible, .crow input:focus-visible { outline: none; }
.cfoot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line2); flex-wrap: wrap; }
.cfoot .grow { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 14px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 99px; background: var(--sunk); font-size: 12.5px; max-width: 240px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: var(--ink3); padding: 0; }
.chip button:hover { background: var(--line); color: var(--ink); }
.cerr { margin: 8px 14px 0; }
.drop { outline: 2px dashed var(--accent); outline-offset: -8px; }

/* admin */
.apane { overflow: auto; min-height: 0; background: var(--paper); }
.ahead { padding: 22px clamp(16px, 4vw, 40px) 0; max-width: 980px; margin: 0 auto; }
.ahead h1 { font: 600 28px var(--serif); margin: 0 0 4px; letter-spacing: -.015em; }
.tabs { display: flex; gap: 2px; margin-top: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--ink2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 550; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-color: var(--accent); }
.tabs a.on .ic { color: var(--accent); }
.abody { padding: 22px clamp(16px, 4vw, 40px) 60px; max-width: 980px; margin: 0 auto; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 4px; font: 600 18px var(--serif); display: flex; align-items: center; gap: 9px; }
.panel > .sub { margin: 0 0 16px; color: var(--ink2); font-size: 13.5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--ink3); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 7px; }
.stat .v { font: 600 22px var(--serif); margin-top: 6px; overflow-wrap: anywhere; }
.stat .s { font-size: 12.5px; color: var(--ink3); margin-top: 2px; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11.5px; color: var(--ink3); text-transform: uppercase; letter-spacing: .06em; padding: 0 10px 8px; font-weight: 700; }
.t td { padding: 10px; border-top: 1px solid var(--line2); vertical-align: middle; }
.t td.r { text-align: right; white-space: nowrap; }
.t .nm { display: flex; align-items: center; gap: 10px; }
.tscroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.logbox { background: #14120e; color: #d8d0bf; font: 12.5px/1.55 var(--mono); border-radius: 8px; padding: 12px 14px; max-height: 280px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.logbox .good { color: #7ecfae; } .logbox .badl { color: #f08a80; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.sb { justify-content: space-between; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--ink3); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.dnsrow { display: grid; grid-template-columns: 24px 120px 1fr; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--line2); align-items: start; }
.dnsrow:first-of-type { border-top: 0; }
.dnsrow .st .ic { width: 18px; height: 18px; }
.dnsrow .st.ok { color: var(--ok); } .dnsrow .st.no { color: var(--warn); }
.dnsrow .nm { font-weight: 600; }
.dnsrow .vals { font-family: var(--mono); font-size: 12px; color: var(--ink2); overflow-wrap: anywhere; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; z-index: 80; box-shadow: var(--shadow); font-size: 13.5px; display: flex; gap: 8px; align-items: center; animation: fadeIn .2s both; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); color: #fff; }
.menu { position: absolute; bottom: 52px; left: 8px; right: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 5px; z-index: 30; animation: fadeIn .15s both; }
.menu button, .menu a { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 7px; text-align: left; text-decoration: none; color: var(--ink); }
.menu button:hover, .menu a:hover { background: var(--sunk); }
.modal { position: fixed; inset: 0; background: rgba(20, 15, 5, .4); z-index: 60; display: grid; place-items: center; padding: 16px; }
.dialog { width: min(440px, 100%); background: var(--card); border-radius: 12px; border: 1px solid var(--line); padding: 22px; box-shadow: var(--shadow); animation: fadeIn .18s both; }
.dialog h3 { margin: 0 0 12px; font: 600 20px var(--serif); }
.dialog .row { justify-content: flex-end; margin-top: 8px; }
.mobbar { display: none; }
.hide-s { display: inline; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .shell { grid-template-columns: 200px minmax(280px, 340px) minmax(0, 1fr); }
  .shell.admin { grid-template-columns: 200px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell, .shell.admin { grid-template-columns: 1fr; position: relative; }
  .side { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 50; transform: translateX(-102%); transition: transform .25s cubic-bezier(.3,.9,.3,1); box-shadow: var(--shadow); }
  .navopen .side { transform: none; }
  .navopen::after { content: ""; position: fixed; inset: 0; background: rgba(20,15,5,.4); z-index: 45; }
  .navopen .side { z-index: 50; }
  .shell .reader { display: none; }
  .shell[data-view="read"] .listpane { display: none; }
  .shell[data-view="read"] .reader { display: flex; }
  .rbar .btn.back { display: inline-flex; }
  .mobbar { display: flex; }
  .hide-s { display: none; }
  .scrim { padding: 0; align-items: stretch; }
  .composer { width: 100%; max-height: none; height: 100%; border-radius: 0; border: 0; }
  .grid2 { grid-template-columns: 1fr; }
  .rsubj { font-size: 23px; }
  .kv { grid-template-columns: 1fr; gap: 0; } .kv dt { margin-top: 8px; }
  .dnsrow { grid-template-columns: 24px 1fr; } .dnsrow .vals { grid-column: 2; }
  .paper-card { padding: 28px 22px 22px; }
}
