/* ============================================================
   Hub — premium design system
   ============================================================ */
:root {
  --accent: #7c5cff;
  --accent-hover: #8f73ff;
  --accent-press: #6f4ff0;
  --accent-soft: rgba(124, 92, 255, .14);
  --accent-ring: rgba(124, 92, 255, .35);

  --ok: #34d399; --ok-bg: rgba(52, 211, 153, .14);
  --proc: #60a5fa; --proc-bg: rgba(96, 165, 250, .14);
  --pend: #fbbf24; --pend-bg: rgba(251, 191, 36, .14);
  --err: #f87171; --err-bg: rgba(248, 113, 113, .14);

  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px;
  --sp: 8px;
  --t: 160ms cubic-bezier(.4, 0, .2, 1);
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
  --sidebar-w: 244px;
  --maxw: 760px;
}
html[data-theme="dark"] {
  --bg: #0c0c0f; --bg-grad: radial-gradient(1200px 600px at 70% -10%, rgba(124,92,255,.10), transparent 60%);
  --surface: #161619; --surface-2: #1e1e24; --surface-3: #26262e;
  --border: #26262e; --border-soft: #1f1f25;
  --text: #ededf2; --text-dim: #9c9ca8; --text-faint: #6a6a76;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -8px rgba(0,0,0,.5);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --skeleton: linear-gradient(90deg, #1c1c22 25%, #24242c 37%, #1c1c22 63%);
}
html[data-theme="light"] {
  --bg: #f5f5f8; --bg-grad: radial-gradient(1200px 600px at 70% -10%, rgba(124,92,255,.10), transparent 60%);
  --surface: #ffffff; --surface-2: #f3f3f6; --surface-3: #ebebf0;
  --border: #e7e7ee; --border-soft: #eeeef3;
  --text: #15151b; --text-dim: #61616d; --text-faint: #9a9aa6;
  --shadow: 0 1px 2px rgba(20,20,40,.06), 0 14px 32px -12px rgba(20,20,50,.18);
  --shadow-sm: 0 1px 2px rgba(20,20,40,.06);
  --skeleton: linear-gradient(90deg, #ededf1 25%, #f6f6f9 37%, #ededf1 63%);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); background-image: var(--bg-grad); background-attachment: fixed;
  color: var(--text); font-family: var(--sans); font-size: 14.5px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 20px 14px; border-right: 1px solid var(--border-soft); gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
.brand-mark { font-size: 20px; filter: saturate(1.1); }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-dim { color: var(--text-faint); font-weight: 600; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 11px;
  border: 0; background: transparent; color: var(--text-dim); font: inherit; font-weight: 500;
  border-radius: var(--r-sm); cursor: pointer; transition: var(--t); text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active .ico { stroke: var(--accent); }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 12px; }
.who { font-size: 11.5px; color: var(--text-faint); padding: 0 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghost-btn {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-dim); font: inherit; font-weight: 500; cursor: pointer; transition: var(--t);
}
.ghost-btn:hover { background: var(--surface-2); color: var(--text); }
.ico-moon { display: none; }
html[data-theme="light"] .ico-sun { display: none; }
html[data-theme="light"] .ico-moon { display: block; }

/* ---------- main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; padding: 26px 32px 18px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border-soft);
}
.page-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.page-sub { margin: 3px 0 0; font-size: 13px; color: var(--text-dim); }
.content { padding: 24px 32px 80px; width: 100%; max-width: calc(var(--maxw) + 64px); margin: 0 auto; }
.tab { display: none; animation: fade .25s ease; }
.tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- inputs / buttons ---------- */
input, textarea, select, button { font: inherit; color: var(--text); }
input, textarea, select {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 11px 13px; transition: var(--t); width: 100%; outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface); }
textarea { resize: vertical; line-height: 1.6; }
select.mini { width: auto; padding: 8px 10px; font-size: 13px; border-radius: var(--r-sm); cursor: pointer; }

.primary-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600; border-radius: var(--r); transition: var(--t);
  box-shadow: var(--shadow-sm); white-space: nowrap;
}
.primary-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.primary-btn:active { background: var(--accent-press); transform: translateY(0) scale(.98); }
.primary-btn .ico { width: 16px; height: 16px; stroke: #fff; }

.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-faint); cursor: pointer; transition: var(--t);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .ico { width: 15px; height: 15px; }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 3px; gap: 2px; }
.seg-btn {
  border: 0; background: transparent; color: var(--text-dim); padding: 6px 13px; font-size: 13px; font-weight: 500;
  border-radius: 8px; cursor: pointer; transition: var(--t);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- composer ---------- */
.composer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; margin-bottom: 24px; box-shadow: var(--shadow); transition: var(--t); }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.composer textarea { border: 0; background: transparent; padding: 6px 6px 2px; font-size: 15px; }
.composer textarea:focus { box-shadow: none; background: transparent; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.composer-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.attach-chip { display: inline-flex; align-items: center; gap: 8px; margin: 8px 2px 0; padding: 5px 10px; background: var(--accent-soft); color: var(--accent); border-radius: 8px; font-size: 12.5px; font-weight: 600; }
.attach-chip button { background: transparent; border: 0; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.row-form { display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.row-form input { flex: 1; min-width: 150px; }
.note-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; margin-bottom: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.note-form input, .note-form textarea { border: 0; background: var(--surface-2); }
.note-form-bar { display: flex; justify-content: space-between; gap: 10px; }

/* ---------- cards / stack ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px; transition: var(--t); position: relative; animation: fade .3s ease;
}
.card:hover { border-color: var(--surface-3); box-shadow: var(--shadow); transform: translateY(-1px); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.card-meta { color: var(--text-faint); font-size: 12.5px; margin-top: 5px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.card-meta .dot { width: 3px; height: 3px; border-radius: 99px; background: currentColor; opacity: .5; }
.card-body { margin-top: 8px; color: var(--text-dim); font-size: 13.5px; white-space: pre-wrap; }
.card-actions { display: flex; gap: 2px; opacity: 0; transition: var(--t); }
.card:hover .card-actions { opacity: 1; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.chip.active, .chip.todo, .chip.pending { color: var(--pend); background: var(--pend-bg); }
.chip.done { color: var(--ok); background: var(--ok-bg); }
.chip.processing, .chip.doing { color: var(--proc); background: var(--proc-bg); }
.chip.error, .chip.blocked { color: var(--err); background: var(--err-bg); }
.chip.paused { color: var(--text-faint); background: var(--surface-2); }
.prio { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* request result */
.result {
  margin-top: 12px; padding: 13px 15px; background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: var(--r); font-size: 13.5px; line-height: 1.6; max-height: 460px; overflow: auto; position: relative;
}
.result.err { color: var(--err); background: var(--err-bg); border-color: transparent; }
.result h1, .result h2, .result h3 { font-size: 14px; margin: 12px 0 6px; font-weight: 700; }
.result h1:first-child, .result h2:first-child, .result h3:first-child { margin-top: 0; }
.result p { margin: 8px 0; }
.result ul, .result ol { margin: 8px 0; padding-left: 20px; }
.result li { margin: 3px 0; }
.result code { font-family: var(--mono); font-size: .9em; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
.result pre { background: var(--surface-3); padding: 12px; border-radius: var(--r-sm); overflow: auto; }
.result pre code { background: none; padding: 0; }
.result a { color: var(--accent); text-decoration: none; }
.result a:hover { text-decoration: underline; }
.result-copy { position: absolute; top: 8px; right: 8px; }
.req-prompt { font-weight: 600; font-size: 14.5px; letter-spacing: -.01em; padding-right: 70px; }

/* empty + skeleton */
.empty { text-align: center; padding: 56px 20px; color: var(--text-faint); }
.empty .ico { width: 30px; height: 30px; margin: 0 auto 12px; stroke: var(--text-faint); opacity: .7; }
.empty-title { color: var(--text-dim); font-weight: 600; font-size: 14.5px; }
.empty-hint { font-size: 13px; margin-top: 4px; }
.skel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; }
.skel-line { height: 11px; border-radius: 6px; background: var(--skeleton); background-size: 400% 100%; animation: shimmer 1.3s infinite; }
.skel-line + .skel-line { margin-top: 10px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(60px);
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 99px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow); opacity: 0; transition: var(--t); pointer-events: none; z-index: 30;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; width: 100%; flex-direction: row;
    align-items: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(14px); z-index: 20; gap: 2px;
  }
  .brand, .sidebar-foot .who { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav-item { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 7px 8px; flex: 1; justify-content: center; }
  .nav-item span { font-size: 10.5px; }
  .sidebar-foot { margin: 0; padding: 0; }
  .ghost-btn .theme-label { display: none; }
  .ghost-btn { flex-direction: column; padding: 7px 10px; }
  .topbar { padding: 18px 18px 14px; }
  .content { padding: 16px 16px 92px; }
  .composer-bar { flex-direction: column; align-items: stretch; }
  .composer-right { justify-content: space-between; }
  .seg { width: 100%; }
  .seg-btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
