:root {
  --bg: #f4f5f8; --panel: #ffffff; --panel-2: #f8f9fb; --text: #1b2130; --muted: #657084; --line: #e3e6ec;
  --accent: #4353e6; --accent-2: #eef0fe; --accent-text: #3140c9;
  --ok: #157a4a; --ok-2: #e4f6ec; --warn: #9a5a00; --warn-2: #fff3dd; --err: #b42318; --err-2: #fdecea;
  --code: #f0f2f6; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px; --sidebar: 248px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117; --panel: #161a22; --panel-2: #1b2029; --text: #e7e9ee; --muted: #9aa3b2; --line: #2a303b;
    --accent: #8090ff; --accent-2: #1f2545; --accent-text: #a8b3ff;
    --ok: #4cc38a; --ok-2: #12291e; --warn: #f2b14c; --warn-2: #2b2112; --err: #ff8a80; --err-2: #2d1517;
    --code: #202633; --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14.5px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 28px 0 12px; }
h3 { font-size: 14.5px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
code { background: var(--code); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .nowrap { white-space: nowrap; }
.right { margin-left: auto; } .hidden { display: none !important; }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); min-width: calc(var(--sidebar) - 46px); }
.brand:hover { text-decoration: none; }
.brand .logo { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--accent-2); }
.topsearch { flex: 1; max-width: 560px; position: relative; }
.topsearch input { padding-left: 34px; background: var(--panel-2); }
.topsearch::before { content: "🔎"; position: absolute; left: 11px; top: 8px; font-size: 13px; opacity: .65; }
.menu-btn { display: none; background: none; border: 0; color: var(--text); font-size: 20px; padding: 4px 6px; }
.usermenu { position: relative; margin-left: auto; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 10px; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--panel-2); }
.usermenu .dropdown { position: absolute; right: 0; top: 44px; min-width: 210px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: grid; }
.usermenu .dropdown a, .usermenu .dropdown button { text-align: left; padding: 8px 10px; border-radius: 7px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.usermenu .dropdown a:hover, .usermenu .dropdown button:hover { background: var(--panel-2); text-decoration: none; }

.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidebar { border-right: 1px solid var(--line); background: var(--panel); padding: 14px 10px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; color: var(--text); margin-bottom: 1px; }
.nav-item:hover { background: var(--panel-2); text-decoration: none; }
.nav-item.on { background: var(--accent-2); color: var(--accent-text); font-weight: 600; }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-title { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; margin: 18px 10px 6px; }
.nav-title a { font-size: 16px; line-height: 1; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 3px; background: hsl(var(--h, 230) 65% 55%); flex: none; }
.content { padding: 24px 28px 80px; min-width: 0; max-width: 1240px; }
@media (max-width: 900px) {
  .menu-btn { display: block; }
  .brand { min-width: 0; }
  .brand .name { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 56px; bottom: 0; width: 270px; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 18px 16px 70px; }
}

/* ---------- building blocks ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
a.card { display: block; color: inherit; transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cols { display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr) 330px; align-items: start; }
@media (max-width: 1100px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.page-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 6px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--code); color: var(--muted); white-space: nowrap; }
.badge.accent { background: var(--accent-2); color: var(--accent-text); } .badge.ok { background: var(--ok-2); color: var(--ok); }
.badge.warn { background: var(--warn-2); color: var(--warn); } .badge.err { background: var(--err-2); color: var(--err); }
.pill { font-size: 11px; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; text-align: center; font-weight: 600; }
.avatar { --h: 230; width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-size: 12px; font-weight: 700;
  color: hsl(var(--h) 60% 30%); background: hsl(var(--h) 75% 88%); }
@media (prefers-color-scheme: dark) { .avatar { color: hsl(var(--h) 80% 85%); background: hsl(var(--h) 35% 28%); } }
.avatar.sm { width: 24px; height: 24px; font-size: 10.5px; } .avatar.lg { width: 38px; height: 38px; font-size: 14px; }
.avatars { display: flex; } .avatars .avatar { margin-left: -7px; border: 2px solid var(--panel); } .avatars .avatar:first-child { margin-left: 0; }
.agent { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; padding: 0 7px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
.agent.bot { border-color: transparent; background: var(--accent-2); color: var(--accent-text); }
.aid { font-family: ui-monospace, Consolas, monospace; font-size: 10.5px; opacity: .7; }

/* ---------- forms ---------- */
input, select, textarea { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-2); border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
textarea.code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
label.field { display: grid; gap: 5px; font-size: 13px; font-weight: 500; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
form.stack { display: grid; gap: 10px; }
.btn, button { font: inherit; font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 9px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover, button:hover { filter: brightness(1.07); text-decoration: none; }
.btn.ghost, button.ghost { background: var(--panel); color: var(--text); border-color: var(--line); }
.btn.ghost:hover, button.ghost:hover { border-color: var(--accent); color: var(--accent-text); }
.btn.sm, button.sm { padding: 3px 10px; font-size: 12.5px; border-radius: 7px; }
button.danger, .btn.danger { background: var(--panel); color: var(--err); border-color: var(--err); }
button.link { background: none; border: 0; color: var(--accent-text); padding: 0; font-weight: 500; }
details.reveal > summary { list-style: none; cursor: pointer; }
details.reveal > summary::-webkit-details-marker { display: none; }
.hint { font-size: 12.5px; color: var(--muted); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 18px 0 20px; overflow-x: auto; }
.tabs a { padding: 9px 14px; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
.tabs .badge { margin-left: 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; background: var(--panel); }
.chip.on { background: var(--accent-2); color: var(--accent-text); border-color: transparent; font-weight: 600; }
.chip:hover { text-decoration: none; border-color: var(--accent); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13.5px; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--panel-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }

/* ---------- markdown ---------- */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 8px; } .md ul, .md ol { padding-left: 22px; margin: 0 0 8px; }
.md pre { background: var(--code); padding: 10px 12px; border-radius: 9px; overflow: auto; font-size: 12.5px; }
.md pre code { padding: 0; background: none; }
.md table { width: auto; border: 1px solid var(--line); margin: 8px 0; } .md th, .md td { padding: 5px 9px; }
.md blockquote { margin: 0 0 8px; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md h1, .md h2, .md h3 { margin: 14px 0 8px; } .md h1 { font-size: 19px; } .md h2 { font-size: 16.5px; }

/* ---------- messages ---------- */
.thread { margin-bottom: 14px; padding: 0; overflow: hidden; }
.msg { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; padding: 14px 18px; }
.msg + .msg { border-top: 1px solid var(--line); }
.msg.reply { padding-left: 52px; background: var(--panel-2); grid-template-columns: 30px minmax(0, 1fr); }
.msg-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.msg-head .when { margin-left: auto; font-size: 12px; color: var(--muted); }
.msg:target { box-shadow: inset 3px 0 0 var(--accent); }
.thread-foot { padding: 10px 18px 12px 68px; border-top: 1px solid var(--line); background: var(--panel-2); }
.composer textarea { min-height: 80px; }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; padding-bottom: 6px; }
@media (max-width: 1000px) { .kanban { grid-template-columns: repeat(4, minmax(240px, 80vw)); } }
.lane { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.lane > h3 { display: flex; align-items: center; gap: 8px; padding: 2px 4px 8px; margin: 0; font-size: 13px; }
.task { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-bottom: 9px; box-shadow: var(--shadow); }
.task:target { border-color: var(--accent); }
.task .title { font-weight: 600; margin-bottom: 4px; }
.task .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }

/* ---------- files ---------- */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); background: var(--panel); cursor: pointer; transition: all .15s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-2); color: var(--accent-text); }
.progress { height: 6px; border-radius: 99px; background: var(--code); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .15s; }
.progress.warn > div { background: var(--warn); } .progress.err > div { background: var(--err); }
.folders { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 16px; }
.folder { display: flex; gap: 10px; align-items: center; padding: 11px 13px; }
.folder .ico { font-size: 22px; }
.fico { font-size: 18px; width: 24px; display: inline-block; text-align: center; }

/* ---------- misc ---------- */
.stat { display: grid; gap: 2px; } .stat .v { font-size: 22px; font-weight: 700; letter-spacing: -.02em; } .stat .l { font-size: 12.5px; color: var(--muted); }
.timeline .day { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 18px 0 8px; }
.event { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.event .what { font-size: 13.5px; } .event .detail { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.empty { text-align: center; padding: 34px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 6px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--code); padding: 10px 12px; border-radius: 9px;
  overflow-wrap: anywhere; white-space: pre-wrap; position: relative; margin: 6px 0 12px; }
.secret .copy { position: absolute; top: 6px; right: 6px; }
mark { background: #ffe58a; color: #1b2130; border-radius: 3px; padding: 0 2px; }
.hit { padding: 13px 16px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; }
.hit:last-child { border-bottom: 0; } .hit .t { font-weight: 600; } .hit .s { color: var(--muted); font-size: 13px; margin-top: 2px; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 50; }
.toast { padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; max-width: 420px; animation: pop .2s ease-out; }
.toast.ok { background: var(--ok-2); color: var(--ok); border: 1px solid var(--ok); } .toast.err { background: var(--err-2); color: var(--err); border: 1px solid var(--err); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 400px; padding: 28px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; } @media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.preview { min-height: 200px; }
