@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Serif+Display&display=swap");

:root {
  --bg: #0a0a0b;
  --panel: #121216;
  --panel-2: #191a20;
  --accent: #ff4b3e;
  --accent-2: #ff8a3d;
  --text: #f1f1f3;
  --muted: #9a9aa4;
  --danger: #ff5e6f;
  --line: rgba(255,255,255,0.08);
  --glow: 0 0 24px rgba(255,75,62,0.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 800px at 10% -10%, rgba(255,75,62,0.2), transparent),
              radial-gradient(900px 600px at 90% 10%, rgba(255,138,61,0.14), transparent),
              radial-gradient(700px 500px at 50% 120%, rgba(255,75,62,0.08), transparent),
              var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

a { color: var(--accent); text-decoration: none; }

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(10,10,12,0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-family: "DM Serif Display", serif;
  font-size: 24px;
  letter-spacing: 0.5px;
}

.container { padding: 28px; max-width: 1200px; margin: 0 auto; }

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  background: linear-gradient(180deg, rgba(18,18,22,0.95), rgba(12,12,14,0.95));
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.side-nav .brand {
  font-size: 22px;
}

.project-switcher {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--panel);
}

.project-switcher summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.project-switcher summary::-webkit-details-marker {
  display: none;
}

.project-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-item {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f0f12;
  color: var(--text);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0f0f12;
  color: var(--text);
}

.nav-link.active {
  border-color: rgba(255,75,62,0.55);
  box-shadow: var(--glow);
}

.side-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.app-main {
  padding: 28px 32px;
}

.dashboard {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

.dashboard .main { min-width: 0; }
.dashboard .sidebar { min-width: 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.builder-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.builder-card h4 { margin: 0 0 6px 0; }

.featured-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.02);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--glow);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
}

.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: rgba(255,75,62,0.6);
  box-shadow: var(--glow);
}

.button.primary {
  background: linear-gradient(135deg, var(--accent), #d93b2f);
  color: #140606;
  border: none;
}

.button.danger {
  background: #2a1214;
  color: #ffb8c0;
}

.input, .select, textarea {
  width: 100%;
  background: #0e0f14;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 10px;
  font-family: inherit;
}

label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; }

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  text-align: left;
  color: var(--text);
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,75,62,0.12);
  color: var(--accent);
  font-size: 12px;
}

.builder {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}

.builder.role-builder {
  grid-template-columns: 280px 1fr 340px;
  align-items: stretch;
  height: 100%;
}

.builder-container {
  max-width: none;
}

.palette, .canvas, .inspector {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.palette .block {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #0e0f14;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  position: relative;
}

.palette .block:hover::after {
  content: attr(data-desc);
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  background: #111217;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  z-index: 10;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  flex: 1;
  padding: 8px 10px;
  background: #0e0f14;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  color: var(--text);
  border-color: rgba(255,75,62,0.6);
  box-shadow: var(--glow);
}

.tab-panel.hidden { display: none; }

.canvas {
  position: relative;
  min-height: 72vh;
  overflow: hidden;
  background: radial-gradient(circle at 20px 20px, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  cursor: grab;
}

.canvas:active {
  cursor: grabbing;
}

.plane {
  position: relative;
  width: 2000px;
  height: 1200px;
  transform: translate(0px, 0px);
  z-index: 1;
}

.link-layer {
  position: absolute;
  inset: 0;
  width: 2000px;
  height: 1200px;
  pointer-events: none;
}

.link-line {
  stroke: rgba(255,75,62,0.7);
  stroke-width: 2;
}

.link-line.temp {
  stroke: rgba(255,138,61,0.8);
  stroke-dasharray: 6 6;
}

.plane-hint {
  position: absolute;
  bottom: 20px;
  right: 24px;
  color: var(--muted);
  font-size: 12px;
}

.settings-block {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 420px;
  max-width: 90%;
  background: rgba(18,18,22,0.92);
  border: 1px solid rgba(255,75,62,0.55);
  box-shadow: var(--glow);
  border-radius: 14px;
  padding: 16px;
  z-index: 2;
  resize: both;
  overflow: auto;
}

.settings-title {
  font-weight: 600;
  margin-bottom: 10px;
}

.event-node {
  position: absolute;
  min-width: 220px;
  background: rgba(255,255,255,0.03);
  border: 1px dashed rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: grab;
}

.event-node .connector {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 2px solid rgba(255,75,62,0.75);
  left: 50%;
  transform: translateX(-50%);
  box-shadow: var(--glow);
}

.event-node .connector.top { top: -8px; }
.event-node .connector.bottom { bottom: -8px; }

.event-node .connector:hover {
  border-color: var(--accent-2);
}

.event-node.selected {
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.action-list { margin-top: 8px; }

.canvas .action {
  padding: 6px 8px;
  margin: 6px 0;
  background: rgba(255,75,62,0.1);
  border: 1px solid rgba(255,75,62,0.3);
  border-radius: 8px;
}

.canvas .action.selected {
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.action-editor {
  margin-top: 8px;
  padding: 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.template-item {
  padding: 6px 8px;
  margin-top: 8px;
  background: #0f131a;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.muted { color: var(--muted); font-size: 13px; }

.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  align-items: center;
}

.hero h1 { font-family: "DM Serif Display", serif; font-size: 44px; margin: 0 0 12px 0; }

.notice {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,75,62,0.35);
  background: rgba(255,75,62,0.12);
  color: #ffd2cf;
  margin-bottom: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(10,10,12,0.92);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .title {
  font-family: "DM Serif Display", serif;
  font-size: 22px;
}

.topbar-actions {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.builder-shell {
  padding: 20px 24px;
}

.builder-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.role-builder-page {
  height: 100vh;
  overflow: hidden;
}

.role-builder-page .builder-shell {
  height: calc(100vh - 72px);
}

.role-builder-page .builder-container {
  height: 100%;
}

.role-palette,
.role-inspector {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.role-palette .tab-panel {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 4px;
}

.role-palette .tabs {
  flex: 0 0 auto;
}

.role-inspector {
  overflow-y: auto;
}

.role-settings {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0e0f14;
}

.role-settings .grid {
  gap: 12px;
}

.role-canvas {
  height: 100%;
  min-height: 0;
}

.role-builder .canvas {
  height: 100%;
  min-height: 0;
}

.builder-inspector {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.canvas-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
}

.center-button {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

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

.module-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 320px;
}

.module-image {
  height: 140px;
  background: #0f1015;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.module-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.module-image-placeholder {
  color: var(--muted);
  font-size: 12px;
}

.module-body {
  padding: 14px;
  flex: 1 1 auto;
}

.module-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.module-link {
  color: var(--text);
}

.module-link:hover {
  color: var(--accent);
}

.module-hero {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  align-items: stretch;
}

.module-hero-image {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #0f1015;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.module-hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.module-hero-body {
  display: flex;
  flex-direction: column;
}

.module-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px 16px;
  color: var(--muted);
  font-size: 13px;
}

.module-hero-controls {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 160px minmax(0, 220px) auto;
  gap: 10px;
  align-items: end;
}

.module-hero-controls label {
  margin: 0;
}

.module-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.module-gallery-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #0f1015;
  min-height: 160px;
}

.module-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.module-versions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.module-version {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.02);
}

.module-version-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.module-version-notes {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.module-actions {
  padding: 14px;
  border-top: 1px solid var(--line);
}

.module-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 8, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.module-modal.open {
  display: flex;
}

.module-modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  width: 360px;
  max-width: 90%;
  box-shadow: var(--glow);
}

.module-modal-title {
  font-weight: 600;
  margin-bottom: 12px;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .side-nav {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .app-main { padding: 20px; }
  .grid { grid-template-columns: 1fr; }
  .col-4, .col-6, .col-8, .col-12 { grid-column: span 1; }
  .hero { grid-template-columns: 1fr; }
  .builder { grid-template-columns: 1fr; }
  .builder.role-builder { grid-template-columns: 1fr; height: auto; }
  .role-palette, .role-inspector { height: auto; overflow: visible; }
  .dashboard { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .plane { width: 1200px; height: 900px; }
  .settings-block { width: 100%; position: relative; left: 0; top: 0; transform: none; }
  .module-hero { grid-template-columns: 1fr; }
  .module-hero-controls { grid-template-columns: 1fr; }
}
