/* Claude Hub. Zinc neutrals, one orange accent.
   Radius rule: 10px for controls and panels, 16px for chat bubbles and dialogs, full pill for chips. */
:root {
  color-scheme: light;
  --bg: #f4f4f5;
  --panel: #ffffff;
  --raised: #fafafa;
  --ink: #18181b;
  --ink-2: #3f3f46;
  --muted: #6b6b76;
  --line: #e4e4e7;
  --line-2: #d4d4d8;
  --accent: #d9622b;
  --accent-ink: #ffffff;
  --accent-soft: #fbeee6;
  --mine: #fdf1ea;
  --mine-line: #f3d6c5;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #c2261d;
  --danger-soft: #fdecea;
  --code: #f4f4f5;
  --shadow: 0 1px 2px rgb(24 24 27 / .05), 0 8px 24px rgb(24 24 27 / .06);
  --r: 10px;
  --r-lg: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d0d10;
    --panel: #141418;
    --raised: #1a1a1f;
    --ink: #ececef;
    --ink-2: #c8c8ce;
    --muted: #8e8e99;
    --line: #25252c;
    --line-2: #33333b;
    --accent: #ee7440;
    --accent-ink: #1a0d06;
    --accent-soft: #2a1a12;
    --mine: #231812;
    --mine-line: #3a2619;
    --ok: #4ade80;
    --warn: #fbbf24;
    --danger: #f87171;
    --danger-soft: #2b1514;
    --code: #1d1d23;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 12px 32px rgb(0 0 0 / .35);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; letter-spacing: -.015em; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ico { width: 18px; height: 18px; flex: none; display: block; }

/* ---------- buttons and fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--r);
  border: 1px solid transparent; background: none; cursor: pointer;
  font-weight: 560; font-size: 14px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, opacity .15s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { color: var(--ink-2); }
.btn.ghost:hover { background: var(--raised); border-color: var(--line); }
.btn.danger-ghost { color: var(--danger); }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.icon { width: 36px; padding: 0; }
.btn.icon-text { padding-left: 11px; }
.btn.wide { width: 100%; height: 42px; }
.btn.small { height: 30px; padding: 0 11px; font-size: 13px; }

label { display: block; font-size: 13px; font-weight: 560; color: var(--ink-2); margin: 14px 0 6px; }
input:not([type=checkbox]), select, textarea {
  width: 100%; border: 1px solid var(--line-2); background: var(--panel);
  border-radius: var(--r); padding: 9px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:not([type=checkbox]):focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: none; }
label.check { display: flex; align-items: center; gap: 9px; font-weight: 450; color: var(--ink); cursor: pointer; }
label.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.field-error { margin: 10px 0 0; min-height: 1em; font-size: 13px; color: var(--danger); }
.field-error:empty { display: none; }

/* ---------- brand mark ---------- */
.mark {
  width: 44px; height: 44px; border-radius: 12px; position: relative;
  background: var(--ink);
}
.mark::before, .mark::after { content: ""; position: absolute; border-radius: 50%; inset: 0; margin: auto; }
.mark::before { width: 28%; height: 28%; background: var(--accent); }
.mark::after { width: 62%; height: 62%; border: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); }
.mark.small { width: 22px; height: 22px; border-radius: 7px; }
.mark.small::after { border-width: 1.5px; }
.mark.large { width: 56px; height: 56px; border-radius: 15px; }
@media (prefers-color-scheme: dark) { .mark { background: #24242b; } }

/* ---------- boot and login ---------- */
.boot { position: fixed; inset: 0; background: var(--bg); }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 32px 28px 28px; box-shadow: var(--shadow);
  animation: rise .5s var(--ease) both;
}
.login-card h1 { font-size: 22px; margin-top: 18px; }
.login-card p.muted { margin: 4px 0 8px; }
.login-card .btn { margin-top: 18px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 320px 1fr; height: 100dvh; }
.side {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-right: 1px solid var(--line);
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -.01em; }
.search { position: relative; padding: 4px 16px 10px; }
.search input { padding-left: 36px; height: 38px; background: var(--raised); border-color: var(--line); }
.search-icon { position: absolute; left: 28px; top: 15px; color: var(--muted); pointer-events: none; }
.search-icon .ico { width: 16px; height: 16px; }
.list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.side-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 10px 18px; border-top: 1px solid var(--line);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.conn { font-size: 12.5px; color: var(--muted); }
.conn.live { color: var(--ok); }

.list-label { padding: 12px 10px 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%;
  text-align: left; padding: 10px 10px 11px; border-radius: var(--r);
  border: 1px solid transparent; background: none; cursor: pointer;
  transition: background .12s;
}
.row:hover { background: var(--raised); }
.row.current { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.row-name { display: flex; align-items: center; gap: 7px; font-weight: 600; min-width: 0; }
.row-name span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-name .ico { width: 15px; height: 15px; color: var(--accent); }
.row-time { font-size: 12px; color: var(--muted); align-self: center; }
.row-preview {
  grid-column: 1 / -1; font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row .badge {
  min-width: 18px; height: 18px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center; justify-self: end;
}
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 560; }
.state.working, .state.waiting { color: var(--accent); }
.state.queued { color: var(--warn); }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state.working::before { animation: pulse 1.4s ease-in-out infinite; }
.state.idle { color: var(--muted); }
.state.idle::before { display: none; }

.list-empty { padding: 28px 14px; text-align: center; color: var(--muted); font-size: 13.5px; }
.result {
  display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: var(--r);
  background: none; cursor: pointer;
}
.result:hover { background: var(--raised); }
.result b { font-size: 12.5px; color: var(--accent); }
.result p { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- main ---------- */
.main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.empty { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.empty-inner { max-width: 380px; text-align: left; animation: rise .5s var(--ease) both; }
.empty-inner h2 { font-size: 24px; margin: 20px 0 8px; }
.empty-inner p { margin: 0 0 22px; }

.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat-head {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  z-index: 2;
}
.chat-title { flex: 1; min-width: 0; }
.chat-title h2 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); margin-top: 1px; flex-wrap: wrap; }
.chat-actions { display: flex; gap: 4px; }
.settings {
  position: absolute; right: 16px; top: calc(100% + 6px); width: min(320px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 4px 16px 16px; box-shadow: var(--shadow); animation: drop .2s var(--ease) both;
}
.settings .btn { margin-top: 14px; width: 100%; justify-content: flex-start; }

.messages {
  flex: 1; overflow-y: auto; padding: 20px 16px 8px; outline: none;
  display: flex; flex-direction: column; gap: 4px;
}
.messages > * { width: 100%; max-width: 780px; margin-left: auto; margin-right: auto; }
.older { align-self: center; margin-bottom: 8px; }

.msg { display: flex; flex-direction: column; margin-top: 10px; animation: rise .35s var(--ease) both; }
.msg .who { font-size: 12px; color: var(--muted); margin: 0 4px 4px; display: flex; gap: 8px; }
.msg.mine { align-items: flex-end; }
.bubble {
  max-width: min(620px, 88%); padding: 10px 14px; border-radius: var(--r-lg);
  background: var(--mine); border: 1px solid var(--mine-line);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.peer .bubble { background: var(--panel); border-color: var(--line); white-space: normal; }
.msg.assistant .text { padding: 0 4px; overflow-wrap: anywhere; }
.text p { margin: 0 0 .7em; }
.text p:last-child, .text ul:last-child, .text ol:last-child, .text .code:last-child { margin-bottom: 0; }
.text h3 { font-size: 15.5px; margin: 1em 0 .4em; }
.text ul, .text ol { margin: 0 0 .7em; padding-left: 1.35em; }
.text li { margin: .15em 0; }
.text code {
  font: 13px/1.5 var(--mono); background: var(--code); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 6px;
}
.code { position: relative; margin: 0 0 .8em; border: 1px solid var(--line); border-radius: var(--r); background: var(--code); }
.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; font: 13px/1.55 var(--mono); }
.code pre code { background: none; border: 0; padding: 0; }
.code .copy { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .15s; background: var(--panel); border-color: var(--line); }
.code:hover .copy, .code .copy:focus-visible { opacity: 1; }
@media (hover: none) { .code .copy { opacity: 1; } }

.tools { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.tool {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px;
  width: 100%; text-align: left; padding: 6px 10px; border-radius: var(--r);
  border: 1px solid transparent; background: none; cursor: pointer; color: var(--ink-2);
  font-size: 13px;
}
.tool:hover { background: var(--panel); border-color: var(--line); }
.tool .ico { width: 15px; height: 15px; color: var(--muted); }
.tool .t { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool .s .ico { width: 14px; height: 14px; }
.tool.done .s { color: var(--ok); }
.tool.error .s { color: var(--danger); }
.tool.running .s::before { content: ""; display: block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.tool-out {
  margin: 2px 0 6px 34px; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--code); font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 280px; overflow-y: auto; color: var(--ink-2);
}

.perm {
  margin-top: 12px; border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  background: var(--panel); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--shadow);
  animation: rise .35s var(--ease) both;
}
.perm-head { display: flex; align-items: center; gap: 8px; font-weight: 620; }
.perm-head .ico { color: var(--accent); }
.perm pre {
  margin: 10px 0 0; padding: 10px 12px; border-radius: var(--r); background: var(--code); border: 1px solid var(--line);
  font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow-y: auto;
}
.perm .reason { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.perm-actions { display: flex; gap: 8px; margin-top: 12px; }
.perm-actions .btn.ghost { border-color: var(--line-2); }
.perm.answered { box-shadow: none; border-color: var(--line); }
.perm .verdict { margin-top: 10px; font-size: 13px; font-weight: 560; }
.verdict.allowed { color: var(--ok); }
.verdict.denied, .verdict.expired, .verdict.timed-out { color: var(--muted); }

.sys { align-self: center; margin: 14px auto 4px; font-size: 12.5px; color: var(--muted); text-align: center; max-width: 560px; }
.sys.err { color: var(--danger); }

.working { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 0 4px; color: var(--muted); font-size: 13px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }

.jump {
  position: absolute; left: 50%; bottom: 88px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  box-shadow: var(--shadow); cursor: pointer; font-size: 13px; font-weight: 560; z-index: 3;
}
.jump .ico { width: 15px; height: 15px; }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  width: 100%; max-width: 812px; margin: 0 auto; padding: 8px 16px 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.composer textarea {
  min-height: 46px; max-height: 220px; padding: 12px 14px; border-radius: var(--r-lg);
  background: var(--panel); box-shadow: var(--shadow); line-height: 1.45;
}
.composer .btn { width: 46px; height: 46px; border-radius: var(--r-lg); }

/* ---------- dialog and toast ---------- */
.dialog {
  width: min(460px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--panel); color: var(--ink); padding: 24px; box-shadow: var(--shadow);
}
.dialog[open] { animation: rise .3s var(--ease) both; }
.dialog::backdrop { background: rgb(9 9 11 / .45); backdrop-filter: blur(3px); }
.dialog h2 { font-size: 19px; margin-bottom: 4px; }
.dialog label.check { margin-top: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r);
  font-size: 13.5px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
  animation: rise .3s var(--ease) both;
}

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- phone ---------- */
.only-mobile { display: none; }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .app.in-chat .side { display: none; }
  .app:not(.in-chat) .main { display: none; }
  .side { border-right: 0; }
  .only-mobile { display: inline-flex; }
  .chat-head { padding: 10px 12px; }
  .messages { padding: 14px 12px 6px; }
  .composer { padding: 6px 10px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .bubble { max-width: 92%; }
  .tool-out { margin-left: 0; }
  input:not([type=checkbox]), select, textarea { font-size: 16px; }
}
