:root {
  color-scheme: dark;

  --bg: #07090f;
  --bg2: #0b0e17;
  --panel: rgba(21, 26, 42, 0.66);
  --panel-solid: #141927;
  --panel2: rgba(28, 34, 56, 0.85);
  --panel3: #1c2440;
  --border: rgba(148, 163, 210, 0.13);
  --border-strong: rgba(148, 163, 210, 0.28);

  --text: #e9edf7;
  --muted: #8b93ad;
  --faint: #5b6278;

  --accent: #8b5cf6;
  --accent2: #6d4ae8;
  --cyan: #22d3ee;
  --gold: #f5b83d;
  --green: #34d399;
  --red: #f87171;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 34px -14px rgba(0, 0, 0, 0.75);
  --glow-accent: 0 0 0 1px rgba(139, 92, 246, 0.35), 0 8px 30px -8px rgba(139, 92, 246, 0.45);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  background-image:
    radial-gradient(1100px 560px at 82% -12%, rgba(124, 92, 240, 0.16), transparent 62%),
    radial-gradient(820px 480px at -8% 112%, rgba(34, 211, 238, 0.08), transparent 60%),
    radial-gradient(520px 320px at 55% 115%, rgba(245, 184, 61, 0.05), transparent 65%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 650; margin: 0; }
h3 {
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--cyan);
}

/* ---------- scrollbars ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 210, 0.25) transparent;
}
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 210, 0.2);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 210, 0.38); background-clip: content-box; }

/* ---------- topbar ---------- */
#topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 10, 17, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: relative;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent2), var(--accent) 60%, var(--cyan));
  box-shadow: 0 6px 20px -6px rgba(139, 92, 246, 0.7);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 800; letter-spacing: 0.2em; font-size: 14.5px; white-space: nowrap; }
.brand-sub { font-size: 10.5px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; }

.top-status { display: flex; gap: 8px; align-items: center; min-width: 0; }

/* pills */
.pill {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--muted);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}
button.pill { cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease, transform 0.05s ease; }
button.pill:hover { border-color: var(--border-strong); color: var(--text); }
button.pill:active { transform: translateY(1px); }

.pill.badge-ok { color: var(--green); border-color: rgba(52, 211, 153, 0.35); }
.pill.badge-error { color: var(--red); border-color: rgba(248, 113, 113, 0.35); }
.pill.badge-paused { color: var(--gold); border-color: rgba(245, 184, 61, 0.35); }

.pill-status::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 7px;
  vertical-align: 1px;
  background: var(--faint);
}
.pill-status.badge-idle { color: var(--muted); }
.pill-status.badge-idle::before { background: var(--faint); }
.pill-status.badge-running { color: var(--green); border-color: rgba(52, 211, 153, 0.35); }
.pill-status.badge-running::before { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, 0.8); animation: pulse 1.1s infinite; }
.pill-status.badge-paused { color: var(--gold); border-color: rgba(245, 184, 61, 0.35); }
.pill-status.badge-paused::before { background: var(--gold); box-shadow: 0 0 8px rgba(245, 184, 61, 0.8); }
.pill-status.badge-error { color: var(--red); border-color: rgba(248, 113, 113, 0.35); }
.pill-status.badge-error::before { background: var(--red); }

/* ---------- layout ---------- */
#layout {
  display: grid;
  grid-template-columns: 344px 1fr;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* ---------- sidebar ---------- */
#sidebar {
  border-right: 1px solid var(--border);
  min-height: 0;
  overflow: hidden;
  background: rgba(9, 12, 20, 0.6);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(6px);
}

#tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(11, 14, 23, 0.8);
  backdrop-filter: blur(10px);
  z-index: 10;
}
.tab {
  position: relative;
  padding: 9px 2px 7px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: color 0.15s ease, background 0.15s ease;
}
.tab::after {
  content: "";
  position: absolute;
  bottom: 0; left: 24%; right: 24%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent2), var(--cyan));
  opacity: 0;
  transition: opacity 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { opacity: 1; }
.tab-ico { font-size: 15px; line-height: 1; filter: saturate(0.6); transition: filter 0.2s ease; }
.tab.active .tab-ico { filter: saturate(1.1); }
.tab-label { text-transform: uppercase; letter-spacing: 0.08em; font-size: 10px; font-weight: 700; }
.tab-count {
  position: absolute;
  top: 5px; right: 9px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--panel3);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 9.5px;
  font-family: var(--mono);
  display: flex; align-items: center; justify-content: center;
}
.tab-count:empty { display: none; }

.tab-panel { display: none; padding: 16px 15px 20px; }
.tab-panel.active { display: block; overflow-y: auto; min-height: 0; flex: 1; }

.panel-head { margin-bottom: 14px; }
.panel-head h3 { color: var(--text); font-size: 13px; letter-spacing: 0.06em; display: flex; align-items: center; gap: 8px; }
.panel-head .hint { margin: 5px 0 0; }
.panel-head.rel-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.panel-head.rel-heading .hint { margin-top: 5px; }

.panel-block { margin-bottom: 22px; }
.panel-block > h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

.hint { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 4px 0 10px; }
.hint.empty { text-align: center; padding: 14px 0; opacity: 0.7; }

.badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--muted);
}
.badge-ai { color: var(--accent); border-color: rgba(167, 139, 250, 0.4); }

.notice {
  font-size: 12px;
  line-height: 1.55;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  margin: 4px 0 12px;
  border: 1px solid var(--border);
}
.notice-warn {
  color: var(--gold);
  border-color: rgba(245, 184, 61, 0.4);
  background: linear-gradient(180deg, rgba(245, 184, 61, 0.09), rgba(245, 184, 61, 0.03));
}

/* relations tab: fixed internal scroll */
#tab-relations.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#tab-relations .panel-head { flex-shrink: 0; margin-bottom: 4px; }
#tab-relations .hint { flex-shrink: 0; }
#tab-relations .notice { flex-shrink: 0; }
.rel-scroll { flex: 0 0 auto; overflow: visible; }
.mem-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin-top: 18px; margin-bottom: 0; }
.mem-panel h3 { flex-shrink: 0; }
.mem-scroll { flex: 1; min-height: 0; overflow: hidden; padding-right: 4px; margin-bottom: 0; }
.memory-group { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.memory-group h4 { flex-shrink: 0; }
.memory-card-list { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; }

/* ---------- cards ---------- */
.card-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* character card */
.character-card { position: relative; overflow: hidden; }
.character-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--mcolor, var(--accent));
  opacity: 0.55;
}
.character-card.editing { border-color: var(--accent); }

.char-head { display: flex; align-items: center; gap: 11px; padding: 12px; cursor: pointer; }
.char-avatar {
  width: 42px; height: 42px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.6);
}
.char-main { flex: 1; min-width: 0; }
.char-name { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-dir {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.char-dir strong { color: var(--gold); font-weight: 600; }

.char-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.char-actions button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s ease, background 0.15s ease, transform 0.05s ease;
}
.char-actions button:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.char-actions button:active { transform: translateY(1px); }
.char-actions button.del:hover { color: var(--red); background: rgba(248, 113, 113, 0.1); }
.char-actions .caret { font-size: 11px; transition: transform 0.2s ease; }
.character-card.open .char-actions .caret { transform: rotate(90deg); }

.char-details {
  padding: 0 12px 12px;
  border-top: 1px dashed var(--border);
  margin-top: 0;
  display: none;
}
.character-card.open .char-details { display: block; padding-top: 10px; margin-top: 2px; }
.kv { margin-bottom: 9px; }
.kv:last-child { margin-bottom: 0; }
.kv-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--faint); font-weight: 700; margin-bottom: 3px; }
.kv-label.directive { color: var(--gold); }
.kv-val { font-size: 12px; line-height: 1.55; color: var(--muted); white-space: pre-wrap; word-wrap: break-word; }
.kv-val:empty::after { content: "—"; opacity: 0.4; }

/* endpoint card */
.endpoint-card { padding: 11px 12px; display: flex; flex-direction: column; gap: 8px; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.endpoint-card.selected { border-color: rgba(139, 92, 246, 0.55); box-shadow: var(--glow-accent); }

.endpoint-top { display: flex; align-items: center; gap: 9px; }
.endpoint-status { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); font-family: var(--mono); flex: 1; min-width: 0; }
.endpoint-status .st-error { color: var(--red); }
.endpoint-status .st-live { color: var(--green); }
.endpoint-status .st-checking { color: var(--gold); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.live { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, 0.7); animation: pulse 1.2s infinite; }
.dot.offline { background: var(--red); box-shadow: 0 0 8px rgba(248, 113, 113, 0.6); }
.dot.checking { background: var(--gold); animation: pulse 0.8s infinite; }
.dot.unknown { background: var(--muted); }

.endpoint-actions { display: flex; gap: 5px; flex-shrink: 0; }
.endpoint-actions button {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 11.5px;
  padding: 4px 9px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
.endpoint-actions button:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.endpoint-actions button.select:hover { color: var(--green); border-color: rgba(52, 211, 153, 0.4); }
.endpoint-actions button.del:hover { color: var(--red); border-color: rgba(248, 113, 113, 0.4); }
.endpoint-actions button:disabled { opacity: 0.5; cursor: not-allowed; }

.ep-input {
  background: var(--bg2);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  padding: 4px 8px;
  font: inherit;
  font-size: 13px;
  width: 100%;
  min-width: 0;
  transition: border-color 0.15s ease;
}
.ep-name-row { display: flex; align-items: center; gap: 8px; }
.ep-name-row .ep-name { flex: 1; }
.ep-input:hover { border-color: var(--border); }
.ep-input:focus { outline: none; border-color: var(--accent); }
.ep-name { font-weight: 700; }
.ep-url { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.ep-url:focus { color: var(--text); }

.saved-flash { color: var(--green); font-size: 11px; font-family: var(--mono); opacity: 0; transition: opacity 0.2s ease; white-space: nowrap; }
.saved-flash.show { opacity: 1; }
.endpoint-meta { font-size: 11px; color: var(--faint); }

/* relationship card */
.rel-card { padding: 12px; }
.rel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.rel-names { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-label {
  color: var(--muted);
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--panel2);
}
.rel-bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.rel-fill { height: 100%; border-radius: 999px; transition: width 0.5s ease, background 0.5s ease; }
.rel-score { font-family: var(--mono); font-size: 11px; margin-top: 4px; text-align: right; color: var(--muted); }

.rel-moods { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.rel-mood { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; line-height: 1.5; }
.rel-mood .mood-dir { color: var(--text); font-weight: 600; white-space: nowrap; }
.rel-mood .mood-val { color: var(--accent); font-style: italic; }

.rel-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.mini-bar .mini-head { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; }
.mini-bar .mini-head .mini-val { font-family: var(--mono); letter-spacing: 0; text-transform: none; }
.mini-bar .bar { height: 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.mini-bar .bar .fill { height: 100%; border-radius: 999px; transition: width 0.5s ease, background 0.5s ease; }

.rel-power { margin-top: 12px; }
.power-head { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; }
.power-head .mini-val { font-family: var(--mono); letter-spacing: 0; text-transform: none; color: var(--text); }
.power-track { position: relative; height: 12px; }
.power-track .track-line { position: absolute; top: 5px; left: 0; right: 0; height: 2px; background: linear-gradient(to right, var(--red), var(--muted) 50%, var(--green)); border-radius: 2px; }
.power-track .center { position: absolute; top: 1px; left: 50%; width: 1px; height: 10px; background: var(--muted); }
.power-track .marker {
  position: absolute; top: 2px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--panel-solid);
  transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
  transition: left 0.5s ease;
}

/* memories */
.memory-group h4 { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; font-size: 12.5px; color: var(--text); }
.memory-group:first-of-type h4 { margin-top: 0; }
.memory-group h4 .mem-avatar {
  width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.6);
}
.memory-group h4 .mem-count { color: var(--faint); font-weight: 400; font-size: 10.5px; font-family: var(--mono); }
.memory-card-list { display: flex; flex-direction: column; gap: 7px; padding-right: 4px; }

.memory-card { display: flex; flex-direction: column; gap: 3px; padding: 9px 11px; }
.memory-card .mem-text { font-size: 12px; line-height: 1.55; color: var(--text); }
.memory-card .mem-time { font-size: 10px; color: var(--faint); font-family: var(--mono); }

/* ---------- forms ---------- */
.add-card { margin-top: 2px; margin-bottom: 14px; }
.add-card summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
  padding: 8px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s ease;
}
.add-card summary:hover { color: var(--text); }
.add-card summary::-webkit-details-marker { display: none; }
.add-card[open] summary { color: var(--text); }

.form-row { display: flex; gap: 6px; }
.form-row input[type="text"] { flex: 1; }

.f-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  font-weight: 700;
  margin: 10px 0 4px;
}

input[type="text"], input[type="number"], input[type="url"], textarea, select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:focus, input[type="number"]:focus, input[type="url"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="color"] {
  width: 40px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg2);
  padding: 2px;
  cursor: pointer;
}
textarea { resize: vertical; line-height: 1.55; }
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%238b93ad' d='M5 6 0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 26px;
  cursor: pointer;
}
.form-actions { display: flex; gap: 8px; margin-top: 12px; }

.field { margin: 12px 0; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--text);
  line-height: 1.45;
  cursor: pointer;
  margin: 8px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--panel);
  transition: border-color 0.15s ease;
}
.check:hover { border-color: var(--border-strong); }
.check input { margin-top: 3px; accent-color: var(--accent2); width: 15px; height: 15px; flex-shrink: 0; }
.check strong { display: block; font-size: 12.5px; }
.check small { color: var(--muted); font-size: 11px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { filter: brightness(1.14); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-accent {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  border: none;
  color: #fff;
  box-shadow: 0 8px 22px -8px rgba(124, 92, 240, 0.7);
}
.btn-god {
  background: linear-gradient(135deg, #d99a1f, var(--gold));
  border: none;
  color: #201503;
  font-weight: 800;
  box-shadow: 0 8px 22px -8px rgba(245, 184, 61, 0.6);
}
.btn-danger { color: var(--red); border-color: rgba(248, 113, 113, 0.3); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.1); }
.btn-ghost { background: none; }
.btn-block { width: 100%; margin-top: 10px; }
.btn-xs { padding: 4px 9px; font-size: 11px; font-weight: 700; }

/* ---------- summon ---------- */
.gen-row { display: flex; gap: 8px; }
.gen-row input[type="text"] { flex: 1; }
.gen-row select { width: 64px; flex-shrink: 0; }
.gen-actions { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.gen-actions .hint { margin: 0; flex: 1; font-size: 12px; }
.gen-status { color: var(--green) !important; }

/* ---------- stage ---------- */
#stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

#activityBar { flex-shrink: 0; }
.activity {
  padding: 7px 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
}
.activity[hidden] { display: none; }
.activity .act-dot {
  width: 7px; height: 7px; border-radius: 50%;
  animation: pulse 1s infinite;
  flex-shrink: 0;
}
.activity.speaking { color: var(--text); }
.activity.speaking .act-dot { background: var(--accent); box-shadow: 0 0 8px rgba(139, 92, 246, 0.8); }
.activity.speaking .act-avatar {
  width: 22px; height: 22px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
}
.activity.speaking .act-name { color: var(--accent); font-weight: 700; }
.activity.speaking .act-ellipsis::after { content: "…"; animation: blink 1s infinite; }
.activity.dev { color: var(--gold); background: linear-gradient(180deg, rgba(245, 184, 61, 0.07), transparent); }
.activity.dev .act-dot { background: var(--gold); }
.activity.god { color: var(--gold); background: linear-gradient(180deg, rgba(245, 184, 61, 0.13), rgba(245, 184, 61, 0.03)); font-style: italic; }
.activity.god .act-dot { background: var(--gold); box-shadow: 0 0 10px rgba(245, 184, 61, 0.9); animation: pulse 0.8s infinite; }

@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- transcript ---------- */
#transcript {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 22px 26px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.transcript-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 500px;
  animation: fadein 0.4s ease;
}
.transcript-empty .empty-glyph {
  width: 72px; height: 72px;
  margin: 0 auto 16px;
  font-size: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--accent2), var(--accent) 55%, var(--cyan));
  box-shadow: 0 0 60px -6px rgba(139, 92, 246, 0.7);
}
.transcript-empty h2 { color: var(--text); margin: 0 0 10px; font-size: 22px; letter-spacing: 0.04em; }
.transcript-empty p { line-height: 1.75; font-size: 13.5px; }

.empty-steps { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
.empty-step {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
}
.empty-step:hover { border-color: var(--border-strong); background: var(--panel2); }
.empty-step:active { transform: translateY(1px); }
.empty-step .step-num {
  width: 26px; height: 26px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.empty-step .step-text { flex: 1; font-weight: 600; }
.empty-step .step-arrow { color: var(--muted); font-size: 13px; }

/* messages */
.msg {
  display: flex;
  gap: 12px;
  max-width: 88%;
  animation: fadein 0.3s ease;
}
.msg.god-msg { align-self: center; max-width: 80%; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.msg-avatar {
  width: 40px; height: 40px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.65);
  position: relative;
  top: 2px;
}
.msg-body {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
  padding: 10px 14px;
  min-width: 0;
  border-left: 2px solid var(--mcolor, var(--accent));
  box-shadow: var(--shadow);
}
.msg-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 4px; }
.msg-name { font-weight: 700; font-size: 13px; }
.msg-time { font-size: 10.5px; color: var(--faint); font-family: var(--mono); }
.msg-text { font-size: 14px; line-height: 1.62; white-space: pre-wrap; word-wrap: break-word; }
.msg-text.live::after {
  content: "▍";
  animation: blink 0.8s infinite;
  color: var(--accent);
  margin-left: 1px;
}

.god-msg .msg-body {
  background: linear-gradient(180deg, rgba(245, 184, 61, 0.12), rgba(245, 184, 61, 0.04));
  border-color: rgba(245, 184, 61, 0.5);
  border-left-color: var(--gold);
  border-radius: 14px;
  box-shadow: 0 0 30px -12px rgba(245, 184, 61, 0.65);
  text-align: center;
}
.god-msg .msg-head { justify-content: center; }
.god-msg .msg-name { color: var(--gold); letter-spacing: 0.16em; }
.god-msg .msg-text { font-style: italic; color: #f3e5c4; }
.god-msg .msg-avatar {
  background: linear-gradient(135deg, #d99a1f, var(--gold)) !important;
  box-shadow: 0 0 22px -2px rgba(245, 184, 61, 0.8);
}
.msg-effect {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed rgba(245, 184, 61, 0.35);
  font-size: 12px;
  line-height: 1.55;
  color: var(--gold);
  font-style: italic;
}
.msg-rel {
  margin-top: 6px;
  font-size: 11px;
  color: var(--accent);
  font-family: var(--mono);
}

/* ---------- god console ---------- */
#godConsole {
  border-top: 1px solid var(--border);
  background: rgba(8, 10, 17, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 11px 18px 13px;
  flex-shrink: 0;
}
.console-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; flex-wrap: wrap; }
.console-label { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: 0.14em; font-size: 11.5px; text-transform: uppercase; }
.console-icon { color: var(--gold); font-size: 13px; }
.console-hint { font-weight: 400; letter-spacing: 0.02em; text-transform: none; color: var(--faint); font-size: 11px; }

.console-lock {
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 5px 11px;
}
.console-lock[hidden] { display: none; }

.console-input-wrap { display: flex; gap: 9px; align-items: stretch; }
#interfereInput {
  flex: 1;
  background: var(--bg2);
  resize: none;
  max-height: 120px;
  font-size: 13.5px;
  line-height: 1.55;
  padding: 10px 12px;
}
#interfereInput:disabled { opacity: 0.5; }
.console-input-wrap .btn-god { min-width: 108px; white-space: nowrap; }

.console-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.console-actions .spacer { flex: 1; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel3);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 13px;
  box-shadow: 0 18px 50px -14px rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 72vw;
  z-index: 60;
  font-weight: 500;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-8px); }
#toast.error { border-left-color: var(--red); }

/* ---------- modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 12, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadein 0.2s ease;
}
.modal-overlay[hidden] { display: none; }

.modal {
  width: min(460px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9);
  text-align: center;
}
.modal-icon {
  width: 54px; height: 54px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  background: linear-gradient(135deg, var(--accent2), var(--accent) 60%, var(--cyan));
  box-shadow: 0 0 50px -6px rgba(139, 92, 246, 0.7);
}
.modal h2 { font-size: 19px; letter-spacing: 0.04em; margin: 0; }
.modal-sub { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 8px 0 18px; }

.modal-steps {
  list-style: none;
  counter-reset: step;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-align: left;
}
.modal-steps li {
  counter-increment: step;
  position: relative;
  padding-left: 34px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.modal-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  width: 24px; height: 24px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.modal-steps b { color: var(--text); }

.modal-actions { display: flex; gap: 9px; justify-content: center; }
.modal-actions .btn { flex: 1; }

.template-preview {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 18px;
}
.template-cast { display: flex; gap: 8px; margin-bottom: 10px; }
.tpl-char {
  font-size: 12px;
  font-weight: 700;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}
.template-scene {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
  font-style: italic;
  border-left: 2px solid var(--gold);
  padding-left: 10px;
}

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  #layout { grid-template-columns: 1fr; grid-template-rows: 40% 1fr; height: calc(100vh - 60px); }
  #sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .tab-count { display: none; }
  .pill { max-width: 180px; }
}
