:root {
  color-scheme: dark;
  --bg: #111113;
  --panel: #1d1b1f;
  --panel-2: #252228;
  --text: #f4efe8;
  --muted: #aaa39a;
  --line: #3a353c;
  --accent: #4fb286;
  --accent-2: #f06d49;
  --blue: #6bb8e8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.shell {
  width: 100%;
  min-height: 100vh;
  padding: 20px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(360px, 1fr) minmax(300px, 380px);
  gap: 16px;
  min-height: calc(100vh - 40px);
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: conic-gradient(from 30deg, var(--accent), var(--blue), var(--accent-2), var(--accent));
  flex: 0 0 auto;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.check-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 13px;
}

.check-row input {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--accent);
}

input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #141216;
  color: var(--text);
  padding: 0 12px;
  font-size: 15px;
}

textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #141216;
  color: var(--text);
  padding: 12px;
  font-size: 14px;
  line-height: 1.65;
}

button,
.download {
  height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #07110c;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  opacity: 0.62;
  cursor: wait;
}

h2 {
  margin: 4px 0 2px;
  font-size: 15px;
  line-height: 1.3;
}

.mode-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.mode-nav a {
  display: grid;
  place-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--panel-2);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  padding: 0 8px;
}

.mode-nav a.active {
  background: var(--blue);
  color: #071019;
  border-color: transparent;
}

.summary {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  font-size: 13px;
  line-height: 1.7;
}

.video-form {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.rules-box {
  display: grid;
  gap: 7px;
  border: 1px solid #3e3842;
  border-radius: 8px;
  background: #17151a;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.rules-box strong {
  color: var(--text);
  font-size: 13px;
}

.download {
  display: grid;
  place-items: center;
  margin-top: 12px;
  text-decoration: none;
}

.chart-area {
  display: grid;
  place-items: center;
  min-height: 640px;
  border: 1px solid var(--line);
  background: #151318;
  border-radius: 8px;
  overflow: hidden;
}

#chart {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

#chart svg {
  width: min(100%, 760px);
  height: min(calc(100vh - 58px), 960px);
  display: block;
}

.chart-placeholder {
  color: #4d4651;
  font-size: 64px;
  font-weight: 800;
}

.video-result {
  width: min(100%, 520px);
  display: grid;
  gap: 14px;
  padding: 16px;
}

.video-result video {
  width: 100%;
  max-height: calc(100vh - 120px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #000;
}

.video-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.video-links a {
  display: grid;
  place-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--panel-2);
  text-decoration: none;
  font-size: 12px;
  text-align: center;
}

.contact-sheet {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab.active {
  background: var(--blue);
  color: #071019;
}

.details {
  font-size: 13px;
  line-height: 1.55;
}

.form-group-title {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.kv,
.planet-row,
.channel-row {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.kv strong,
.planet-row strong,
.channel-row strong {
  color: var(--text);
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none;
}

.knowledge-shell {
  padding: 20px;
}

.knowledge-layout {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(520px, 1fr) minmax(280px, 340px);
  gap: 16px;
  min-height: calc(100vh - 40px);
}

.knowledge-sidebar,
.knowledge-detail {
  align-self: stretch;
}

.knowledge-main {
  min-height: calc(100vh - 40px);
  border: 1px solid var(--line);
  background: #151318;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.graph-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(29, 27, 31, 0.9);
}

.ghost-link {
  min-height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: var(--panel-2);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.graph-canvas {
  min-height: 620px;
  position: relative;
}

.knowledge-svg {
  width: 100%;
  height: 100%;
  min-height: 620px;
  display: block;
}

.graph-edge {
  stroke: #403a43;
  stroke-width: 1;
  opacity: 0.52;
}

.edge-forms_channel,
.edge-connects_channel {
  opacity: 0.34;
}

.graph-node {
  cursor: pointer;
}

.graph-node circle {
  stroke: #141216;
  stroke-width: 2;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.graph-node:hover circle {
  filter: brightness(1.18);
  transform: scale(1.08);
}

.graph-node text {
  fill: var(--text);
  font-size: 10px;
  pointer-events: none;
}

.node-gate text,
.node-channel text {
  fill: var(--muted);
  font-size: 9px;
}

.graph-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.filter-chip {
  width: auto;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.filter-chip.active {
  background: var(--accent);
  color: #07110c;
}

.ad-slot {
  display: grid;
  gap: 7px;
  margin-top: 18px;
  min-height: 140px;
  border: 1px dashed #5b535f;
  border-radius: 8px;
  background: #17151a;
  padding: 16px;
  align-content: center;
}

.ad-slot.compact {
  min-height: 92px;
}

.ad-slot span {
  color: var(--muted);
  font-size: 12px;
}

.ad-slot strong {
  color: var(--text);
  font-size: 15px;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 320px 1fr;
  }

  .details-panel {
    grid-column: 1 / -1;
  }

  .knowledge-layout {
    grid-template-columns: 320px 1fr;
  }

  .knowledge-detail {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .knowledge-layout {
    grid-template-columns: 1fr;
  }

  .chart-area {
    min-height: 520px;
  }

  #chart svg {
    height: auto;
  }

  .graph-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .graph-canvas,
  .knowledge-svg {
    min-height: 520px;
  }
}
