/* ═══════════════════════════════════════════════════════════════
   TEIA — CSS  |  Dark Cinematic · Space Mono + Syne
═══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #04040c;
  --bg2:       #07071a;
  --bg3:       #0d0d24;
  --surface:   rgba(10, 10, 28, 0.95);
  --surface2:  rgba(15, 15, 36, 0.98);
  --border:    rgba(255,255,255,0.10);
  --border2:   rgba(255,255,255,0.18);
  --red:       #e04030;
  --red-glow:  #ff4444;
  --red-dim:   rgba(224,64,48,0.18);
  --gold:      #E8C030;
  --gold-dim:  rgba(232,192,48,0.14);
  --text:      #f0f4fa;
  --text2:     #a8b4c8;
  --text3:     #6a7a99;
  --font:      'Inter', sans-serif;
  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --trans:     all 0.18s cubic-bezier(0.4,0,0.2,1);
}

html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }

/* ─── Screens ─────────────────────────────────────────────── */
.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }

/* ─── HOME ────────────────────────────────────────────────── */
#screen-home { overflow-y: auto; overflow-x: hidden; }

.home-bg {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
}
#bg-canvas { width: 100%; height: 100%; }
.home-grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(192,57,43,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(192,57,43,0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 80%);
}

.home-content {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

.home-header {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(4,4,12,0.7);
  backdrop-filter: blur(20px);
  position: sticky; top: 0; z-index: 10;
}

.logo-mark {
  font-size: 28px; color: var(--red);
  animation: pulse-logo 3s ease-in-out infinite;
  line-height: 1;
}
@keyframes pulse-logo {
  0%, 100% { opacity: 1; text-shadow: 0 0 20px var(--red); }
  50% { opacity: 0.7; text-shadow: 0 0 40px var(--red-glow); }
}

.logo-text { display: flex; flex-direction: column; gap: 2px; }
.logo-teia { font-family: var(--font); font-size: 18px; font-weight: 800; letter-spacing: 3px; color: #fff; }
.logo-sub  { font-family: var(--font); font-size: 10px; font-weight: 500; letter-spacing: 2px; color: var(--text2); }

.header-actions { margin-left: auto; display: flex; gap: 8px; }

.home-main {
  flex: 1; padding: 48px 32px 64px;
  max-width: 1300px; margin: 0 auto; width: 100%;
}

.home-intro { margin-bottom: 56px; }
.home-title {
  font-family: var(--sans); font-size: clamp(36px, 5vw, 64px);
  font-weight: 800; line-height: 1.1; letter-spacing: -1px;
  color: #fff; margin-bottom: 16px;
}
.home-title em { color: var(--red); font-style: normal; }
.home-desc { font-size: 16px; color: var(--text2); max-width: 480px; line-height: 1.7; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.section-label {
  font-family: var(--font); font-size: 11px; font-weight: 600; letter-spacing: 1px; color: var(--text2);
}

.search-wrap { position: relative; }
.search-input {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font); font-size: 13px; font-weight: 500;
  padding: 8px 14px; border-radius: var(--radius-sm);
  width: 200px; outline: none; transition: var(--trans);
}
.search-input:focus { border-color: var(--red); width: 260px; }
.search-input::placeholder { color: var(--text3); }

.teias-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.loading-pulse {
  grid-column: 1/-1;
  display: flex; gap: 8px; align-items: center; padding: 40px;
  justify-content: center;
}
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--red);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
.pulse-dot:nth-child(2) { animation-delay: 0.2s; }
.pulse-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse-dot {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Teia Card */
.teia-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 24px;
  cursor: pointer; transition: var(--trans);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
  animation: card-in 0.4s ease backwards;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.teia-card::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(192,57,43,0.08) 0%, transparent 60%);
  opacity: 0; transition: opacity 0.3s;
}
.teia-card:hover { border-color: rgba(192,57,43,0.3); transform: translateY(-2px); box-shadow: 0 12px 40px rgba(0,0,0,0.5); }
.teia-card:hover::before { opacity: 1; }

.card-accent { width: 36px; height: 3px; background: var(--red); border-radius: 2px; margin-bottom: 4px; }
.card-name { font-family: var(--font); font-size: 18px; font-weight: 700; color: #fff; line-height: 1.2; }
.card-desc { font-size: 13px; color: var(--text2); line-height: 1.5; flex: 1; }
.card-meta {
  display: flex; gap: 16px; align-items: center; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.card-stat { font-family: var(--font); font-size: 11px; font-weight: 500; color: var(--text2); }
.card-stat strong { color: var(--text); font-weight: 700; }
.card-arrow { margin-left: auto; color: var(--red); font-size: 16px; opacity: 0; transition: var(--trans); }
.teia-card:hover .card-arrow { opacity: 1; transform: translateX(4px); }
.card-delete {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 12px; padding: 4px 6px; border-radius: 4px; opacity: 0;
  transition: var(--trans); z-index: 2;
}
.teia-card:hover .card-delete { opacity: 1; }
.card-delete:hover { color: var(--red); background: var(--red-dim); }

.empty-state {
  grid-column: 1/-1;
  text-align: center; padding: 60px 20px;
  color: var(--text3); font-family: var(--font); font-size: 12px; font-weight: 500;
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 16px; opacity: 0.4; }

/* ─── GRAPH SCREEN ────────────────────────────────────────── */
#screen-graph { background: var(--bg); }

/* Toolbar */
#toolbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 50;
  height: 54px; background: rgba(4,4,12,0.97);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0;
  backdrop-filter: blur(16px);
}

.tb-left {
  display: flex; align-items: center; gap: 0;
  padding: 0 16px; flex-shrink: 0;
  border-right: 1px solid var(--border);
}
.tb-back {
  background: none; border: none; color: var(--text2);
  font-family: var(--font); font-size: 12px; font-weight: 600; letter-spacing: 0.5px;
  cursor: pointer; padding: 6px 10px; border-radius: var(--radius-sm);
  transition: var(--trans); white-space: nowrap;
}
.tb-back:hover { color: var(--red); background: var(--red-dim); }
.tb-divider { width: 1px; height: 24px; background: var(--border); margin: 0 12px; }
.tb-title-wrap { display: flex; flex-direction: column; gap: 2px; }
.tb-title { font-family: var(--font); font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.tb-counts { font-family: var(--font); font-size: 11px; font-weight: 500; color: var(--text2); letter-spacing: 0.2px; }

.tb-center {
  flex: 1; display: flex; align-items: center; gap: 0; padding: 0 12px;
}
.tb-group {
  display: flex; align-items: center; gap: 4px;
  padding: 0 10px; border-right: 1px solid var(--border);
}
.tb-group-label { font-family: var(--font); font-size: 10px; font-weight: 600; letter-spacing: 0.5px; color: var(--text2); margin-right: 4px; }

.tb-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text2); font-family: var(--font); font-size: 11px; font-weight: 600;
  letter-spacing: 0.3px; cursor: pointer; padding: 5px 10px;
  border-radius: var(--radius-sm); transition: var(--trans);
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.tb-btn .btn-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.5; }
.tb-btn:hover { border-color: var(--red); color: #ff7060; background: var(--red-dim); }
.tb-btn.on { border-color: rgba(224,64,48,0.6); color: #ff7060; background: var(--red-dim); }
.tb-btn.on .btn-dot { opacity: 1; }
.tb-btn.accent { border-color: rgba(212,172,13,0.3); color: #c4a020; }
.tb-btn.accent:hover, .tb-btn.accent.on { border-color: var(--gold); color: #f5c800; background: var(--gold-dim); }
.tb-btn.danger { border-color: rgba(142,68,173,0.25); color: #8060a0; }
.tb-btn.danger:hover { border-color: #8e44ad; color: #d0a7ff; background: rgba(142,68,173,0.1); }

.tb-search { padding: 0 10px; }
.tb-search-input {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font); font-size: 13px; font-weight: 500;
  padding: 5px 12px; border-radius: var(--radius-sm);
  width: 170px; outline: none; transition: var(--trans);
}
.tb-search-input:focus { border-color: var(--red); width: 230px; }
.tb-search-input::placeholder { color: var(--text3); }

.tb-right {
  display: flex; align-items: center; gap: 4px;
  padding: 0 14px; border-left: 1px solid var(--border);
  flex-shrink: 0;
}

/* Graph wrap */
#graph-wrap { position: absolute; inset: 0; top: 54px; }
#svg { width: 100%; height: 100%; }

/* Legend */
#legend {
  position: absolute; left: 14px; bottom: 40px; z-index: 20;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  min-width: 190px; max-height: calc(100vh - 160px);
  overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}
#legend::-webkit-scrollbar { width: 3px; }
#legend::-webkit-scrollbar-thumb { background: #1e1e2e; border-radius: 99px; }
.legend-title {
  font-family: var(--font); font-size: 11px; font-weight: 700; letter-spacing: 0.5px; color: var(--text2);
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.leg-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 6px; cursor: pointer; transition: var(--trans);
}
.leg-item:hover { background: rgba(255,255,255,0.04); }
.leg-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.leg-label { color: var(--text); font-family: var(--font); font-size: 12px; font-weight: 500; line-height: 1; flex: 1; }
.leg-count { color: var(--text2); font-family: var(--font); font-size: 11px; font-weight: 600; }
.leg-item.off .leg-dot { opacity: 0.2; filter: grayscale(1); }
.leg-item.off .leg-label { color: var(--text3); text-decoration: line-through; }

/* Node panel */
#node-panel {
  position: absolute; top: 10px; right: 14px; z-index: 20;
  width: 360px; background: var(--surface2); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: 0 0 50px rgba(0,0,0,0.8);
  display: none; border: 1px solid var(--border);
  animation: panel-in 0.2s ease;
}
@keyframes panel-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
#node-panel.show { display: block; }

#np-head { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); position: relative; }
#np-type-badge { font-family: var(--font); font-size: 11px; font-weight: 700; letter-spacing: 1.5px; margin-bottom: 6px; }
#np-name { font-family: var(--font); font-size: 20px; font-weight: 800; color: #fff; line-height: 1.2; }
#np-sub { font-family: var(--font); font-size: 13px; color: var(--text2); margin-top: 6px; line-height: 1.5; }
.np-actions { display: flex; gap: 6px; margin-top: 12px; }
.np-btn {
  background: none; border: 1px solid var(--border); color: var(--text2);
  font-family: var(--font); font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
  cursor: pointer; padding: 6px 12px; border-radius: var(--radius-sm); transition: var(--trans);
}
.np-btn:hover { border-color: var(--red); color: #ff6b5a; background: var(--red-dim); }
.np-btn.danger:hover { border-color: #e74c3c; color: #ff8080; background: rgba(231,76,60,0.1); }
.np-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-family: var(--font); font-size: 11px; font-weight: 500; padding: 4px 6px;
  border-radius: var(--radius-sm); transition: var(--trans);
}
.np-close:hover { color: var(--red); background: var(--red-dim); }

#np-body { padding: 12px 18px; max-height: 55vh; overflow-y: auto; }
#np-body::-webkit-scrollbar { width: 3px; }
#np-body::-webkit-scrollbar-thumb { background: #1e1e2e; }
.np-section-title { font-family: var(--font); font-size: 11px; font-weight: 700; letter-spacing: 0.5px; color: var(--text2); margin-bottom: 10px; }

.conn-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px; border-radius: 8px; cursor: pointer;
  transition: var(--trans); margin-bottom: 4px;
}
.conn-item:hover { background: rgba(255,255,255,0.04); }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.conn-label { color: #e2e8f0; font-size: 12px; font-weight: 600; }
.conn-rel { color: var(--text2); font-size: 11px; margin-top: 2px; line-height: 1.4; }
.conn-del {
  margin-left: auto; flex-shrink: 0; background: none; border: none;
  color: var(--text3); cursor: pointer; font-size: 11px; padding: 2px 5px;
  border-radius: 4px; opacity: 0; transition: var(--trans);
}
.conn-item:hover .conn-del { opacity: 1; }
.conn-del:hover { color: #ff8080; background: rgba(231,76,60,0.1); }

/* Stats bar */
#stats-bar {
  position: absolute; bottom: 10px; right: 14px; z-index: 15;
  background: var(--surface); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 8px;
  display: flex; gap: 16px; align-items: center;
  font-family: var(--font); font-size: 11px; font-weight: 500; color: var(--text2); letter-spacing: 0.2px;
}
.stats-hint { font-family: var(--font); font-size: 11px; color: var(--text3); }

/* Tooltip */
#tooltip {
  position: fixed; z-index: 100; pointer-events: none; display: none;
  background: var(--surface2); border: 1px solid var(--border2);
  padding: 12px 14px; border-radius: var(--radius); max-width: 300px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
}
.tt-name { color: #fff; font-family: var(--font); font-size: 14px; font-weight: 700; }
.tt-sub { color: var(--text2); font-family: var(--font); font-size: 12px; line-height: 1.5; margin-top: 5px; }
.tt-meta { font-family: var(--font); font-size: 11px; font-weight: 500; color: var(--text2); margin-top: 8px; }

/* ─── MODALS ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
  animation: overlay-in 0.15s ease;
}
@keyframes overlay-in {
  from { opacity: 0; } to { opacity: 1; }
}
.modal-overlay.show { display: flex; }

.modal {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); width: min(500px, 92vw);
  box-shadow: 0 24px 80px rgba(0,0,0,0.8);
  animation: modal-in 0.2s cubic-bezier(0.34,1.56,0.64,1);
  overflow: hidden;
}
.modal-wide { width: min(700px, 92vw); }
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 22px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-family: var(--font); font-size: 12px; font-weight: 700; letter-spacing: 1.5px; color: var(--red); }
.modal-close {
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 14px; padding: 4px 8px; border-radius: var(--radius-sm);
  transition: var(--trans);
}
.modal-close:hover { color: var(--red); background: var(--red-dim); }

.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; }
.form-group.flex-1 { flex: 1; }
.form-group.flex-2 { flex: 2; }
.form-label { font-family: var(--font); font-size: 11px; font-weight: 600; letter-spacing: 0.5px; color: var(--text2); }
.form-input {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font); font-size: 13px; font-weight: 400;
  padding: 10px 13px; border-radius: var(--radius-sm);
  outline: none; transition: var(--trans); width: 100%;
}
.form-input:focus { border-color: var(--red); background: var(--red-dim); }
.form-input::placeholder { color: var(--text3); }
.form-textarea { resize: vertical; min-height: 80px; font-family: var(--font); font-size: 13px; }
.form-textarea-lg { min-height: 160px; }
.form-select { cursor: pointer; }
.form-range { width: 100%; accent-color: var(--red); }
.range-labels { display: flex; justify-content: space-between; font-family: var(--font); font-size: 11px; font-weight: 500; color: var(--text2); margin-top: 4px; }
.edge-arrow { color: var(--red); font-size: 18px; padding-bottom: 4px; flex-shrink: 0; }

/* Type templates */
.type-templates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-template {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; cursor: pointer; transition: var(--trans); position: relative;
}
.type-template:hover { border-color: rgba(192,57,43,0.4); }
.type-template.selected { border-color: var(--red); background: var(--red-dim); }
.type-template.selected::after {
  content: '✓'; position: absolute; top: 8px; right: 10px;
  color: var(--red); font-size: 12px;
}
.tt-icon { font-size: 20px; margin-bottom: 6px; }
.tt-name { font-family: var(--font); font-size: 13px; font-weight: 700; color: #fff; }
.tt-desc { font-family: var(--font); font-size: 11px; color: var(--text2); margin-top: 2px; }

/* Type chips */
.type-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.type-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 20px; cursor: pointer; transition: var(--trans);
  font-size: 11px; color: var(--text2);
}
.type-chip-dot { width: 8px; height: 8px; border-radius: 50%; }
.type-chip:hover { border-color: rgba(255,255,255,0.2); color: #fff; }
.type-chip.selected { border-color: #fff; color: #fff; background: rgba(255,255,255,0.08); }

/* Settings */
.settings-section { padding-top: 16px; border-top: 1px solid var(--border); }
.settings-section-title { font-family: var(--font); font-size: 11px; font-weight: 700; letter-spacing: 0.5px; color: var(--text2); margin-bottom: 12px; }
.node-type-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.node-type-row input { flex: 1; }
.node-type-row .color-input { width: 44px; height: 36px; padding: 2px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--border); background: none; }
.node-type-row .del-type { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 14px; padding: 4px 8px; border-radius: var(--radius-sm); transition: var(--trans); }
.node-type-row .del-type:hover { color: #ff8080; background: rgba(231,76,60,0.1); }

/* Import */
.import-or { text-align: center; font-family: var(--font); font-size: 12px; font-weight: 600; color: var(--text2); letter-spacing: 0.5px; }
.file-drop {
  border: 2px dashed var(--border2); border-radius: var(--radius);
  padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: var(--trans); color: var(--text2); font-size: 13px; text-align: center;
}
.file-drop:hover { border-color: var(--red); color: #fff; background: var(--red-dim); }
.file-drop-icon { font-size: 28px; }

/* Buttons */
.btn-primary {
  background: var(--red); border: 1px solid var(--red);
  color: #fff; font-family: var(--font); font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
  cursor: pointer; padding: 10px 20px; border-radius: var(--radius-sm);
  transition: var(--trans); white-space: nowrap;
}
.btn-primary:hover { background: #c83428; box-shadow: 0 0 24px rgba(224,64,48,0.45); }

.btn-ghost {
  background: none; border: 1px solid var(--border2); color: var(--text);
  font-family: var(--font); font-size: 12px; font-weight: 500; letter-spacing: 0.2px;
  cursor: pointer; padding: 10px 16px; border-radius: var(--radius-sm);
  transition: var(--trans); white-space: nowrap;
}
.btn-ghost:hover { border-color: rgba(255,255,255,0.35); color: #fff; background: rgba(255,255,255,0.07); }
.btn-ghost.danger:hover { border-color: #e74c3c; color: #ff8080; background: rgba(231,76,60,0.1); }
.btn-sm { padding: 5px 10px; font-size: 10px; }

/* Toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 999; background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text); font-family: var(--font); font-size: 13px; font-weight: 500;
  padding: 10px 18px; border-radius: 8px; display: none;
  animation: toast-in 0.2s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .home-main { padding: 28px 16px 40px; }
  .home-header { padding: 14px 16px; }
  .home-title { font-size: 32px; }
  .tb-center { display: none; }
  #toolbar { flex-wrap: wrap; height: auto; padding: 8px; }
  #legend { display: none; }
  #stats-bar { font-size: 9px; }
  .stats-hint { display: none; }
  #node-panel { width: calc(100vw - 28px); right: 14px; }
}

/* ─── NODE PHOTO ──────────────────────────────────────────────── */
.node-photo-wrap {
  display: flex; align-items: center; gap: 12px;
}
.node-photo-preview {
  width: 80px; height: 80px; border-radius: 50%;
  border: 2px dashed var(--border2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  background: rgba(255,255,255,0.04); flex-shrink: 0;
  transition: var(--trans);
}
.node-photo-preview:hover { border-color: var(--red); background: var(--red-dim); }
.node-photo-preview img {
  width: 100%; height: 100%; object-fit: cover;
  position: absolute; inset: 0; border-radius: 50%;
}
.node-photo-icon { font-size: 26px; pointer-events: none; }
.node-photo-overlay {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(0,0,0,0.55); display: flex;
  align-items: center; justify-content: center;
  font-family: var(--font); font-size: 11px; font-weight: 600;
  color: #fff; opacity: 0; transition: opacity 0.2s;
}
.node-photo-preview:hover .node-photo-overlay { opacity: 1; }
.node-photo-remove {
  background: none; border: 1px solid var(--border2); color: var(--text3);
  font-size: 13px; cursor: pointer; padding: 4px 8px; border-radius: 50%;
  transition: var(--trans); line-height: 1;
}
.node-photo-remove:hover { border-color: #e74c3c; color: #ff8080; background: rgba(231,76,60,0.1); }

/* Photo in node panel */
.np-photo {
  width: 76px; height: 76px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--border2);
  flex-shrink: 0; box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.np-head-top {
  display: flex; align-items: center; gap: 14px; margin-bottom: 10px;
}
.np-head-info { flex: 1; min-width: 0; }

/* ─── USER AUTH ───────────────────────────────────────────────── */
.user-info {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px; border-radius: 20px;
  border: 1px solid var(--border); margin-right: 4px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--red); color: #fff;
  font-size: 12px; font-weight: 800; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.user-name {
  font-size: 12px; font-weight: 600; color: var(--text2);
  white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis;
}
.user-role-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
  padding: 2px 6px; border-radius: 10px;
  background: rgba(224,64,48,0.15); color: var(--red); border: 1px solid rgba(224,64,48,0.3);
}
.user-role-badge.contributor {
  background: rgba(168,180,200,0.1); color: var(--text3); border-color: var(--border);
}

/* User list in modal */
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); margin-bottom: 6px;
  background: rgba(255,255,255,0.02);
}
.user-row-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--red); color: #fff;
  font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-row-info { flex: 1; min-width: 0; }
.user-row-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-row-meta { font-size: 11px; color: var(--text2); margin-top: 2px; }
.user-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.user-row-btn {
  background: none; border: 1px solid var(--border); color: var(--text2);
  font-family: var(--font); font-size: 10px; font-weight: 600;
  cursor: pointer; padding: 4px 8px; border-radius: 4px; transition: var(--trans);
}
.user-row-btn:hover { border-color: var(--red); color: #ff7060; background: var(--red-dim); }
.user-row-btn.del:hover { border-color: #e74c3c; color: #ff8080; background: rgba(231,76,60,0.1); }

/* ✨ AI REPORT STYLES ────────────────────────────────────────── */
.modal-report-body {
  line-height: 1.8; color: var(--text); font-size: 15px;
  max-width: 800px; margin: 0 auto;
}
.modal-report-body h1, .modal-report-body h2 { color: #fff; margin: 24px 0 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; font-family: var(--sans); }
.modal-report-body h3, .modal-report-body h4 { color: var(--red); margin: 18px 0 8px; font-family: var(--sans); }
.modal-report-body p { margin-bottom: 14px; color: var(--text2); }
.modal-report-body ul, .modal-report-body ol { margin-bottom: 16px; padding-left: 20px; }
.modal-report-body li { margin-bottom: 6px; color: var(--text2); }
.modal-report-body blockquote {
  border-left: 4px solid var(--red); background: var(--red-dim);
  padding: 12px 20px; border-radius: 4px; margin: 16px 0; font-style: italic;
}
.modal-report-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Loading State */
.ai-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; text-align: center; gap: 20px;
}
.ai-sparkle { font-size: 40px; animation: sparkle-float 2s ease-in-out infinite; }
@keyframes sparkle-float {
  0%, 100% { transform: translateY(0) scale(1.1); filter: drop-shadow(0 0 10px var(--red-glow)); }
  50% { transform: translateY(-10px) scale(1); filter: drop-shadow(0 0 20px var(--red-glow)); }
}
.loading-bar { width: 240px; height: 4px; background: var(--border); border-radius: 10px; overflow: hidden; }
.loading-progress {
  width: 40%; height: 100%; background: var(--red); border-radius: 10px;
  animation: loading-slide 1.5s infinite ease-in-out;
}
@keyframes loading-slide {
  from { transform: translateX(-100%); width: 20%; }
  to { transform: translateX(500%); width: 40%; }
}
