/* admin-dev — visual polish layer: motion, glass, native-app feel. Loaded after app.css. */
:root {
  --ease: cubic-bezier(.22, 1, .36, 1);          /* smooth deceleration */
  --spring: cubic-bezier(.34, 1.56, .64, 1);     /* small overshoot */
  --glass: color-mix(in srgb, var(--bg2) 72%, transparent);
  --glow: rgba(99, 102, 241, .35);
}

/* ---------- fix: no sideways overflow (cards used to get wider than the screen) ---------- */
body { overflow-x: clip; }
.main, .content, .grid > *, .card, .row > * { min-width: 0; }
.g2, .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4, .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }
.card .row.sm span { min-width: 0; }
.logbox { max-width: 100%; }
img, svg { max-width: 100%; }
.tablewrap { -webkit-overflow-scrolling: touch; }

/* ---------- ambient background ---------- */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(600px 420px at 12% 8%, rgba(99,102,241,.30), transparent 65%), radial-gradient(520px 380px at 90% 92%, rgba(139,92,246,.24), transparent 65%);
  background-size: 130% 130%; opacity: .8; animation: bgmove 24s ease-in-out infinite alternate; }
:root[data-theme="light"] body::before { opacity: .45; }
@keyframes bgmove { from { background-position: 0% 0%; } to { background-position: 100% 100%; } }

/* ---------- glass cards ---------- */
.card {
  background: linear-gradient(180deg, color-mix(in srgb, var(--card2) 55%, var(--card)), var(--card));
  border-color: color-mix(in srgb, var(--line2) 70%, transparent);
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 32px rgba(0,0,0,.28);
  transition: transform .35s var(--ease), border-color .25s, box-shadow .35s var(--ease);
}
:root[data-theme="light"] .card { box-shadow: 0 1px 0 #fff inset, 0 10px 26px rgba(20,30,60,.08); }
@media (hover: hover) { .card.stat:hover, .svc:hover { transform: translateY(-3px); border-color: rgba(99,102,241,.5); box-shadow: 0 16px 40px rgba(0,0,0,.35), 0 0 0 1px rgba(99,102,241,.18); } }
.card h3 { letter-spacing: .6px; font-size: 12.5px; }
.card h3::before { content: ""; width: 3px; height: 13px; border-radius: 3px; background: linear-gradient(var(--accent), var(--accent2)); flex: none; }
.stat .big { background: linear-gradient(180deg, var(--text), color-mix(in srgb, var(--text) 62%, var(--accent2))); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; font-variant-numeric: tabular-nums; }
.stat .big small { -webkit-text-fill-color: var(--muted); }

/* ---------- pills, status ---------- */
.pill.ok { box-shadow: 0 0 18px rgba(34,197,94,.18); }
.pill.ok::before { animation: dot 2s ease-in-out infinite; }
.pill.bad::before { animation: dot 1s ease-in-out infinite; }
@keyframes dot { 0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; } 50% { box-shadow: 0 0 0 4px transparent; opacity: .55; } }
.nav .badge, #alertBadge { animation: badge 2.4s ease-in-out infinite; }
@keyframes badge { 0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.55); } 50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); } }
.bar { background: color-mix(in srgb, var(--card2) 80%, #000); box-shadow: inset 0 1px 2px rgba(0,0,0,.35); }
.bar i { transition: width 1s var(--ease); box-shadow: 0 0 12px var(--glow); position: relative; overflow: hidden; }
.bar i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); transform: translateX(-100%); animation: sheen 3.6s ease-in-out infinite; }
@keyframes sheen { 55%, 100% { transform: translateX(100%); } }
.uptimebar i { transition: transform .2s var(--spring); } .uptimebar i:hover { transform: scaleY(1.25); }

/* ---------- buttons: pressed state like a native app ---------- */
.btn, .tab, .chip, .sess, .bottombar a, .nav a, .me, .burger { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.btn { transition: transform .25s var(--spring), border-color .2s, background .2s, box-shadow .25s; }
.btn:active, .tab:active, .chip:active, .sess:active { transform: scale(.95); transition-duration: .08s; }
.btn.primary:active { box-shadow: 0 3px 10px rgba(99,102,241,.35); }
.tab { transition: transform .25s var(--spring), background .25s, color .25s, border-color .25s; }
.tab.active { box-shadow: 0 6px 18px var(--glow); }
.chip { transition: transform .25s var(--spring), background .2s; }

/* ---------- top bar ---------- */
.top { transition: box-shadow .3s, background .3s; }
.top.scrolled { box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.top h1 { letter-spacing: -.3px; animation: titleIn .5s var(--ease) both; }
@keyframes titleIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
[data-act="theme"] svg { transition: transform .6s var(--spring); }
[data-act="theme"]:active svg { transform: rotate(180deg) scale(.8); }

/* ---------- page enter (stagger) ---------- */
.content.enter > *, .content.enter > .grid > *, .content.enter > .tabs, .content.enter .grid.g2 > *, .content.enter .grid.g3 > *, .content.enter .grid.g4 > * {
  animation: rise .65s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.975); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.content.enter > :nth-child(1) { animation-delay: 0s; } .content.enter > :nth-child(2) { animation-delay: .06s; } .content.enter > :nth-child(3) { animation-delay: .12s; }
.content.enter > :nth-child(4) { animation-delay: .18s; } .content.enter > :nth-child(5) { animation-delay: .24s; } .content.enter > :nth-child(n+6) { animation-delay: .3s; }
.content.enter .grid > :nth-child(1) { animation-delay: .04s; } .content.enter .grid > :nth-child(2) { animation-delay: .1s; }
.content.enter .grid > :nth-child(3) { animation-delay: .16s; } .content.enter .grid > :nth-child(4) { animation-delay: .22s; }
.content.enter .grid > :nth-child(5) { animation-delay: .28s; } .content.enter .grid > :nth-child(6) { animation-delay: .34s; } .content.enter .grid > :nth-child(n+7) { animation-delay: .4s; }
.content.enter svg.spark { animation: reveal 1.1s .25s var(--ease) both; }
@keyframes reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.content { animation: none; }

/* loading placeholder: shimmer instead of plain text */
.empty.is-loading { position: relative; color: transparent; min-height: 150px; border-radius: var(--r); overflow: hidden; background: linear-gradient(90deg, var(--card) 25%, var(--card2) 50%, var(--card) 75%); background-size: 220% 100%; animation: shimmer 1.3s linear infinite; }
.empty.is-loading::after { content: ""; position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px; border-radius: 50%; border: 3px solid rgba(99,102,241,.25); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes shimmer { to { background-position: -220% 0; } } @keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toasts / modals / palette ---------- */
.toast { background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); animation: toastIn .45s var(--spring) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(24px) scale(.9); } to { opacity: 1; transform: none; } }
.modal-bg, .palette-bg { animation: bgIn .25s ease both; }
@keyframes bgIn { from { opacity: 0; } to { opacity: 1; } }
.modal, .palette { animation: popIn .4s var(--spring) both; background: var(--glass); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); }
@keyframes popIn { from { opacity: 0; transform: translateY(24px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- login ---------- */
.auth .card { animation: popIn .7s var(--ease) both; backdrop-filter: blur(18px); }
.auth .brand, .auth .logo { animation: floaty 5s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translateY(-5px); } }
.logo { box-shadow: 0 8px 24px var(--glow), 0 1px 0 rgba(255,255,255,.35) inset; }

/* ---------- pull to refresh ---------- */
#ptr { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 58px); z-index: 45; width: 38px; height: 38px; margin-left: -19px; border-radius: 50%; display: grid; place-items: center; background: var(--glass); backdrop-filter: blur(14px); border: 1px solid var(--line2); box-shadow: var(--shadow); opacity: 0; transform: translateY(-30px) scale(.6); pointer-events: none; transition: opacity .2s, transform .3s var(--spring); }
#ptr svg { width: 18px; height: 18px; stroke: var(--accent); fill: none; stroke-width: 2.4; stroke-linecap: round; }
#ptr.pull { transition: none; }
#ptr.busy svg { animation: spin .8s linear infinite; }

/* ---------- splash ---------- */
#splash { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: var(--bg); transition: opacity .5s var(--ease), transform .6s var(--ease), visibility 0s .6s; }
#splash.hide { opacity: 0; transform: scale(1.06); visibility: hidden; pointer-events: none; }
#splash .lg { width: 84px; height: 84px; border-radius: 24px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: grid; place-items: center; box-shadow: 0 18px 50px var(--glow); animation: splashPop .8s var(--spring) both, floaty 3s 0.8s ease-in-out infinite; }
#splash .lg svg { width: 42px; height: 42px; stroke: #fff; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw .9s .3s var(--ease) forwards; }
#splash::after { content: ""; position: absolute; width: 84px; height: 84px; border-radius: 24px; border: 2px solid var(--accent); animation: ring 1.8s ease-out infinite; }
@keyframes splashPop { from { opacity: 0; transform: scale(.5) rotate(-12deg); } to { opacity: 1; transform: none; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes ring { from { opacity: .7; transform: scale(1); } to { opacity: 0; transform: scale(2.2); } }

/* ---------- phone: native feel ---------- */
.bottombar .tb-ind { display: none; }
@media (max-width: 860px) {
  .top { padding-top: max(12px, env(safe-area-inset-top)); background: var(--glass); }
  .top h1 { font-size: 22px; font-weight: 800; }
  .content { padding-top: 16px; }

  /* floating glass tab bar with a sliding highlight */
  .bottombar { left: 10px; right: 10px; bottom: calc(8px + env(safe-area-inset-bottom)); padding: 6px; border: 1px solid color-mix(in srgb, var(--line2) 80%, transparent); border-radius: 24px; background: var(--glass); backdrop-filter: blur(22px) saturate(1.6); -webkit-backdrop-filter: blur(22px) saturate(1.6); box-shadow: 0 14px 40px rgba(0,0,0,.45), 0 1px 0 rgba(255,255,255,.06) inset; animation: barIn .7s .1s var(--ease) both; }
  @keyframes barIn { from { transform: translateY(120%); } to { transform: none; } }
  .bottombar a { position: relative; z-index: 1; border-radius: 18px; transition: color .25s, transform .3s var(--spring); }
  .bottombar a.active { background: none; color: var(--text); }
  .bottombar a.active svg { color: var(--accent); transform: translateY(-1px) scale(1.12); filter: drop-shadow(0 4px 8px var(--glow)); }
  .bottombar a svg { transition: transform .35s var(--spring), color .25s; }
  .bottombar a:active { transform: scale(.88); }
  .bottombar .tb-ind { display: block; position: absolute; z-index: 0; top: 6px; bottom: 6px; left: 0; width: 0; border-radius: 18px; background: linear-gradient(135deg, rgba(99,102,241,.32), rgba(139,92,246,.2)); box-shadow: inset 0 0 0 1px rgba(99,102,241,.4), 0 6px 18px rgba(99,102,241,.25); transition: transform .45s var(--spring), width .45s var(--spring), opacity .25s; opacity: 0; }
  .content { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  #toasts { bottom: calc(96px + env(safe-area-inset-bottom)); }

  /* drawer: spring slide, dimmed blurred backdrop, staggered items */
  .side { transition: transform .5s var(--ease); transform: translateX(-104%); background: var(--glass); backdrop-filter: blur(26px) saturate(1.5); -webkit-backdrop-filter: blur(26px) saturate(1.5); border-radius: 0 26px 26px 0; box-shadow: none; }
  .side.open { transform: none; box-shadow: 0 0 80px rgba(0,0,0,.6); }
  .side.dragging { transition: none; }
  .scrim, .scrim.open { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .4s var(--ease); }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .side .nav a, .side .me, .side .brand { opacity: 0; transform: translateX(-18px); transition: opacity .35s var(--ease), transform .45s var(--ease), background .15s, color .15s; }
  .side.open .nav a, .side.open .me, .side.open .brand { opacity: 1; transform: none; }
  .side.open .brand { transition-delay: .05s; }
  .side.open .nav a:nth-child(1) { transition-delay: .08s; } .side.open .nav a:nth-child(2) { transition-delay: .11s; } .side.open .nav a:nth-child(3) { transition-delay: .14s; }
  .side.open .nav a:nth-child(4) { transition-delay: .17s; } .side.open .nav a:nth-child(5) { transition-delay: .2s; } .side.open .nav a:nth-child(6) { transition-delay: .23s; }
  .side.open .nav a:nth-child(7) { transition-delay: .26s; } .side.open .nav a:nth-child(8) { transition-delay: .29s; } .side.open .nav a:nth-child(9) { transition-delay: .32s; }
  .side.open .nav a:nth-child(10) { transition-delay: .35s; } .side.open .nav a:nth-child(n+11) { transition-delay: .38s; } .side.open .me { transition-delay: .42s; }
  .nav a { border-radius: 14px; } .nav a:active { transform: scale(.97); }

  .card { border-radius: 20px; }
  .btn { border-radius: 14px; }
  .modal { animation: sheetIn .5s var(--ease) both; background: var(--card); border-radius: 26px 26px 0 0; }
  .modal::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 5px; background: var(--line2); margin: -6px auto 14px; }
  .stat .big { font-size: 30px; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; margin-left: -12px; margin-right: -12px; padding: 0 12px 4px; }
  .tabs::-webkit-scrollbar { display: none; } .tab { flex: none; }
}

/* ---------- accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  body::before { animation: none; }
}

/* ================= Claude feed ================= */
.chat { gap: 14px; }
.msg { white-space: normal; max-width: min(860px, 100%); padding: 0; border: none; background: none; display: flex; gap: 10px; align-items: flex-start; animation: msgIn .45s var(--ease) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.msg .who { margin-bottom: 6px; font-size: 10.5px; opacity: .8; }
.msg.user { align-self: flex-end; flex-direction: column; align-items: flex-end; max-width: 88%; padding: 11px 15px; border-radius: 20px 20px 6px 20px; background: linear-gradient(135deg, #6366f1, #8b5cf6); border: none; color: #fff; box-shadow: 0 10px 26px rgba(99,102,241,.32); }
.msg.user .who { color: rgba(255,255,255,.75); margin-bottom: 3px; } .msg.user code { background: rgba(0,0,0,.25); color: #fff; }
.msg.claude { align-self: flex-start; width: 100%; }
.msg .av { flex: none; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, rgba(99,102,241,.3), rgba(56,189,248,.2)); box-shadow: inset 0 0 0 1px rgba(99,102,241,.4); color: var(--accent); margin-top: 2px; }
.msg .av svg { width: 16px; height: 16px; }
.msg .bub { min-width: 0; flex: 1; padding: 12px 15px; border-radius: 6px 20px 20px 20px; background: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0,0,0,.18); }

.md { line-height: 1.62; font-size: 15px; overflow-wrap: anywhere; }
.md p { margin: 0 0 9px; } .md > :last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 10px; padding-left: 22px; } .md li { margin: 3px 0; } .md li::marker { color: var(--accent); font-weight: 700; }
.md .mdh { margin: 14px 0 7px; font-size: 15.5px; font-weight: 800; letter-spacing: -.1px; display: flex; align-items: center; gap: 8px; }
.md .mdh::before { content: ""; width: 4px; height: 15px; border-radius: 4px; background: linear-gradient(var(--accent), var(--accent2)); }
.md strong { font-weight: 700; color: var(--text); } .md em { color: var(--muted); }
.md a { text-decoration: underline; text-underline-offset: 3px; }
.md code { font-family: var(--mono); font-size: .86em; padding: 2px 6px; border-radius: 7px; background: color-mix(in srgb, var(--accent) 16%, var(--bg2)); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); color: color-mix(in srgb, var(--text) 85%, var(--accent)); word-break: break-word; }
.md .codeblock { margin: 8px 0; padding: 12px 14px; border-radius: 14px; background: #07090d; border: 1px solid var(--line); color: #cbd5e1; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; overflow-x: auto; white-space: pre; -webkit-overflow-scrolling: touch; }
.md .mdrow { display: flex; gap: 8px; padding: 6px 10px; margin: 2px 0; border-radius: 10px; background: color-mix(in srgb, var(--card2) 70%, transparent); font-size: 13.5px; }
.md .mdrow span { flex: 1; min-width: 0; } .md .mdrow span:first-child { font-weight: 700; flex: .7; }

/* tool calls: compact chips instead of mono walls of text */
.tool { align-self: flex-start; max-width: 100%; display: flex; align-items: baseline; gap: 8px; padding: 6px 12px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--card) 80%, transparent); font-size: 12px; color: var(--muted); margin-left: 40px; animation: msgIn .4s var(--ease) both; }
.tool b { flex: none; padding: 1px 8px; border-radius: 99px; background: rgba(56,189,248,.14); color: var(--info); font-size: 11px; letter-spacing: .3px; margin: 0; }
.tool span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
details.tool.res { display: block; padding: 0; border-left-color: var(--dim); }
details.tool.res summary { list-style: none; cursor: pointer; padding: 5px 12px; font-weight: 600; } details.tool.res summary::-webkit-details-marker { display: none; }
details.tool.res summary::before { content: "▸"; display: inline-block; margin-right: 6px; transition: transform .25s var(--spring); } details.tool.res[open] summary::before { transform: rotate(90deg); }
details.tool.res pre { margin: 0; padding: 8px 12px 10px; max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 11.5px; border-top: 1px solid var(--line); }
details.tool.err { border-left-color: var(--bad); } details.tool.err summary { color: #fca5a5; }

/* session list */
.sess { position: relative; padding: 13px 15px; border-radius: 16px; overflow: hidden; transition: transform .3s var(--spring), border-color .2s, background .2s; }
.sess.active { border-color: rgba(99,102,241,.6); background: linear-gradient(135deg, rgba(99,102,241,.18), rgba(139,92,246,.1)); box-shadow: 0 8px 24px rgba(99,102,241,.2); }
.sess.active::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: linear-gradient(var(--accent), var(--accent2)); }
.live { padding: 3px 10px; border-radius: 99px; background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); }
.bottombar a { white-space: nowrap; }
@media (max-width: 860px) {
  .msg.user { max-width: 92%; } .msg .av { width: 26px; height: 26px; border-radius: 9px; }
  .msg .bub { padding: 11px 13px; } .md { font-size: 15px; } .tool { margin-left: 36px; }
  #clist { gap: 10px; }
}

/* Face ID button */
[data-act="pk-login"] { gap: 10px; font-size: 16px; } [data-act="pk-login"] svg { width: 22px; height: 22px; }
@media (max-width: 860px) {
  /* drawer content must scroll instead of being cut off */
  .side { height: 100%; max-height: 100dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}

/* ================= list rows (account: passkeys, sessions) ================= */
.lrow { display: flex; align-items: center; gap: 12px; padding: 11px 12px; margin: 8px 0; border-radius: 16px; background: color-mix(in srgb, var(--card2) 70%, transparent); border: 1px solid var(--line); transition: transform .3s var(--spring), border-color .2s; }
.lrow:last-child { margin-bottom: 0; }
.lrow.cur { border-color: rgba(34,197,94,.4); background: linear-gradient(135deg, rgba(34,197,94,.1), transparent 70%); }
.lico { flex: none; width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: var(--accent); background: linear-gradient(135deg, rgba(99,102,241,.22), rgba(139,92,246,.12)); box-shadow: inset 0 0 0 1px rgba(99,102,241,.3); }
.lico.pc { color: var(--info); background: linear-gradient(135deg, rgba(56,189,248,.2), rgba(56,189,248,.06)); box-shadow: inset 0 0 0 1px rgba(56,189,248,.3); }
.lico.key { color: var(--warn); background: linear-gradient(135deg, rgba(245,158,11,.2), rgba(245,158,11,.05)); box-shadow: inset 0 0 0 1px rgba(245,158,11,.3); }
.lico svg { width: 20px; height: 20px; }
.lmain { flex: 1; min-width: 0; } .lmain b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .btn { flex: none; }
#pkname { max-width: 100% !important; }
.card .row.mt { align-items: stretch; }

/* ================= tables ================= */
table { border-collapse: separate; border-spacing: 0; }
th { background: color-mix(in srgb, var(--card2) 60%, transparent); }
th:first-child { border-radius: 10px 0 0 10px; } th:last-child { border-radius: 0 10px 10px 0; }
th { border-bottom: none; }
td { border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
@media (max-width: 860px) {
  .tablewrap { overflow: visible; }
  table.rt, table.rt tbody { display: block; width: 100%; }
  table.rt thead { display: none; }
  table.rt tr { display: block; margin: 0 0 10px; padding: 8px 12px; border-radius: 16px; border: 1px solid var(--line); background: color-mix(in srgb, var(--card2) 65%, transparent); animation: msgIn .4s var(--ease) both; }
  table.rt td { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 7px 0; border: none; text-align: right; word-break: break-word; min-width: 0; }
  table.rt td + td { border-top: 1px dashed color-mix(in srgb, var(--line) 80%, transparent); }
  table.rt td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; text-align: left; }
  table.rt td:not([data-label])::before { display: none; }
  table.rt td.hide-m { display: none; }
  table.rt tbody tr:hover td { background: none; }
  table.rt td .btn { margin-left: auto; }
  .card { overflow: hidden; }
}

/* ================= app lock ================= */
#lock { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(30px) saturate(1.4); -webkit-backdrop-filter: blur(30px) saturate(1.4); animation: bgIn .3s ease both; transition: opacity .4s var(--ease), transform .4s var(--ease); }
#lock.out { opacity: 0; transform: scale(1.04); pointer-events: none; }
#lock .lk { width: 100%; max-width: 340px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; animation: popIn .6s var(--ease) both; }
#lock .logo { width: 72px; height: 72px; border-radius: 22px; animation: floaty 4s ease-in-out infinite; } #lock .logo svg { width: 36px; height: 36px; }
#lock h2 { margin: 6px 0 0; font-size: 24px; } #lock p { margin: 0 0 10px; color: var(--muted); }
#lock .btn { width: 100%; justify-content: center; padding: 14px; font-size: 16px; } #lock .btn svg { width: 22px; height: 22px; }

/* ---- chat fixes: no sideways overflow, tighter type ---- */
.chat { min-width: 0; max-width: 100%; overflow: hidden; }
.chat > * { min-width: 0; max-width: 100%; }
.tool { width: fit-content; max-width: calc(100% - 40px); overflow: hidden; }
.tool span { flex: 1 1 0; min-width: 0; }
details.tool.res { width: auto; }
details.tool.res pre { max-width: 100%; }
.md { font-size: 14.5px; line-height: 1.56; }
.md ul, .md ol { padding-left: 20px; margin: 3px 0 9px; }
.md li > ul, .md li > ol { margin: 2px 0; }
.msg.claude { min-width: 0; } .msg .bub { max-width: calc(100% - 40px); }
.msg.user { min-width: 0; } .msg.user .md { text-align: left; }
@media (max-width: 860px) {
  .content { overflow-x: clip; }
  .md { font-size: 14.5px; } .msg .bub { padding: 10px 13px; } .msg.user { padding: 10px 14px; }
  .tool { max-width: calc(100% - 36px); }
}

/* number inputs + backup rows */
input[type=number] { width: auto; padding: 9px 12px; border-radius: 11px; border: 1px solid var(--line2); background: var(--bg2); color: var(--text, inherit); outline: none; text-align: center; font-weight: 700; -moz-appearance: textfield; appearance: textfield; transition: .15s; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.2); }
.chk input[type=number] { width: 72px; height: auto; margin: 0 4px; }
.chk input[type=radio] { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.chk { flex-wrap: wrap; }
.chk .grow { flex: 1 1 140px; min-width: 0; }
.bkkeep { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.bkkeep input[type=number] { width: 72px; }
html, body { touch-action: pan-x pan-y; }

/* image viewer */
body.noscroll { overflow: hidden; }
.imgv { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: rgba(6,7,14,.88); backdrop-filter: blur(22px) saturate(1.2); -webkit-backdrop-filter: blur(22px) saturate(1.2); animation: bgIn .25s ease both; padding-top: env(safe-area-inset-top); }
.imgv.out { opacity: 0; transition: opacity .2s; }
.imgv-top { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; }
.imgv-tabs { flex: 1; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.imgv-tabs::-webkit-scrollbar { display: none; }
.imgv-tabs button { flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line2); background: rgba(255,255,255,.05); font-weight: 600; font-size: 14px; transition: .2s; }
.imgv-tabs button.on { background: linear-gradient(135deg, #6366f1, #8b5cf6); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(99,102,241,.4); }
.imgv-x { flex: none; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line2); background: rgba(255,255,255,.06); font-size: 16px; }
.imgv-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 16px; }
.imgv-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 18px; box-shadow: 0 24px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08); transition: opacity .3s, transform .35s cubic-bezier(.2,.8,.2,1); transform: none; }
.imgv-stage.loading img { transform: scale(.97); }
.imgv-spin { position: absolute; width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: #818cf8; opacity: 0; animation: spin .8s linear infinite; pointer-events: none; }
.imgv-stage.loading .imgv-spin { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
.imgv-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); flex-wrap: wrap; justify-content: flex-end; }
.imgv-bar .imgv-pub { margin: 0 auto 0 0; font-size: 14px; }

/* database viewer */
.dbwrap { max-height: 68vh; overflow: auto; border-radius: inherit; }
table.dbt, table.dbt.rt { display: table !important; width: max-content; min-width: 100%; }
table.dbt thead { display: table-header-group !important; }
table.dbt tbody { display: table-row-group !important; }
table.dbt tr { display: table-row !important; margin: 0 !important; padding: 0 !important; border: 0 !important; background: none !important; }
table.dbt td, table.dbt th { display: table-cell !important; text-align: left !important; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
table.dbt td::before { display: none !important; }
table.dbt thead th { position: sticky; top: 0; background: var(--card2); z-index: 1; font-size: 12px; }
table.dbt tbody tr:active td, table.dbt tbody tr:hover td { background: rgba(99,102,241,.08) !important; }
table.dbt .dbn { position: sticky; left: 0; background: var(--card2); min-width: 44px; text-align: right !important; z-index: 2; }
.imgv-week { display: flex; gap: 8px; justify-content: center; padding: 4px 14px 0; }
.imgv-week button { padding: 7px 16px; border-radius: 99px; border: 1px solid var(--line2); background: rgba(255,255,255,.05); font-size: 14px; font-weight: 600; }
.imgv-week button.on { background: rgba(99,102,241,.25); border-color: var(--accent); }
