/* ═══ 777 INNER PROTECTION — Gumloop-style chat UI ═══ */
:root {
  --bg: #0a0a0b;
  --bg-soft: #131316;
  --panel: #1a1a1f;
  --panel-2: #222228;
  --border: #2c2c34;
  --text: #ececf1;
  --text-dim: #9c9ca8;
  --text-faint: #6b6b78;
  --a: #2563eb;          /* accent (theme-able) */
  --a2: #1d4ed8;
  --a-dim: #2563eb1f;
  --bubble: #26262e;
  --radius: 18px;
  --radius-sm: 12px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
kbd {
  font-family: var(--mono); font-size: 10px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}

/* ── avatars ── */
.avatar {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: var(--a); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; letter-spacing: -.5px;
}
.avatar.sm { width: 32px; height: 32px; border-radius: 9px; font-size: 11px; }

/* ═══ GATE — classic 777 style ═══ */
#gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: #050508; overflow: hidden;
  transition: opacity .4s, visibility .4s;
}
#gate.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
#gateCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.gate-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 45%, rgba(0,0,0,.28) 100%);
}
.gate-inner {
  position: relative; text-align: center; padding: 44px 40px;
  max-width: 400px; width: 92%;
  background: linear-gradient(180deg, rgba(16,16,24,.58), rgba(8,8,13,.68));
  border: 1px solid rgba(232,168,64,.14); border-radius: 18px;
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  box-shadow: 0 24px 70px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.04);
  animation: gateIn .7s cubic-bezier(.22,.9,.3,1);
}
@keyframes gateIn { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
.gate-mark {
  font-family: var(--mono); font-size: 12px; letter-spacing: 5px;
  color: var(--a); opacity: .75; margin-bottom: 10px;
}
.gate-title {
  font-family: Georgia, serif;
  font-size: 64px; font-weight: 700; letter-spacing: 4px; line-height: 1; margin: 0;
  background: linear-gradient(180deg, #f5cf8a, var(--a) 55%, var(--a2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 26px rgba(232,168,64,.28));
}
.gate-sub {
  font-family: var(--mono); font-size: 12px; letter-spacing: 6px;
  text-transform: uppercase; color: var(--text-dim); margin: 12px 0 40px;
}
.gate-form { display: flex; flex-direction: column; gap: 12px; }
.gate-input-wrap {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; color: var(--text-faint);
  transition: border-color .2s;
}
.gate-input-wrap:focus-within { border-color: var(--a); }
.gate-input-wrap input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 15px; letter-spacing: 1px;
}
.gate-input-wrap input::placeholder { color: var(--text-faint); }
.gate-btn {
  background: var(--a); border: none; color: #0a0a10;
  border-radius: 10px; padding: 14px; font-size: 15px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  transition: background .15s, transform .1s;
}
.gate-btn:hover { background: var(--a2); }
.gate-btn:active { transform: scale(.98); }
.gate-btn:disabled { opacity: .6; }
.gate-err { min-height: 18px; font-family: var(--mono); font-size: 11px; letter-spacing: 1px; color: #f87171; }
.gate-last { font-family: var(--mono); font-size: 10px; color: var(--text-faint); margin-top: 4px; }
.gate-sec { margin-top: 22px; display: flex; flex-direction: column; gap: 7px; }
.gate-notice {
  font-family: var(--mono); font-size: 10px; letter-spacing: 2px;
  color: #f59e0b; opacity: .9;
}
.gate-notice2 {
  font-family: var(--mono); font-size: 9px; letter-spacing: 1.8px;
  color: var(--text-faint);
}
.gate-fp {
  font-family: var(--mono); font-size: 9px; letter-spacing: 1.8px;
  color: #4ade80; opacity: 0; transition: opacity .6s;
}
.gate-fp.show { opacity: .85; }
.gate-foot {
  margin-top: 26px; font-family: var(--mono); font-size: 10px;
  letter-spacing: 2px; color: var(--text-faint);
}
.shake { animation: shake .45s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-9px)} 40%{transform:translateX(9px)} 60%{transform:translateX(-6px)} 80%{transform:translateX(6px)} }

#granted {
  position: fixed; inset: 0; z-index: 99; display: flex; align-items: center; justify-content: center;
  background: var(--bg); opacity: 0; visibility: hidden; transition: opacity .5s, visibility .5s;
}
#granted.show { opacity: 1; visibility: visible; }
.granted-text {
  font-size: 26px; font-weight: 800; letter-spacing: 6px; color: var(--a);
  text-shadow: 0 0 30px rgba(232,168,64,.4);
}

/* ═══ APP LAYOUT ═══ */
#app { display: flex; height: 100vh; }
.hidden-app { display: none !important; }

/* sidebar */
#sb {
  width: 264px; flex-shrink: 0; background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 10px; gap: 10px;
}
.sb-logo { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.logo-shield {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 0 10px rgba(232,168,64,.25));
}
.sb-logo-name { font-weight: 700; font-size: 13px; letter-spacing: -.2px; white-space: nowrap; }
.sb-logo-sub { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }
.sb-new {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px; font-size: 14px; font-weight: 500;
  transition: background .15s;
}
.sb-new:hover { background: var(--panel-2); }
.sb-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; color: var(--text-faint);
}
.sb-search input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 13px; }
.sb-cats { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.cat-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: none; color: var(--text-dim);
  padding: 8px 10px; border-radius: 9px; font-size: 13.5px; text-align: left;
  transition: background .12s, color .12s;
}
.cat-btn:hover { background: var(--panel); color: var(--text); }
.cat-btn.active { background: var(--a-dim); color: var(--a); }
.cat-btn .cat-n { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); }
.sb-foot {
  display: flex; justify-content: space-between; padding: 8px 8px 2px;
  font-family: var(--mono); font-size: 10.5px; color: var(--text-faint);
  border-top: 1px solid var(--border);
}
#sbOverlay { display: none; }

/* main */
#main { flex: 1; overflow-y: auto; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
}
#menuBtn { display: none; background: none; border: none; color: var(--text); }
.topbar-titles h1 { font-size: 17px; font-weight: 700; }
.topbar-titles p { font-size: 12px; color: var(--text-faint); }
.topbar-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--panel); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 500;
  transition: all .12s; white-space: nowrap;
}
.chip:hover { background: var(--panel-2); color: var(--text); }
.clock-chip, .session-chip { font-family: var(--mono); font-size: 11px; }

/* dashboard */
.dash { padding: 22px 20px 6px; display: flex; flex-direction: column; gap: 22px; }
.dash-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--text-faint); margin-bottom: 10px; }
.dash-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.mini-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px 15px; cursor: pointer; transition: border-color .15s, transform .1s;
}
.mini-card:hover { border-color: var(--a); transform: translateY(-1px); }
.mini-card .mc-name { font-weight: 600; font-size: 13.5px; }
.mini-card .mc-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-empty { color: var(--text-faint); font-size: 13px; padding: 6px 2px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.cat-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; cursor: pointer; transition: border-color .15s, transform .1s;
}
.cat-card:hover { border-color: var(--a); transform: translateY(-1px); }
.cat-card .cc-icon { font-size: 20px; }
.cat-card .cc-name { font-weight: 600; font-size: 13.5px; margin-top: 8px; }
.cat-card .cc-n { font-family: var(--mono); font-size: 11px; color: var(--text-faint); margin-top: 2px; }

/* tools grid */
.tools-wrap { padding: 16px 20px 40px; }
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.tool-card {
  position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 15px 16px; cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.tool-card:hover { border-color: var(--a); transform: translateY(-1px); }
.tool-card .tc-name { font-weight: 600; font-size: 14px; padding-right: 26px; }
.tool-card .tc-desc { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; line-height: 1.45; }
.tool-card .tc-cat { font-family: var(--mono); font-size: 10px; color: var(--text-faint); margin-top: 8px; text-transform: uppercase; letter-spacing: .6px; }
.tool-card .tc-star {
  position: absolute; top: 12px; right: 12px; background: none; border: none;
  color: var(--text-faint); font-size: 16px; transition: color .12s;
}
.tool-card .tc-star.on { color: #fbbf24; }

/* ═══ MODULE MODAL ═══ */
#result {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; padding: 18px;
}
#result.open { opacity: 1; visibility: visible; }
.rm {
  width: 100%; max-width: 780px; max-height: 88vh; overflow-y: auto;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 14px;
}
.rh { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.rh-title h2 { font-size: 19px; font-weight: 700; }
.rh-meta { font-family: var(--mono); font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.rh-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text-dim); font-size: 17px;
  transition: all .12s;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); }
.icon-btn.on { color: #fbbf24; }
.rf { display: flex; gap: 8px; }
.rf input {
  flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 14px; color: var(--text); font-size: 14px; outline: none;
}
.rf input:focus { border-color: var(--a); }
.run-btn {
  background: var(--a); border: none; color: #fff; border-radius: var(--radius-sm);
  padding: 0 22px; font-weight: 600; font-size: 14px; transition: background .15s;
}
.run-btn:hover { background: var(--a2); }
.rstatus { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); min-height: 14px; }
.rstatus.err { color: #f87171; }
.rc {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; min-height: 140px; max-height: 46vh; overflow-y: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
}
.rc .loading { color: var(--text-faint); font-family: 'Inter', sans-serif; }
.rc pre { white-space: pre-wrap; word-break: break-word; }
.rc .kv { display: flex; gap: 10px; padding: 3px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.rc .kv .k { color: var(--a); min-width: 150px; flex-shrink: 0; }
.rc .kv .v { color: var(--text); word-break: break-word; }
.rc a { color: var(--a); }
.rfoot { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-btn {
  background: var(--panel); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 8px; padding: 6px 12px; font-size: 12px; transition: all .12s;
}
.mini-btn:hover:not(:disabled) { color: var(--text); background: var(--panel-2); }
.mini-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ═══ COMMAND PALETTE ═══ */
#palette {
  position: fixed; inset: 0; z-index: 70; display: flex; justify-content: center;
  background: rgba(0,0,0,.6); padding: 12vh 18px 0;
  opacity: 0; visibility: hidden; transition: opacity .15s, visibility .15s;
}
#palette.open { opacity: 1; visibility: visible; }
.pal-box {
  width: 100%; max-width: 560px; height: fit-content;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.pal-input-row {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); color: var(--text-faint);
}
.pal-input-row input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 15px; }
.pal-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.pal-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 9px; cursor: pointer; font-size: 13.5px;
}
.pal-item:hover, .pal-item.sel { background: var(--a-dim); color: var(--a); }
.pal-item .pi-cat { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--text-faint); }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 10px 20px; font-size: 13px; font-weight: 500;
  opacity: 0; transition: all .3s; z-index: 90; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: #7f1d1d; color: #fca5a5; }

/* boards / batch / ioc panels injected by app.js reuse .rm styles */
.section-title { font-size: 14px; font-weight: 700; margin: 4px 0 8px; }
.board-item, .hist-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 6px; font-size: 13px; cursor: pointer;
}
.board-item:hover, .hist-item:hover { border-color: var(--a); }
textarea.big-input {
  width: 100%; min-height: 110px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 12px; font-size: 13px;
  font-family: var(--mono); outline: none; resize: vertical;
}

/* ═══ MOBILE ═══ */
@media (max-width: 860px) {
  #sb {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform .25s;
  }
  #sb.open { transform: none; }
  #sbOverlay.show {
    display: block; position: fixed; inset: 0; z-index: 49; background: rgba(0,0,0,.5);
  }
  #menuBtn { display: block; }
  .topbar { padding: 10px 14px; }
  .topbar-actions .chip:not(.kbd-chip) { display: none; }
  .topbar-actions .clock-chip, .topbar-actions .session-chip { display: none; }
  .dash, .tools-wrap { padding-left: 14px; padding-right: 14px; }
}
