:root {
  --void: #080A1C;
  --deep: #0C0F26;
  --panel: #11152F;
  --panel-2: #171C3D;
  --line: #262C5A;
  --line-soft: #1B2048;
  --text: #ECEAFB;
  --muted: #8E93BD;
  --dim: #5C6192;
  --core: #F3F0FF;

  --t-feature: #7CF29A;
  --t-change: #5AA9FF;
  --t-run: #FFB938;
  --t-error: #FF4D6D;
  --t-fix: #2EE6D6;
  --t-notify: #F472D0;
  --t-log: #9AA0C8;
  --t-media: #B18CFF;

  --display: 'Unbounded', 'Golos Text', system-ui, sans-serif;
  --body: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  font: 400 14px/1.45 var(--body);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% 18%, #1A1550 0%, transparent 60%),
    radial-gradient(900px 500px at 8% 90%, #0E2A4A 0%, transparent 55%),
    var(--void);
  background-attachment: fixed;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--t-media); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: .92em; color: var(--t-fix); }

/* ── шапка ─────────────────────────────────────────────── */
.top {
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  padding: 14px 20px 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font: 600 17px/1.1 var(--display); letter-spacing: -.01em; }
.brand p { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%; flex: none; position: relative;
  background: radial-gradient(circle at 38% 34%, #fff, var(--core) 35%, #9C8CFF 100%);
  box-shadow: 0 0 22px #8E7BFF99;
}
.brand-mark::after {
  content: ''; position: absolute; inset: -7px -12px; border-radius: 50%;
  border: 2px solid var(--t-media); border-left-color: var(--t-fix); border-bottom-color: var(--t-notify);
  transform: rotate(-22deg) scaleY(.42); animation: spin 9s linear infinite;
}
@keyframes spin { to { transform: rotate(-22deg) scaleY(.42) rotate(360deg); } }

.top-stats { display: flex; gap: 26px; margin-left: 8px; }
.stat { display: flex; flex-direction: column; }
.stat b { font: 600 20px/1.1 var(--display); }
.stat span { color: var(--muted); font-size: 12px; }
.stat-err b { color: var(--t-error); }
.stat-fix b { color: var(--t-fix); }

.top-tools { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.clock { font: 400 15px var(--display); color: var(--text); min-width: 92px; text-align: right; }
.link { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.link i { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.link.on i { background: var(--t-feature); box-shadow: 0 0 0 0 #7CF29A88; animation: ping 2s infinite; }
.link.on { color: var(--text); }
.link.off i { background: var(--t-error); }
@keyframes ping { 70% { box-shadow: 0 0 0 9px #7CF29A00; } 100% { box-shadow: 0 0 0 0 #7CF29A00; } }

.btn {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--panel-2); border-color: #3A4285; }
.btn:active { transform: scale(.96); }
.btn[aria-pressed="true"] { background: var(--t-run); color: #1A1200; border-color: transparent; font-weight: 600; }
.btn-main { background: var(--core); color: #0C0F26; border-color: transparent; font-weight: 600; padding: 11px 18px; }
.btn-main:hover { background: #fff; }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 999px; color: var(--muted); transition: color .15s, background .2s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px #3A4285; }

/* ── бегущая лента ─────────────────────────────────────── */
.wire {
  display: flex; align-items: center; gap: 12px;
  border-block: 1px solid var(--line-soft); background: #0A0D2299; padding: 0 20px; height: 34px;
}
.wire-tag { font: 600 11.5px var(--display); color: var(--void); background: var(--core); padding: 3px 9px; border-radius: 6px; flex: none; }
.wire-track { overflow: hidden; flex: 1; mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent); }
.wire-run { display: inline-flex; gap: 34px; white-space: nowrap; animation: wire 70s linear infinite; padding-left: 20px; }
.wire:hover .wire-run { animation-play-state: paused; }
@keyframes wire { to { transform: translateX(-50%); } }
.wire-item { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.wire-item b { color: var(--text); font-weight: 500; }
.wire-item:hover b { text-decoration: underline; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--dim)); flex: none; box-shadow: 0 0 8px var(--c, transparent); }

/* ── чипы проектов ─────────────────────────────────────── */
.chips { display: flex; gap: 8px; padding: 12px 20px 4px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 9px; flex: none;
  padding: 7px 13px 7px 9px; border-radius: 12px; border: 1px solid var(--line-soft);
  background: #0E1230CC; color: var(--muted); transition: border-color .2s, color .2s, background .2s, transform .12s;
}
.chip:hover { color: var(--text); border-color: var(--line); }
.chip:active { transform: scale(.97); }
.chip.on { color: var(--text); border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--panel)); }
.chip .mono { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; font: 600 10px var(--display); color: #0A0C1E; background: var(--c); }
.chip em { font-style: normal; font-size: 12px; color: var(--dim); }
.chip.on em { color: var(--text); }

/* ── сетка ─────────────────────────────────────────────── */
.grid {
  display: grid; gap: 12px; padding: 10px 20px 28px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-areas:
    "pr pr pr re re re re re re si si si"
    "ty ty ty ty ty ty ty ty ty ty ty ty"
    "tl tl tl tl tl tl tl he he he he he"
    "jo jo jo jo jo jo jo jo me me me me";
}
.p-projects { grid-area: pr; } .p-reactor { grid-area: re; } .p-side { grid-area: si; }
.types { grid-area: ty; } .p-timeline { grid-area: tl; } .p-heat { grid-area: he; }
.p-journal { grid-area: jo; } .p-media { grid-area: me; }

.panel {
  background: linear-gradient(180deg, #121634E6, #0E1230E6);
  border: 1px solid var(--line-soft); border-radius: var(--r);
  display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
}
.panel > header { display: flex; align-items: baseline; gap: 12px; padding: 12px 14px 8px; flex-wrap: wrap; }
.panel > header.sub { border-top: 1px solid var(--line-soft); margin-top: 6px; }
.panel h2 { font: 600 13px var(--display); letter-spacing: -.005em; }
.hint { color: var(--dim); font-size: 12px; }

.p-projects, .p-reactor, .p-side { height: 540px; }

/* проекты */
.proj-list { overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 4px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.proj {
  display: grid; grid-template-columns: 30px 1fr 86px; gap: 10px; align-items: center; text-align: left;
  padding: 9px 8px; border-radius: 10px; border: 1px solid transparent; background: none; width: 100%;
  transition: background .15s, border-color .2s, opacity .25s;
}
.proj:hover { background: #1A1F47; }
.proj.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); }
.proj.dim { opacity: .38; }
.proj .mono { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font: 600 11px var(--display); color: #0A0C1E; background: var(--c); position: relative; }
.proj.alert .mono::after { content: ''; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--t-error); box-shadow: 0 0 0 2px var(--panel); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.proj-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj svg { width: 86px; height: 28px; overflow: visible; }
.proj svg path.l { fill: none; stroke: var(--c); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.proj svg path.a { fill: var(--c); opacity: .14; }

/* реактор */
.reactor-wrap { position: relative; flex: 1; min-height: 0; }
.reactor-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#stage { cursor: default; }

/* боковые списки */
.feed { overflow-y: auto; flex: 1; padding: 0 8px 6px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; min-height: 60px; }
.feed li {
  display: grid; grid-template-columns: 8px 1fr auto; gap: 10px; align-items: start;
  padding: 7px 6px; border-radius: 8px; cursor: pointer; transition: background .15s;
}
.feed li:hover { background: #1A1F47; }
.feed li .dot { margin-top: 6px; }
.feed li p { font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.feed li small { color: var(--dim); font-size: 11.5px; display: block; margin-top: 1px; }
.feed li time { color: var(--dim); font-size: 11.5px; white-space: nowrap; }
.empty { color: var(--dim); padding: 14px; font-size: 13px; }
.fresh { animation: fresh 1.6s var(--ease); }
@keyframes fresh { 0% { background: color-mix(in srgb, var(--c, #fff) 30%, transparent); transform: translateX(-6px); } 100% { background: transparent; transform: none; } }

/* типы событий */
.types { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
.type {
  position: relative; text-align: left; padding: 12px 14px 13px; border-radius: var(--r);
  border: 1px solid var(--line-soft); background: #0F1331E6; overflow: hidden;
  transition: border-color .2s, transform .12s, background .2s, opacity .25s;
}
.type::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c); }
.type:hover { border-color: var(--c); }
.type:active { transform: scale(.98); }
.type.on { background: color-mix(in srgb, var(--c) 16%, var(--panel)); border-color: var(--c); }
.type.dim { opacity: .45; }
.type b { display: block; font: 600 24px/1.1 var(--display); color: var(--c); }
.type span { display: block; color: var(--text); font-size: 13px; margin-top: 4px; }
.type small { color: var(--dim); font-size: 11.5px; }
.type kbd { position: absolute; right: 10px; top: 10px; font: 500 10.5px var(--body); color: var(--dim); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.type.bump b { animation: bump .5s var(--ease); }
@keyframes bump { 30% { transform: scale(1.22); } }

/* графики */
.chart-wrap { position: relative; flex: 1; min-height: 230px; padding: 0 10px 10px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.tip {
  position: absolute; z-index: 3; pointer-events: none; min-width: 150px;
  background: #0A0D22F2; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12.5px;
  box-shadow: 0 10px 30px #0008;
}
.tip h4 { margin: 0 0 4px; font: 500 12px var(--body); color: var(--muted); }
.tip div { display: flex; align-items: center; gap: 7px; }
.tip div b { margin-left: auto; padding-left: 14px; }

.heat { padding: 2px 14px 14px; display: grid; gap: 4px; overflow-x: auto; }
.heat-row { display: grid; grid-template-columns: 128px repeat(14, minmax(14px, 1fr)); gap: 4px; align-items: center; }
.heat-row > span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.heat-row > span:hover { color: var(--text); }
.heat-row i { height: 20px; border-radius: 5px; background: color-mix(in srgb, var(--c) calc(var(--v) * 100%), #171C3D); transition: transform .12s, background .4s; font-style: normal; }
.heat-row i:hover { transform: scale(1.25); outline: 1px solid var(--text); }
.heat-row.head i { background: none; height: auto; font-size: 10.5px; color: var(--dim); text-align: center; }
.heat-row.head i:hover { transform: none; outline: 0; }

/* журнал */
.p-journal, .p-media { height: 460px; }
.search { margin-left: auto; }
.search input {
  width: 300px; max-width: 100%; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: #0A0D22; outline-offset: 0;
}
.search input::placeholder { color: var(--dim); }
.journal { overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.row {
  display: grid; grid-template-columns: 96px 150px 128px 1fr; gap: 12px; align-items: center;
  padding: 7px 14px; border-top: 1px solid #1B204866; cursor: pointer; font-size: 13px;
}
.row:hover { background: #1A1F47; }
.row time { color: var(--dim); font-size: 12px; white-space: nowrap; }
.row .rp { display: flex; align-items: center; gap: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.row .rt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--c); white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 2px; background: var(--c); }

/* медиа */
.media { overflow-y: auto; flex: 1; padding: 2px 10px 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; align-content: start; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.tile {
  text-align: left; border: 1px solid var(--line-soft); border-radius: 12px; background: #0D1130; padding: 10px;
  display: grid; gap: 6px; transition: border-color .2s, transform .15s var(--ease);
}
.tile:hover { border-color: var(--t-media); transform: translateY(-2px); }
.tile .ico { height: 54px; border-radius: 8px; display: grid; place-items: center; font: 600 11px var(--display); color: var(--kc); background: color-mix(in srgb, var(--kc) 13%, #0A0D22); }
.tile b { font-weight: 500; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile small { color: var(--dim); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* карточка события */
.drawer {
  position: fixed; right: 16px; top: 16px; bottom: 16px; width: min(440px, calc(100vw - 32px)); z-index: 20;
  background: #0C0F26F7; border: 1px solid var(--line); border-radius: 18px; padding: 22px; overflow-y: auto;
  box-shadow: -20px 0 60px #000A; animation: drawer .28s var(--ease);
}
@keyframes drawer { from { transform: translateX(30px); opacity: 0; } }
.drawer-x { position: absolute; right: 14px; top: 14px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); }
.drawer h3 { font: 600 16px/1.35 var(--display); margin: 12px 0 14px; overflow-wrap: anywhere; }
.drawer dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0 0 16px; font-size: 13px; }
.drawer dt { color: var(--dim); }
.drawer dd { margin: 0; overflow-wrap: anywhere; }
.drawer pre { white-space: pre-wrap; overflow-wrap: anywhere; background: #080A1C; border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px; font: 12.5px/1.5 ui-monospace, 'Cascadia Mono', Consolas, monospace; color: #C9CCF0; margin: 0; }

/* вход */
.login { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: #080A1CE6; backdrop-filter: blur(10px); padding: 16px; }
.login[hidden], .drawer[hidden], .tip[hidden] { display: none; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; justify-items: start; padding: 28px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); }
.login-card h2 { font: 600 20px var(--display); margin-top: 6px; }
.login-card p { color: var(--muted); font-size: 13.5px; }
.login-card input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #0A0D22; }
.login-card .btn-main { width: 100%; }
.login-err { color: var(--t-error) !important; min-height: 1.2em; }

/* ── адаптив ───────────────────────────────────────────── */
@media (max-width: 1280px) {
  .grid {
    grid-template-areas:
      "re re re re re re re re si si si si"
      "pr pr pr pr pr pr pr pr pr pr pr pr"
      "ty ty ty ty ty ty ty ty ty ty ty ty"
      "tl tl tl tl tl tl tl tl tl tl tl tl"
      "he he he he he he he he he he he he"
      "jo jo jo jo jo jo jo jo jo jo jo jo"
      "me me me me me me me me me me me me";
  }
  .p-projects { height: auto; max-height: 360px; }
  .types { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .top { gap: 14px; padding: 12px 14px; }
  .top-tools { margin-left: 0; }
  .grid { padding: 8px 12px 24px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "re" "si" "pr" "ty" "tl" "he" "jo" "me"; }
  .p-reactor { height: 420px; } .p-side { height: 400px; }
  .types { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row { grid-template-columns: 70px 1fr; }
  .row .rp, .row .badge { display: none; }
  .search { margin-left: 0; width: 100%; } .search input { width: 100%; }
  .chips, .wire { padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .wire-run { animation: none; }
}

/* ── ИИ-разбор ошибок ──────────────────────────────────── */
.link.ai-on i { background: var(--t-media); box-shadow: 0 0 10px var(--t-media); }
.link.ai-on { color: var(--text); }
.link.ai-off i { background: var(--dim); }
.feed li small.ai { color: var(--t-media); margin-top: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.feed li small.ai.noise { color: var(--dim); }
.ai-note { border: 1px solid color-mix(in srgb, var(--t-media) 45%, var(--line)); background: color-mix(in srgb, var(--t-media) 8%, #0C0F26); border-radius: 14px; padding: 14px; margin-bottom: 16px; }
.ai-note.noise { border-color: var(--line); background: #0E1230; }
.ai-note h4 { margin: 0 0 8px; font: 600 13px var(--display); color: var(--t-media); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.ai-note.noise h4 { color: var(--muted); }
.ai-note h4 span { font: 400 11.5px var(--body); color: var(--dim); }
.ai-note h5 { margin: 12px 0 3px; font: 500 12px var(--body); color: var(--muted); }
.ai-note p { font-size: 13.5px; overflow-wrap: anywhere; white-space: pre-wrap; }
.ai-note .ai-sum { font-weight: 500; }
.ai-note .cmd { display: flex; gap: 8px; align-items: center; margin-top: 8px; background: #080A1C; border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px 8px 8px 12px; }
.ai-note .cmd code { flex: 1; overflow-wrap: anywhere; color: #C9CCF0; }
.ai-note .cmd .btn { flex: none; font-size: 12px; padding: 5px 10px; }
.ai-note .ai-warn { margin-top: 12px; font-size: 12px; color: var(--dim); }
.feed li.empty { display: block; cursor: default; }
.feed li.empty:hover { background: none; }

/* ── Монитор: ИИ-наблюдатель ───────────────────────────── */
:root { --mon: #FF3B4E; }
.mon-face, .msg-face, .alarm-face { background: #15171c url('/ai-monitor.jpg') 50% 20% / 285% auto no-repeat; border-radius: 50%; display: block; }
.mon { position: fixed; right: 22px; bottom: 22px; z-index: 30; width: 84px; height: 84px; border: 0; border-radius: 50%; padding: 0; background: none; transition: transform .25s var(--ease); }
.mon:hover { transform: scale(1.07) rotate(-3deg); }
.mon:active { transform: scale(.96); }
.mon-face { position: absolute; inset: 5px; box-shadow: 0 10px 30px #000A, 0 0 26px #FF3B4E55; animation: mon-breathe 4s ease-in-out infinite; }
.mon-ring { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, var(--mon), transparent 30%, #B18CFF 50%, transparent 80%, var(--mon)); animation: mon-spin 7s linear infinite; mask: radial-gradient(circle, transparent 37px, #000 38px); -webkit-mask: radial-gradient(circle, transparent 37px, #000 38px); }
.mon.thinking .mon-ring { animation-duration: 1.1s; }
.mon.waiting .mon-ring { background: conic-gradient(from 0deg, var(--t-run), transparent 35%, var(--t-run) 50%, transparent 85%, var(--t-run)); }
.mon.alert { animation: mon-shake .45s linear infinite; }
.mon.alert .mon-ring { background: var(--mon); animation: mon-flash .5s steps(2) infinite; }
.mon.alert .mon-face { box-shadow: 0 0 0 4px #FF3B4E66, 0 0 60px var(--mon); filter: saturate(1.5) brightness(1.15); }
.mon-badge { position: absolute; top: -2px; right: -2px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--t-run); color: #1A1200; font: 600 12px/24px var(--display); box-shadow: 0 0 0 3px var(--void); }
@keyframes mon-spin { to { transform: rotate(360deg); } }
@keyframes mon-breathe { 50% { filter: brightness(1.18) saturate(1.25); } }
@keyframes mon-shake { 25% { transform: translate(-3px, 1px) rotate(-4deg); } 75% { transform: translate(3px, -1px) rotate(4deg); } }
@keyframes mon-flash { 50% { opacity: .25; } }

.mon-bubble { position: fixed; right: 118px; bottom: 34px; z-index: 30; max-width: min(380px, calc(100vw - 150px)); padding: 12px 15px; border-radius: 16px 16px 4px 16px; background: #12152EF5; border: 1px solid var(--line); box-shadow: 0 14px 40px #000A; font-size: 13.5px; cursor: pointer; animation: bubble-in .3s var(--ease); }
.mon-bubble.alert { border-color: var(--mon); background: #2A0C16F7; box-shadow: 0 0 0 1px var(--mon), 0 0 44px #FF3B4E77; font-weight: 500; }
.mon-bubble[hidden], .alarm[hidden], .monp[hidden] { display: none; }
@keyframes bubble-in { from { opacity: 0; transform: translate(14px, 8px) scale(.94); } }

.edge { position: fixed; inset: 0; z-index: 45; pointer-events: none; opacity: 0; box-shadow: inset 0 0 0 3px var(--mon), inset 0 0 160px 30px #FF3B4E88; }
body.alarm-on .edge { animation: edge-pulse 1s ease-in-out 7; }
@keyframes edge-pulse { 0%, 100% { opacity: 0; } 45% { opacity: 1; } }

.alarm { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 40; width: min(760px, calc(100vw - 28px)); display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; background: linear-gradient(90deg, #4A0A18, #2A0C16); border: 1px solid var(--mon); box-shadow: 0 0 0 1px #FF3B4E55, 0 18px 60px #FF3B4E55; animation: alarm-in .45s var(--ease); }
.alarm-face { width: 52px; height: 52px; flex: none; box-shadow: 0 0 0 2px var(--mon), 0 0 24px var(--mon); animation: mon-flash 1s steps(2) infinite; }
.alarm-body { flex: 1; min-width: 0; }
.alarm-body b { font: 600 14px var(--display); color: #FFD9DE; display: block; }
.alarm-body p { font-size: 13px; color: #FFB3BD; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.btn-alarm { background: var(--mon); color: #fff; border-color: transparent; font-weight: 600; }
.btn-alarm:hover { background: #FF5D6D; border-color: transparent; }
@keyframes alarm-in { from { transform: translate(-50%, -120%); } }

.monp { position: fixed; right: 16px; top: 16px; bottom: 16px; z-index: 35; width: min(500px, calc(100vw - 32px)); display: flex; flex-direction: column; background: #0B0D20FA; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; box-shadow: -24px 0 70px #000B; animation: drawer .3s var(--ease); }
.monp-head { position: relative; height: 150px; flex: none; }
.monp-hero { position: absolute; inset: 0; background: url('/ai-monitor.jpg') 50% 18% / cover; }
.monp-hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, #0B0D2000 25%, #0B0D20 100%), linear-gradient(90deg, #0B0D20CC, transparent 60%); }
.monp-id { position: absolute; left: 18px; bottom: 12px; right: 60px; }
.monp-id h2 { font: 600 22px var(--display); }
.monp-id p { font-size: 12.5px; color: #D9C9D0; margin-top: 3px; }
.monp-scroll { flex: 1; overflow-y: auto; padding: 10px 14px 14px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.monp-title { font: 600 13px var(--display); margin: 6px 2px 10px; color: var(--t-run); }
.monp-done { margin: 4px 0 12px; }
.monp-done summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 2px; }
.monp-foot { flex: none; border-top: 1px solid var(--line-soft); padding: 10px 12px 12px; display: grid; gap: 8px; background: #0E1128; }
.monp-chips, .monp-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.monp-foot .btn { font-size: 12.5px; padding: 6px 11px; }
.monp-toggles .btn { color: var(--muted); }
.monp-toggles .btn[aria-pressed="true"] { background: var(--panel-2); color: var(--text); border-color: #3A4285; font-weight: 400; }

.msg { display: flex; gap: 9px; margin: 10px 0; align-items: flex-end; }
.msg-face { width: 30px; height: 30px; flex: none; }
.msg-body { max-width: 86%; padding: 9px 12px; border-radius: 14px 14px 14px 4px; background: var(--panel-2); font-size: 13.5px; overflow-wrap: anywhere; }
.msg.me { justify-content: flex-end; }
.msg.me .msg-body { background: #2B3170; border-radius: 14px 14px 4px 14px; }
.msg.alert .msg-body { background: #3A0E1A; box-shadow: inset 0 0 0 1px var(--mon); }
.msg-body time { display: block; font-size: 11px; color: var(--dim); margin-top: 4px; }
.msg-list { margin-top: 6px; display: grid; gap: 6px; }
.msg-list li { display: grid; }
.msg-list small { color: var(--muted); font-size: 12px; }
.bad { color: #FF8A99; }
.btn-mini { font-size: 12px; padding: 3px 9px; margin-left: 4px; }
.link-btn { background: none; border: 0; padding: 0; text-align: left; color: var(--t-change); text-decoration: underline; text-underline-offset: 2px; }

.plan { border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 12px; background: #10142F; }
.plan.wait { border-color: var(--t-run); box-shadow: 0 0 0 1px #FFB93833, 0 0 30px #FFB9381F; }
.plan.bad { border-color: var(--mon); }
.plan.ok { border-color: #2EE6D688; }
.plan > header { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--dim); }
.plan-status { font: 600 11.5px var(--display); padding: 3px 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.plan.wait .plan-status { background: var(--t-run); color: #1A1200; }
.plan.run .plan-status { background: var(--t-change); color: #04142A; }
.plan.ok .plan-status { background: var(--t-fix); color: #022; }
.plan.bad .plan-status { background: var(--mon); color: #fff; }
.plan.manual .plan-status { background: var(--t-notify); color: #2A0420; }
.plan h3 { font: 600 15px/1.35 var(--display); margin: 10px 0 2px; overflow-wrap: anywhere; }
.plan h4 { font: 500 12px var(--body); color: var(--muted); margin: 14px 0 4px; }
.plan p { font-size: 13.5px; overflow-wrap: anywhere; }
.plan-proj { color: var(--muted); font-size: 12.5px !important; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { display: grid; grid-template-columns: 24px 1fr; gap: 10px; }
.steps li > div { min-width: 0; }
.step-n { width: 24px; height: 24px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font: 600 11px var(--display); }
.plan pre { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; background: #080A1C; border: 1px solid var(--line-soft); border-radius: 10px; padding: 9px 11px; font: 12.5px/1.5 ui-monospace, 'Cascadia Mono', Consolas, monospace; color: #C9CCF0; }
.plan pre.result { max-height: 260px; overflow-y: auto; }
.diff .del { color: #FF8A99; } .diff .add { color: #7CF29A; }
.plan-note { margin-top: 14px; font-size: 12.5px !important; color: var(--muted); }
.plan-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn-confirm { background: var(--t-feature); color: #03210E; border-color: transparent; font-weight: 600; padding: 10px 20px; }
.btn-confirm:hover { background: #9BFFB4; border-color: transparent; }
.btn:disabled { opacity: .5; cursor: wait; }
.plan-open { width: 100%; margin-bottom: 14px; }
.link { cursor: default; } #aiStatus { cursor: pointer; }

@media (max-width: 820px) {
  .mon { width: 64px; height: 64px; right: 12px; bottom: 12px; }
  .mon-ring { mask: radial-gradient(circle, transparent 27px, #000 28px); -webkit-mask: radial-gradient(circle, transparent 27px, #000 28px); }
  .mon-bubble { right: 86px; bottom: 18px; }
  .alarm { flex-wrap: wrap; }
}
