/* Muse — UI. System fonts only, no CDN, no backdrop-filter on live surfaces.
   Layout follows the Atlas/Muse web-app guide: left icon rail, centred chat
   column, right status panel, settings dialog, command palette, mobile bottom bar. */
:root {
  --bg: #08080c;
  --rail: #0b0b11;
  --panel: #101017;
  --surface: #15151d;
  --raise: #1b1b25;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .12);
  --text: #f4f4f7;
  --muted: #8b8b9b;
  --dim: #5e5e6e;
  --accent: #6d5efc;
  --accent-soft: rgba(109, 94, 252, .14);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
/* The hidden attribute must beat any display rule (flex/grid panes) — without this,
   a flex container stays visible when JS sets .hidden = true. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; background: none; border: 0; outline: 0; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .1); border-radius: 9px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .18); }
::-webkit-scrollbar-track { background: transparent; }

.app {
  display: grid; grid-template-columns: 62px 1fr 304px; grid-template-rows: 100vh;
  height: 100vh; height: 100dvh; overflow: hidden;
}

/* ---------- left rail ---------- */
.rail {
  background: var(--rail); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 10px; gap: 4px; min-height: 0; overflow: visible; position: relative;
}
.brand {
  width: 32px; height: 32px; border-radius: 9px; margin-bottom: 12px;
  background: linear-gradient(140deg, var(--accent), #a78bfa);
  display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff;
  box-shadow: 0 4px 14px rgba(109, 94, 252, .35); flex: 0 0 auto;
}
.rail-btn {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  color: var(--dim); flex: 0 0 auto;
  transition: color .12s ease, background-color .12s ease;
}
.rail-btn:hover { color: var(--text); background: var(--raise); }
.rail-btn.on { color: #fff; background: var(--accent-soft); }
.rail-btn svg { width: 19px; height: 19px; }
.rail-sp { flex: 1; }

.drop-menu {
  position: absolute; left: 56px; bottom: 12px; z-index: 30; min-width: 190px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 11px;
  padding: 6px; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.drop-menu[hidden] { display: none; }
.drop-menu button {
  text-align: left; padding: 8px 11px; border-radius: 8px; font-size: 13px; color: var(--text);
}
.drop-menu button:hover { background: var(--raise); }

/* ---------- center ---------- */
.center {
  display: flex; flex-direction: column; min-width: 0;
  min-height: 0; overflow: hidden; background: var(--bg); position: relative;
}
.topbar {
  height: 50px; flex: 0 0 50px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid var(--line);
}
.topbar h1 {
  font-size: 13.5px; font-weight: 600; margin: 0; letter-spacing: .2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 46%;
}
.pill {
  font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.pill.ok { color: var(--ok); border-color: rgba(52, 211, 153, .3); }
.pill.bad { color: var(--danger); border-color: rgba(248, 113, 113, .3); }
.pill.btn { cursor: pointer; }
.pill.btn:hover { color: var(--text); border-color: var(--line-2); }
.pill.btn.acc { color: #fff; background: var(--accent); border-color: transparent; }
.pill.btn.danger { color: var(--danger); border-color: rgba(248, 113, 113, .35); }
.pill.btn.danger:hover { background: rgba(248, 113, 113, .12); }
.pill.wide { width: 100%; text-align: center; padding: 5px 8px; }
.grow { flex: 1; }
.kb-hint {
  font-size: 10px; color: var(--dim); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; flex: 0 0 auto;
}
.vh-title { font-size: 13.5px; font-weight: 600; }

/* ---------- views ---------- */
.view { display: none; flex: 1 1 auto; min-height: 0; flex-direction: column; overflow: hidden; }
.view.on { display: flex; }
.vhead {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 22px; border-bottom: 1px solid var(--line);
}
.vhead.lib-sub { padding-top: 8px; padding-bottom: 8px; }
.scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.wrap { max-width: 780px; margin: 0 auto; padding: 20px 22px 28px; }
.wrap.wide { max-width: 1000px; }

.search-box {
  flex: 1; display: flex; align-items: center; gap: 9px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 0 12px;
  text-align: left; min-width: 0;
}
.search-box:focus-within { border-color: rgba(109, 94, 252, .5); }
.search-box input { flex: 1; padding: 9px 0; min-width: 0; }
.search-box input::placeholder { color: var(--dim); }
.search-box input::-webkit-search-cancel-button { filter: invert(.6); }
.search-box.asbtn { max-width: 440px; padding: 8px 12px; cursor: pointer; }
.search-box.asbtn:hover { border-color: var(--line-2); }
.search-box .sb-txt { flex: 1; font-size: 12.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hit {
  display: block; width: 100%; text-align: left; padding: 9px 11px; border-radius: 9px;
  margin-bottom: 3px; border: 1px solid transparent;
}
.hit:hover { background: var(--raise); border-color: var(--line); }
.hit .kb {
  font-size: 9.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--dim);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; margin-right: 8px;
}
.hit .kb.user { color: #a9a0ff; }
.hit .kb.assistant { color: var(--ok); }
.hit .kb.note { color: var(--warn); }
.hit .hit-t { font-size: 13px; font-weight: 600; }
.hit .hit-s { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }

.seg { max-width: 300px; }
.seg .tab { flex: 0 0 auto; padding: 5px 12px; }
.legend .k { margin-left: 8px; }
.k {
  display: inline-block; min-width: 52px; text-align: center; font-size: 9.5px;
  letter-spacing: .05em; border-radius: 5px; padding: 1px 5px; border: 1px solid var(--line);
}
.k.done { color: var(--ok); }
.k.learned { color: #a9a0ff; }
.k.blocked { color: var(--danger); }

/* ---------- chat hero (avatar) ---------- */
.hero {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 16px 0 6px;
}
.hero-av {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 20px; background: linear-gradient(140deg, #2a2740, #1a1826);
  border: 1px solid var(--line-2); transition: transform .12s ease, border-color .12s;
}
.hero-av:hover { transform: translateY(-1px); border-color: rgba(109, 94, 252, .6); }
.hero-name { font-size: 13px; font-weight: 600; }
.hero-sub { font-size: 11px; color: var(--muted); margin-top: -3px; }

/* ---------- feed prompt card ---------- */
.prompt-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 18px;
}
.pc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pc-title { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
.pc-body { font-size: 12.5px; color: var(--muted); white-space: pre-wrap; }
#feedPromptInput {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; resize: vertical; font-size: 12.5px; margin-top: 6px;
}
.pc-actions { display: flex; gap: 8px; margin-top: 8px; }

.feed-date {
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--dim);
  font-weight: 600; margin: 18px 0 8px;
}
.feed-date:first-child { margin-top: 0; }
.feed-item { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.feed-item .k { flex: 0 0 52px; }
.feed-item .tx { font-size: 13px; line-height: 1.55; word-wrap: break-word; }
.feed-item.blocked .tx { color: var(--danger); }

/* ---------- ideas ---------- */
.idea {
  display: flex; gap: 11px; align-items: flex-start; padding: 12px 13px;
  border: 1px solid var(--line); border-radius: 11px; margin-bottom: 9px; background: var(--surface);
}
.idea .ib {
  flex: 0 0 auto; font-size: 9.5px; letter-spacing: .05em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; color: var(--muted); margin-top: 1px;
}
.idea.blocked .ib, .idea.open .ib { color: var(--danger); }
.idea.pending .ib { color: var(--warn); }
.idea.position .ib { color: var(--ok); }
.idea .it { font-size: 13.5px; font-weight: 600; }
.idea .id { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; word-wrap: break-word; }

/* ---------- goals ---------- */
.goal-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; margin-bottom: 20px;
}
.goal-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.goal-name { font-size: 14.5px; font-weight: 600; }
.bar { height: 9px; border-radius: 9px; background: var(--raise); margin: 13px 0 10px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 9px; background: linear-gradient(90deg, var(--accent), #a78bfa); }
.goal-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.goal-foot .big { font-size: 19px; font-weight: 700; }
.open-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.open-row .sym { font-weight: 700; flex: 0 0 60px; }
.open-row .setup { color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.open-row .tgt { color: var(--ok); flex: 0 0 auto; font-weight: 600; }

/* ---------- library ---------- */
.fs-bar.lib { font-size: 12px; }
.crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.lib-list .fs-row { padding: 8px 10px; font-size: 13px; }

/* ---------- nested file tree (Library → System files) ---------- */
.tree-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; margin: 0 0 12px; font-size: 12px; }
.crumb-btn { color: var(--muted); padding: 3px 7px; border-radius: 7px; }
.crumb-btn:hover { background: var(--raise); color: var(--text); }
.crumb-sep { color: var(--dim); font-size: 11px; }
.tree { display: flex; flex-direction: column; gap: 1px; }
.tree-node { display: flex; flex-direction: column; }
.tree-kids { display: flex; flex-direction: column; gap: 1px; }
.tree-kids[hidden] { display: none !important; }
.tree-row {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 8px;
  font-size: 12.5px; cursor: pointer; transition: background-color .1s;
}
.tree-row:hover { background: var(--raise); }
.tree-chev {
  width: 15px; height: 15px; flex: 0 0 15px; display: grid; place-items: center;
  color: var(--dim); border-radius: 4px;
}
.tree-chev svg { width: 12px; height: 12px; transition: transform .13s ease; }
.tree-chev.open svg { transform: rotate(90deg); }
.tree-chev:hover { color: var(--text); background: var(--line); }
.tree-chev.leaf { visibility: hidden; }
.tree-ico { width: 17px; height: 17px; flex: 0 0 17px; display: grid; place-items: center; color: var(--muted); }
.tree-ico svg { width: 16px; height: 16px; }
.tree-ico.dir { color: var(--accent); }
.tree-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-nm.link { text-decoration: underline dotted; }
.tree-cnt { margin-left: auto; color: var(--dim); font-size: 10.5px; flex: 0 0 auto; }
.tree-sz { margin-left: auto; color: var(--dim); font-size: 10.5px; flex: 0 0 auto; }
.tree-menu {
  flex: 0 0 auto; color: var(--muted); font-size: 14px; line-height: 1; padding: 1px 6px;
  border-radius: 6px; opacity: 0; transition: opacity .12s;
}
.tree-row:hover .tree-menu { opacity: 1; }
.tree-menu:hover { background: var(--line-2); color: var(--text); }
.tree-loading { color: var(--dim); font-size: 11.5px; padding: 5px 8px 5px 30px; }

/* attached-file chip inside a user bubble */
.filechip {
  display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 5px 9px;
  background: rgba(255, 255, 255, .16); border-radius: 8px; font-size: 11.5px;
  max-width: 100%;
}
.filechip .fi { flex: 0 0 auto; }
.filechip .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.view.dragging { outline: 2px dashed var(--accent); outline-offset: -8px; }
.lib-tools { display: flex; gap: 7px; align-items: center; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 11px; }
.lib-grid.list { grid-template-columns: 1fr; }
.lib-card {
  position: relative; text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; min-height: 74px; display: flex; flex-direction: column;
  gap: 6px; transition: border-color .12s, transform .12s;
}
.lib-grid.list .lib-card { min-height: 0; flex-direction: row; align-items: center; }
.lib-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.lib-card .lc-nm { font-size: 12.5px; font-weight: 600; word-break: break-word; }
.lib-card .lc-sub { font-size: 10.5px; color: var(--dim); margin-top: auto; }
.lib-grid.list .lib-card .lc-sub { margin: 0 0 0 auto; flex: 0 0 auto; }
.lib-card .lc-pin { position: absolute; top: 8px; right: 8px; font-size: 11px; color: var(--warn); }
.lib-card .lc-menu {
  position: absolute; bottom: 6px; right: 6px; opacity: 0; transition: opacity .12s;
  font-size: 15px; line-height: 1; padding: 2px 6px; border-radius: 6px; color: var(--muted);
}
.lib-card:hover .lc-menu { opacity: 1; }
.lib-card .lc-menu:hover { background: var(--raise); color: var(--text); }
.lib-card.sel { border-color: var(--accent); background: var(--accent-soft); }
.lib-card .lc-check { position: absolute; top: 8px; left: 8px; font-size: 12px; color: var(--accent); }
.lib-cm {
  position: fixed; z-index: 60; min-width: 168px; background: var(--panel);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 5px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.lib-cm button { text-align: left; padding: 7px 10px; border-radius: 7px; font-size: 12.5px; }
.lib-cm button:hover { background: var(--raise); }
.lib-cm button.danger { color: var(--danger); }
.selbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 9px; padding: 10px 22px;
  border-top: 1px solid var(--line); background: var(--panel); font-size: 12.5px;
}
.sec-h { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--dim); font-weight: 600; margin: 16px 0 9px; }
.sec-h:first-child { margin-top: 0; }

/* past-chats dropdown */
.dropdown {
  position: absolute; inset: 50px 0 0 0; background: rgba(4, 4, 8, .6); z-index: 20;
  display: flex; justify-content: center; align-items: flex-start; padding-top: 14px;
}
.dropdown[hidden] { display: none; }
.dropdown-in {
  width: min(560px, 92%); max-height: 60vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 13px;
  padding: 10px; box-shadow: var(--shadow);
}
html.light .dropdown { background: rgba(255, 255, 255, .55); }

.chat { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: auto; }
.chat-inner { max-width: 780px; margin: 0 auto; padding: 14px 22px 10px; }

.msg { display: flex; gap: 12px; margin-bottom: 22px; }
.msg.user { justify-content: flex-end; }
.av {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 28px; margin-top: 2px;
  background: linear-gradient(140deg, var(--accent), #a78bfa); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.bubble { max-width: 86%; min-width: 0; }
.msg.user .bubble {
  background: var(--accent); color: #fff; border-radius: 14px 14px 4px 14px;
  padding: 9px 13px; white-space: pre-wrap; word-wrap: break-word;
}
.msg.bot .bubble { padding-top: 3px; word-wrap: break-word; }
.bubble.streaming { white-space: pre-wrap; }
.meta { font-size: 11px; color: var(--dim); margin-top: 7px; }
.typing { display: inline-block; width: 7px; height: 14px; background: var(--accent);
  vertical-align: -2px; animation: blink 1s steps(2, start) infinite; border-radius: 1px; }
@keyframes blink { 50% { opacity: 0; } }
.hl { background: rgba(251, 191, 36, .3); border-radius: 3px; }

/* markdown */
.bubble h1, .bubble h2, .bubble h3 { margin: 14px 0 7px; line-height: 1.3; }
.bubble h1 { font-size: 19px; } .bubble h2 { font-size: 16.5px; } .bubble h3 { font-size: 14.5px; }
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 10px; padding-left: 22px; }
.bubble li { margin: 3px 0; }
.bubble a { color: #a9a0ff; }
.bubble code {
  background: rgba(255, 255, 255, .08); padding: 1.5px 5px; border-radius: 5px;
  font: 12.5px var(--mono);
}
.bubble pre.code {
  background: #0c0c13; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; overflow-x: auto; margin: 0 0 11px;
}
.bubble pre.code code { background: none; padding: 0; font-size: 12.5px; line-height: 1.5; }
.bubble blockquote {
  border-left: 2px solid var(--line-2); margin: 0 0 10px; padding: 2px 0 2px 12px; color: var(--muted);
}
.bubble hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.bubble table { border-collapse: collapse; margin: 0 0 11px; font-size: 13px; display: block; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.bubble th { background: rgba(255, 255, 255, .04); font-weight: 600; }
.bubble details {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px;
  margin: 0 0 11px; background: rgba(255, 255, 255, .02);
}
.bubble details > summary { cursor: pointer; font-size: 12.5px; color: var(--muted); list-style: none; }
.bubble details > summary::-webkit-details-marker { display: none; }
.bubble details > summary::before { content: '▸ '; }
.bubble details[open] > summary::before { content: '▾ '; }
.bubble details[open] > summary { margin-bottom: 8px; }

/* composer */
.composer { flex: 0 0 auto; padding: 8px 22px 18px; }
.composer-inner {
  max-width: 780px; margin: 0 auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; padding: 9px 10px 9px 12px;
  display: flex; align-items: flex-end; gap: 8px;
  transition: border-color .14s ease;
}
.composer-inner:focus-within { border-color: rgba(109, 94, 252, .5); }
.composer textarea {
  flex: 1; resize: none; max-height: 168px; min-height: 24px; padding: 5px 2px;
  line-height: 1.5;
}
.composer textarea::placeholder { color: var(--dim); }
.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  color: var(--muted); flex: 0 0 32px; transition: color .12s, background-color .12s;
}
.icon-btn:hover { color: var(--text); background: var(--raise); }
.icon-btn svg { width: 17px; height: 17px; }
.send { background: var(--accent); color: #fff; }
.send:hover { background: #7d70ff; }
.send:disabled { opacity: .4; cursor: default; background: var(--accent); }
.send.rec { background: var(--danger); }

.findbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 22px;
  border-top: 1px solid var(--line); background: var(--panel);
}
.findbar[hidden] { display: none; }
.findbar input {
  flex: 1; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 11px; font-size: 12.5px;
}

/* ---------- right panel ---------- */
.side {
  background: var(--panel); border-left: 1px solid var(--line);
  overflow-y: auto; min-height: 0; padding: 18px 16px; display: flex; flex-direction: column; gap: 16px;
}
.agent-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.agent-av {
  width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center;
  font-size: 26px; background: linear-gradient(140deg, #2a2740, #1a1826);
  border: 1px solid var(--line-2);
}
.agent-name { font-size: 15px; font-weight: 600; }
.agent-sub { font-size: 11.5px; color: var(--muted); margin-top: -4px; }
.status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .16); }
.dot.bad { background: var(--danger); }

.switcher {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; display: flex; align-items: center; gap: 8px;
  font-size: 13px; transition: border-color .12s;
}
.switcher:hover { border-color: var(--line-2); }
.switcher .grow { text-align: left; }

.sec-title {
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--dim); font-weight: 600;
}
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
  border-radius: 12px; padding: 11px; min-height: 78px; cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid rgba(255, 255, 255, .1);
  transition: transform .12s ease; color: #fff;
}
.card:hover { transform: translateY(-1px); }
.card.soul { background: linear-gradient(150deg, #b4245f, #e0447a); }
.card.mem { background: linear-gradient(150deg, #b8342c, #e2622f); }
.card.idn { background: linear-gradient(150deg, #1f5f8b, #2f8fc4); }
.card.usr { background: linear-gradient(150deg, #1f7a5a, #2fa87a); }
.card.t-name { font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.card.t-sub { font-size: 8.5px; opacity: .8; letter-spacing: .04em; }
.card.t-foot { display: flex; align-items: center; justify-content: space-between; font-size: 11px; }

.tabs { display: flex; gap: 4px; background: var(--surface); padding: 3px; border-radius: 9px; }
.tab { flex: 1; text-align: center; font-size: 12px; padding: 5px 0; border-radius: 7px; color: var(--muted); white-space: nowrap; }
.tab.on { background: var(--raise); color: var(--text); }

.fs-bar { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.fs-bar .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.fs { display: flex; flex-direction: column; gap: 1px; font-size: 12.5px; }
.fs-row {
  display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 7px;
  width: 100%; text-align: left; transition: background-color .1s;
}
.fs-row:hover { background: var(--raise); }
.fs-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-row .sz { margin-left: auto; color: var(--dim); font-size: 10.5px; flex: 0 0 auto; }
.fs-ico { width: 14px; flex: 0 0 14px; color: var(--dim); }
.fs-ico.d { color: var(--accent); }

.muted { color: var(--muted); font-size: 12px; }
.empty { color: var(--dim); font-size: 12.5px; text-align: center; padding: 14px 0; }

/* ---------- status panel ---------- */
.panel-back { position: fixed; inset: 0; background: rgba(4, 4, 8, .5); z-index: 44; }
.panel-back[hidden] { display: none; }
.status-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(430px, 100%);
  background: var(--panel); border-left: 1px solid var(--line-2); z-index: 45;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.status-panel[hidden] { display: none; }
.sp-head { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.sp-tabs { margin: 10px 12px 0; flex: 0 0 auto; }
.sp-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 14px 20px; }

.act-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.act-row .at { flex: 0 0 auto; color: var(--dim); font-size: 10.5px; min-width: 54px; }
.act-row .an { flex: 1; min-width: 0; word-break: break-word; }
.act-row .ab { flex: 0 0 auto; font-size: 9.5px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--muted); }
.act-row .ab.started { color: var(--warn); }
.act-row .ab.completed { color: var(--ok); }
.act-row .ab.failed { color: var(--danger); }

.cron-row { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.cron-row .cn { font-weight: 600; }
.cron-row .cd { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.cron-row .pill { margin-right: 5px; }

.kv { display: flex; gap: 10px; padding: 6px 0; font-size: 12.5px; }
.kv .kk { flex: 0 0 44%; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv .vv { flex: 1; word-break: break-word; }

/* ---------- dialogs ---------- */
.modal { position: fixed; inset: 0; background: rgba(4, 4, 8, .72); z-index: 50;
  display: grid; place-items: center; padding: 28px; }
.modal[hidden] { display: none; }
.modal-box {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px;
  width: min(880px, 100%); max-height: 84vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-box.wide { width: min(1000px, 100%); height: 80vh; }
.modal-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); font-size: 12.5px; flex: 0 0 auto;
}
.modal-head .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { overflow: auto; padding: 16px 18px; }
.modal-body pre { margin: 0; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; word-wrap: break-word; }
.modal-body.md h1, .modal-body.md h2, .modal-body.md h3 { margin: 16px 0 8px; }
.modal-body.md p { margin: 0 0 10px; }

.set-wrap { display: grid; grid-template-columns: 216px 1fr; min-height: 0; flex: 1 1 auto; }
.set-nav {
  border-right: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column;
  gap: 2px; overflow-y: auto;
}
.set-nav button { text-align: left; padding: 8px 11px; border-radius: 8px; font-size: 12.5px; color: var(--muted); }
.set-nav button:hover { background: var(--raise); color: var(--text); }
.set-nav button.on { background: var(--accent-soft); color: #fff; }
.set-pane { padding: 16px 18px; overflow-y: auto; min-height: 0; }
.set-pane h3 { font-size: 13.5px; margin: 0 0 12px; }
.set-pane .row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.set-pane .row .rl { flex: 0 0 42%; color: var(--muted); }
.set-pane .row .rv { flex: 1; word-break: break-word; }

/* ---------- palette ---------- */
.pal { position: fixed; inset: 0; background: rgba(4, 4, 8, .6); z-index: 55;
  display: flex; justify-content: center; align-items: flex-start; padding: 72px 20px 20px; }
.pal[hidden] { display: none; }
.pal-box {
  width: min(620px, 100%); background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column;
  max-height: 70vh; overflow: hidden;
}
.pal-in { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--line); color: var(--muted); }
.pal-in input { flex: 1; font-size: 14px; }
.pal-in input::placeholder { color: var(--dim); }
.pal-res { overflow-y: auto; padding: 8px; }
.pal-foot { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-top: 1px solid var(--line); }
.pal-item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 9px;
}
.pal-item:hover, .pal-item.on { background: var(--raise); }
.pal-item .pt { font-size: 13px; font-weight: 600; }
.pal-item .ps { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- mobile bottom bar ---------- */
.bottombar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  background: var(--rail); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottombar .bb {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 9.5px; color: var(--dim); padding: 4px 0; border-radius: 9px;
}
.bottombar .bb svg { width: 20px; height: 20px; }
.bottombar .bb.on { color: #fff; }
.sheet { position: fixed; inset: 0; background: rgba(4, 4, 8, .6); z-index: 56; display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-in {
  width: 100%; background: var(--panel); border-top-left-radius: 16px; border-top-right-radius: 16px;
  padding: 12px 10px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 3px;
}
.sheet-in button { text-align: left; padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.sheet-in button:hover { background: var(--raise); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--raise); border: 1px solid var(--line-2); color: var(--text);
  padding: 9px 15px; border-radius: 10px; font-size: 12.5px; z-index: 70;
  box-shadow: var(--shadow); max-width: 80vw;
}
.toast[hidden] { display: none; }

/* ---------- lock screen ---------- */
.lock {
  position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center;
  z-index: 80; padding: 20px;
}
.lock[hidden] { display: none; }
.lock-box { width: 100%; max-width: 320px; text-align: center; }
.lock-logo {
  width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 16px;
  background: linear-gradient(140deg, var(--accent), #a78bfa);
  display: grid; place-items: center; font-size: 22px; font-weight: 700;
  box-shadow: 0 8px 26px rgba(109, 94, 252, .35);
}
.lock h2 { font-size: 17px; margin: 0 0 6px; }
.lock p { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
.lock input {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px; text-align: center; letter-spacing: .12em;
}
.lock input:focus { border-color: rgba(109, 94, 252, .55); }
.lock button {
  width: 100%; margin-top: 10px; background: var(--accent); color: #fff;
  padding: 11px; border-radius: 10px; font-weight: 600;
}
.lock button:hover { background: #7d70ff; }
.lock .err { color: var(--danger); font-size: 12px; margin-top: 10px; min-height: 16px; }

/* ---------- light theme ---------- */
html.light {
  --bg: #fbfbfd;
  --rail: #f2f2f6;
  --panel: #f6f6f9;
  --surface: #ffffff;
  --raise: #ececf2;
  --line: rgba(0, 0, 0, .09);
  --line-2: rgba(0, 0, 0, .16);
  --text: #16161c;
  --muted: #62626f;
  --dim: #8b8b98;
  --accent: #5b4bf0;
  --accent-soft: rgba(91, 75, 240, .1);
  --shadow: 0 8px 24px rgba(0, 0, 0, .1);
}
html.light .bubble code { background: rgba(0, 0, 0, .06); }
html.light .bubble pre.code { background: #f4f4f8; }
html.light .bubble th { background: rgba(0, 0, 0, .03); }
html.light .bubble details { background: rgba(0, 0, 0, .02); }
html.light .card { color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: 54px 1fr; }
  .side { display: none; }
}
@media (max-width: 620px) {
  /* The rail collapses and the bottom bar takes over — on a phone the app must
     never be left without navigation. */
  .app { grid-template-columns: 1fr; padding-bottom: 58px; }
  .rail { display: none; }
  .bottombar { display: flex; }
  .composer-inner { border-radius: 14px; }
  .topbar { padding: 0 12px; }
  .search-box.asbtn { max-width: none; flex: 1; }
  .hero { padding: 10px 0 2px; }
  .set-wrap { grid-template-columns: 1fr; }
  .set-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .set-nav button { white-space: nowrap; }
  .status-panel { width: 100%; }
  .modal { padding: 12px; }
  .modal-box.wide { height: 88vh; }
  .pal { padding: 20px 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
