/* TG Архив — монохромный тёмный интерфейс в духе Grok */
:root{
  --bg:#000;--bg-2:#0a0a0a;--surface:#111;--surface-2:#191919;--hover:#1f1f1f;
  --border:#262626;--border-2:#363636;
  --text:#fafafa;--text-2:#cfcfcf;--muted:#8d8d8d;--faint:#5f5f5f;
  --inv:#fff;--inv-text:#000;--danger:#ff6b6b;
  --r-xl:28px;--r-lg:22px;--r-md:16px;
  --shadow:0 18px 60px rgba(0,0,0,.65);
  --font:ui-sans-serif,-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Inter,Roboto,"Helvetica Neue",Arial,sans-serif;
  color-scheme:dark;
}
@media (prefers-color-scheme:light){
  :root:not([data-theme="dark"]){
    --bg:#fff;--bg-2:#fafafa;--surface:#f4f4f4;--surface-2:#ececec;--hover:#e9e9e9;
    --border:#e5e5e5;--border-2:#d6d6d6;--text:#0b0b0b;--text-2:#333;--muted:#6f6f6f;--faint:#a9a9a9;
    --inv:#0b0b0b;--inv-text:#fff;--danger:#d93636;--shadow:0 18px 60px rgba(0,0,0,.12);color-scheme:light;
  }
}
:root[data-theme="light"]{
  --bg:#fff;--bg-2:#fafafa;--surface:#f4f4f4;--surface-2:#ececec;--hover:#e9e9e9;
  --border:#e5e5e5;--border-2:#d6d6d6;--text:#0b0b0b;--text-2:#333;--muted:#6f6f6f;--faint:#a9a9a9;
  --inv:#0b0b0b;--inv-text:#fff;--danger:#d93636;--shadow:0 18px 60px rgba(0,0,0,.12);color-scheme:light;
}

*{box-sizing:border-box}
html,body{margin:0;min-height:100%}
body{background:var(--bg);color:var(--text);font:15px/1.5 var(--font);-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}
button,input{font:inherit;color:inherit}
button{cursor:pointer;background:none;border:0;padding:0}
button:disabled{cursor:default}
a{color:inherit}
svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;flex:none}
:focus-visible{outline:2px solid var(--text);outline-offset:2px}
[hidden]{display:none!important}

/* ---------- top bar ---------- */
.topbar{position:sticky;top:0;z-index:20;display:flex;align-items:center;justify-content:space-between;height:60px;padding:0 20px;background:color-mix(in srgb,var(--bg) 82%,transparent);backdrop-filter:saturate(1.4) blur(18px);-webkit-backdrop-filter:saturate(1.4) blur(18px)}
.brand{display:flex;align-items:center;gap:10px;text-decoration:none;font-weight:600;letter-spacing:-.01em}
.mark{width:26px;height:26px;stroke-width:2.1}
.top-actions{display:flex;align-items:center;gap:6px}
.icon-btn{width:38px;height:38px;border-radius:50%;display:grid;place-items:center;color:var(--muted);transition:background .15s,color .15s}
.icon-btn:hover{background:var(--surface-2);color:var(--text)}
.icon-btn svg{width:19px;height:19px}
.me{display:flex;align-items:center;gap:10px;padding:4px 14px 4px 4px;border:1px solid var(--border);border-radius:999px;margin-right:4px}
.me-name{font-size:14px;max-width:160px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* ---------- avatar ---------- */
.av{width:42px;height:42px;border-radius:50%;background:var(--surface-2);display:grid;place-items:center;font-size:14px;font-weight:600;color:var(--text-2);flex:none;letter-spacing:.02em}
.av.sm{width:30px;height:30px;font-size:12px}

/* ---------- auth ---------- */
.auth{min-height:100vh;min-height:100dvh;display:flex;flex-direction:column}
.auth-main{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:24px 16px 48px;width:100%;max-width:680px;margin:0 auto}
.hero{text-align:center;margin-bottom:34px;animation:rise .5s cubic-bezier(.2,.8,.2,1) both}
.hero .mark{width:54px;height:54px;stroke-width:1.6;margin-bottom:22px}
.hero h1{font-size:clamp(30px,5.4vw,42px);font-weight:500;letter-spacing:-.035em;line-height:1.1;margin:0 0 12px}
.hero p{margin:0 auto;max-width:460px;color:var(--muted);font-size:16px}
.auth-foot{padding:18px 20px 26px;text-align:center;color:var(--faint);font-size:12.5px}
.auth-foot span{display:inline-flex;align-items:center;gap:6px}
.auth-foot svg{width:14px;height:14px}

/* ---------- composer (поле как у Grok) ---------- */
.composer{width:100%;background:var(--surface);border:1px solid var(--border);border-radius:var(--r-xl);padding:8px;transition:border-color .2s,box-shadow .2s;animation:rise .55s .05s cubic-bezier(.2,.8,.2,1) both}
.composer:focus-within{border-color:var(--border-2)}
.composer-row{display:flex;align-items:center;gap:8px}
.composer-row input{flex:1;min-width:0;height:48px;background:none;border:0;outline:0;padding:0 8px 0 16px;font-size:17px}
.composer-row input::placeholder,.searchbar input::placeholder,.inp input::placeholder{color:var(--faint)}
.composer-row input.code{letter-spacing:.5em;font-size:22px;font-variant-numeric:tabular-nums}
.send{width:44px;height:44px;border-radius:50%;background:var(--inv);color:var(--inv-text);display:grid;place-items:center;flex:none;transition:transform .15s,opacity .15s}
.send:hover:not(:disabled){transform:scale(1.05)}
.send:disabled{opacity:.25}
.send svg{stroke-width:2.3}
.api-fields{display:grid;grid-template-columns:1fr 2fr;gap:8px;padding:6px 6px 10px;border-bottom:1px solid var(--border);margin-bottom:6px}
.api-fields input{height:42px;border-radius:14px;background:var(--bg-2);border:1px solid var(--border);padding:0 14px;outline:0;font-size:14px;min-width:0}
.api-fields input:focus{border-color:var(--border-2)}
.api-fields p{grid-column:1/-1;margin:2px 4px 0;font-size:12.5px;color:var(--muted)}
.api-fields a{color:var(--text)}

.chips{display:flex;flex-wrap:wrap;gap:8px}
.chips.center{justify-content:center;margin-top:16px}
.chip{display:inline-flex;align-items:center;gap:7px;height:36px;padding:0 15px;border-radius:999px;border:1px solid var(--border);color:var(--text-2);font-size:14px;white-space:nowrap;transition:background .15s,border-color .15s,color .15s}
.chip svg{width:16px;height:16px}
.chip:hover{background:var(--surface-2)}
.chip[aria-pressed="true"]{background:var(--inv);color:var(--inv-text);border-color:var(--inv)}
.chip.static{cursor:default}
.chip.static:hover{background:none}
.chip .n{color:var(--muted);font-size:12.5px}
.chip[aria-pressed="true"] .n{color:inherit;opacity:.6}

.error{min-height:22px;margin:14px 0 0;color:var(--danger);font-size:14px;text-align:center}
.shake{animation:shake .35s}

/* ---------- main ---------- */
.shell{min-height:100vh;min-height:100dvh}
.main{max-width:780px;margin:0 auto;padding:12px 16px 220px}
.greet{padding:28px 4px 22px;animation:rise .45s cubic-bezier(.2,.8,.2,1) both}
.greet h1{font-size:clamp(26px,4.4vw,34px);font-weight:500;letter-spacing:-.03em;margin:0 0 6px;line-height:1.15}
.greet p{margin:0;color:var(--muted)}
.searchbar{display:flex;align-items:center;gap:10px;height:52px;padding:0 18px;border:1px solid var(--border);border-radius:999px;background:var(--surface);color:var(--muted);transition:border-color .2s}
.searchbar:focus-within{border-color:var(--border-2)}
.searchbar input{flex:1;min-width:0;border:0;outline:0;background:none;font-size:16px;color:var(--text)}
.filters{margin:14px 0 18px}
.listhead{display:flex;align-items:center;justify-content:space-between;padding:0 6px 10px;font-size:13.5px;color:var(--muted)}
.link{color:var(--text);font-size:13.5px;font-weight:500;padding:4px 2px}
.link:hover{text-decoration:underline;text-underline-offset:3px}

.chatlist{list-style:none;margin:0;padding:0}
.row{width:100%;display:flex;align-items:center;gap:14px;padding:10px 12px;border-radius:18px;text-align:left;transition:background .12s}
.row:hover{background:var(--surface)}
.row.on{background:var(--surface)}
.tick{width:22px;height:22px;border-radius:50%;border:1.6px solid var(--border-2);display:grid;place-items:center;flex:none;transition:all .15s}
.tick svg{width:14px;height:14px;stroke-width:3;opacity:0;transform:scale(.6);transition:all .15s}
.row.on .tick{background:var(--inv);border-color:var(--inv);color:var(--inv-text)}
.row.on .tick svg{opacity:1;transform:none}
.row-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px}
.row-top{display:flex;align-items:center;gap:8px;min-width:0}
.row-top b{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.row-top time{margin-left:auto;flex:none;font-size:12.5px;color:var(--faint)}
.row small{color:var(--muted);font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tag{font-style:normal;font-size:11px;color:var(--muted);border:1px solid var(--border);border-radius:999px;padding:0 7px;flex:none}
.empty{color:var(--muted);text-align:center;padding:48px 0}
.skel .av,.skel i{background:var(--surface-2);animation:pulse 1.4s ease-in-out infinite}
.skel i{display:block;height:11px;border-radius:6px}
.skel i:first-child{width:46%}.skel i+i{width:28%;margin-top:7px;opacity:.6}
.skel:nth-child(2n) i:first-child{width:34%}.skel:nth-child(3n) i:first-child{width:58%}.skel:nth-child(3n) i+i{width:20%}

/* ---------- dock ---------- */
.dock{position:fixed;left:0;right:0;bottom:0;z-index:15;padding:0 16px max(16px,env(safe-area-inset-bottom));pointer-events:none;background:linear-gradient(to top,var(--bg) 55%,transparent)}
.dock .composer{max-width:780px;margin:0 auto;padding:12px;pointer-events:auto;box-shadow:var(--shadow);animation:none;background:var(--surface)}
.dock .chips{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;padding:2px;margin:-2px}
.dock .chips::-webkit-scrollbar{display:none}
.dock-row{display:flex;align-items:center;gap:8px;margin-top:10px}
.dock-row .spacer{flex:1}
.seg{display:inline-flex;border:1px solid var(--border);border-radius:999px;padding:3px;gap:2px}
.seg button{height:28px;padding:0 12px;border-radius:999px;font-size:12.5px;font-weight:500;color:var(--muted);letter-spacing:.02em}
.seg button[aria-pressed="true"]{background:var(--surface-2);color:var(--text)}
.go{display:inline-flex;align-items:center;gap:10px;height:44px;padding:0 6px 0 18px;border-radius:999px;background:var(--inv);color:var(--inv-text);font-weight:600;font-size:14.5px;white-space:nowrap;transition:opacity .15s,transform .15s}
.go:hover:not(:disabled){transform:translateY(-1px)}
.go:disabled{opacity:.25}
.go .gi{width:32px;height:32px;border-radius:50%;background:var(--inv-text);color:var(--inv);display:grid;place-items:center}
.go .gi svg{width:17px;height:17px;stroke-width:2.4}
.limits{max-width:240px;overflow:hidden;text-overflow:ellipsis}
.settings{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;padding:4px 2px 14px;margin-bottom:12px;border-bottom:1px solid var(--border)}
.field{display:flex;flex-direction:column;gap:6px;font-size:12.5px;color:var(--muted);min-width:0}
.inp{display:flex;align-items:center;height:42px;border:1px solid var(--border);border-radius:14px;background:var(--bg-2);padding:0 12px;gap:6px}
.inp:focus-within{border-color:var(--border-2)}
.inp input{flex:1;min-width:0;border:0;outline:0;background:none;font-size:14.5px;color:var(--text)}
.inp input[type="date"]{font-size:13.5px}
.inp em{font-style:normal;color:var(--faint);font-size:12.5px}
.presets{grid-column:1/-1;display:flex;gap:6px;flex-wrap:wrap}
.presets .chip{height:30px;font-size:12.5px;padding:0 12px}

/* ---------- job ---------- */
.job{min-height:calc(100vh - 60px);min-height:calc(100dvh - 60px);display:flex;align-items:center;justify-content:center;padding:24px 16px 64px}
.job-card{width:100%;max-width:560px;text-align:center;animation:rise .45s cubic-bezier(.2,.8,.2,1) both}
.job-card h1{font-size:clamp(28px,5vw,38px);font-weight:500;letter-spacing:-.035em;margin:0 0 8px}
.job-sub{color:var(--muted);margin:0 0 28px;min-height:24px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.orb{width:64px;height:64px;margin:0 auto 26px;border-radius:50%;display:grid;place-items:center;position:relative}
.orb.spin::before{content:"";position:absolute;inset:0;border-radius:50%;border:2px solid var(--border);border-top-color:var(--text);animation:spin 1s linear infinite}
.orb.spin svg{width:24px;height:24px;color:var(--muted)}
.orb.ok{background:var(--inv);color:var(--inv-text)}
.orb.ok svg{width:28px;height:28px;stroke-width:2.6}
.orb.bad{border:1.5px solid var(--border-2);color:var(--muted)}
.bar{height:4px;border-radius:4px;background:var(--surface-2);overflow:hidden;margin:0 0 24px}
.bar i{display:block;height:100%;background:var(--text);border-radius:4px;transition:width .6s cubic-bezier(.2,.8,.2,1)}
.stats{display:grid;grid-template-columns:repeat(4,1fr);border:1px solid var(--border);border-radius:var(--r-lg);overflow:hidden;margin-bottom:22px}
.stats div{padding:16px 8px;display:flex;flex-direction:column;gap:2px}
.stats div+div{border-left:1px solid var(--border)}
.stats b{font-size:19px;font-weight:500;letter-spacing:-.02em;font-variant-numeric:tabular-nums}
.stats span{font-size:12px;color:var(--muted)}
.note{color:var(--muted);font-size:13.5px;min-height:20px;margin:0 0 18px}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:10px;height:48px;padding:0 24px;border-radius:999px;font-weight:600;font-size:15px;text-decoration:none;transition:transform .15s,background .15s}
.btn.primary{background:var(--inv);color:var(--inv-text);height:54px;padding:0 30px;font-size:16px}
.btn.primary:hover{transform:translateY(-1px)}
.btn.ghost{border:1px solid var(--border);color:var(--text-2)}
.btn.ghost:hover{background:var(--surface-2)}
.btn svg{stroke-width:2.3}
.actions{display:flex;flex-direction:column;align-items:center;gap:12px}
.muted{color:var(--muted);font-size:13.5px;margin:4px 0 0}
.warns{margin:26px auto 0;padding:14px 18px;border:1px dashed var(--border-2);border-radius:var(--r-md);text-align:left;font-size:13px;color:var(--muted);list-style:none}
.warns li+li{margin-top:4px}

/* ---------- motion ---------- */
@keyframes rise{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
@keyframes spin{to{transform:rotate(360deg)}}
@keyframes pulse{50%{opacity:.45}}
@keyframes shake{20%,60%{transform:translateX(-6px)}40%,80%{transform:translateX(6px)}}
.spinner{width:18px;height:18px;border-radius:50%;border:2px solid currentColor;border-right-color:transparent;animation:spin .7s linear infinite}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}

/* ---------- mobile ---------- */
@media (max-width:720px){
  .topbar{padding:0 12px}
  .me{padding:3px;border:0;margin:0}
  .me-name{display:none}
  .main{padding:4px 12px 250px}
  .greet{padding:18px 4px 16px}
  .filters{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;margin:12px -12px 14px;padding:0 12px}
  .filters::-webkit-scrollbar{display:none}
  .settings{grid-template-columns:1fr 1fr}
  .dock{padding:0 8px max(8px,env(safe-area-inset-bottom))}
  .dock .composer{padding:10px;border-radius:24px}
  .limits span{display:none}
  .go{padding-left:14px}
  .stats{grid-template-columns:1fr 1fr}
  .stats div:nth-child(3){border-left:0}
  .stats div:nth-child(n+3){border-top:1px solid var(--border)}
  .api-fields{grid-template-columns:1fr}
  .row{padding:9px 8px;gap:12px}
  .av{width:40px;height:40px}
}
