:root {
  --bg: #071116;
  --bg-2: #0d1c23;
  --panel: rgba(9, 19, 24, 0.82);
  --panel-strong: rgba(6, 13, 18, 0.92);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #ecf5ef;
  --muted: rgba(236, 245, 239, 0.68);
  --accent: #8fd85f;
  --accent-soft: rgba(143, 216, 95, 0.16);
  --cyan: #7ee4ff;
  --danger: #ff7c69;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --radius-lg: 30px;
  --radius-md: 22px;
  --radius-sm: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(126, 228, 255, 0.14), transparent 26%),
    radial-gradient(circle at 80% 10%, rgba(143, 216, 95, 0.16), transparent 28%),
    linear-gradient(180deg, #071116 0%, #08161b 48%, #050d11 100%);
  color: var(--text);
  font-family: 'Inter', sans-serif;
}

body {
  padding: 28px;
}

button,
a,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

input,
select {
  width: 100%;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: 32px;
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 34px;
  background:
    linear-gradient(135deg, rgba(7, 16, 23, 0.96), rgba(10, 22, 29, 0.86)),
    linear-gradient(120deg, rgba(126, 228, 255, 0.06), transparent 34%),
    linear-gradient(220deg, rgba(143, 216, 95, 0.08), transparent 42%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  inset: auto -8% -42% 36%;
  height: 220px;
  background: radial-gradient(circle, rgba(126, 228, 255, 0.2), transparent 58%);
  filter: blur(28px);
  pointer-events: none;
}

.eyebrow,
.section-label {
  font-size: 0.74rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cyan);
}

.hero h1,
.panel h3,
.editor-topbar h2,
.preview-header h3 {
  font-family: 'Outfit', sans-serif;
}

.hero h1 {
  margin: 12px 0 14px;
  max-width: 12ch;
  font-size: clamp(2.5rem, 5vw, 4.3rem);
  line-height: 0.92;
}

.hero-text,
.hero-note,
.panel p,
.activity-row p,
.preset-row p,
.project-row p,
.small-copy {
  color: var(--muted);
}

.hero-text {
  max-width: 56ch;
  font-size: 1rem;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.hero-note {
  margin: 16px 0 0;
  font-size: 0.92rem;
}

.hero-visual {
  position: relative;
  min-height: 320px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(160deg, rgba(5, 11, 16, 0.92), rgba(8, 18, 22, 0.78)),
    radial-gradient(circle at 25% 25%, rgba(143, 216, 95, 0.18), transparent 22%),
    radial-gradient(circle at 70% 65%, rgba(126, 228, 255, 0.2), transparent 18%);
  overflow: hidden;
}

.hero-grid,
.hero-route,
.hero-phone {
  position: absolute;
}

.hero-grid {
  inset: 16px;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  border-radius: 20px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 88%);
}

.hero-route {
  inset: 18% 10% 14% 16%;
  border: 10px solid transparent;
  border-image: linear-gradient(140deg, rgba(143, 216, 95, 0.2), rgba(126, 228, 255, 0.9), rgba(143, 216, 95, 0.95)) 1;
  clip-path: polygon(18% 16%, 30% 6%, 43% 13%, 51% 26%, 64% 28%, 78% 15%, 88% 22%, 86% 36%, 71% 48%, 58% 44%, 42% 58%, 48% 76%, 36% 88%, 22% 82%, 15% 64%, 24% 50%, 10% 34%);
  opacity: 0.88;
  filter: drop-shadow(0 0 26px rgba(126, 228, 255, 0.22));
}

.hero-phone {
  width: 184px;
  border-radius: 34px;
  background: linear-gradient(180deg, rgba(6, 12, 16, 0.98), rgba(8, 18, 23, 0.86));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.32);
}

.hero-phone::before {
  content: '';
  position: absolute;
  inset: 14px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 20% 15%, rgba(143, 216, 95, 0.18), transparent 28%),
    linear-gradient(180deg, rgba(9, 20, 25, 0.96), rgba(6, 12, 16, 0.92));
}

.hero-phone-a {
  height: 308px;
  right: 34px;
  top: 32px;
  transform: rotate(10deg);
}

.hero-phone-b {
  height: 268px;
  right: 170px;
  bottom: 18px;
  transform: rotate(-12deg);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(0, 1.45fr) minmax(280px, 0.92fr);
  gap: 20px;
  margin-top: 22px;
}

.rail,
.editor-shell {
  display: grid;
  gap: 20px;
  align-content: start;
}

.panel,
.editor-shell,
.preview-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel), rgba(6, 12, 17, 0.9));
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.panel {
  padding: 22px;
}

.panel h3,
.editor-topbar h2,
.preview-header h3 {
  margin: 8px 0 10px;
  font-size: 1.2rem;
}

.editor-shell {
  padding: 22px;
}

.editor-topbar,
.preview-header,
.preview-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.editor-actions,
.inline-actions,
.form-actions,
.hero-actions,
.meta-badges,
.segmented,
.chip-row,
.list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.canvas-shell {
  display: grid;
  gap: 14px;
}

.canvas-frame,
.preview-stage {
  position: relative;
  width: 100%;
  border-radius: 26px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(4, 10, 14, 0.94), rgba(7, 15, 18, 0.94));
}

.canvas-frame.landscape,
.preview-stage.landscape {
  aspect-ratio: 16 / 9;
}

.canvas-frame.portrait,
.preview-stage.portrait {
  aspect-ratio: 9 / 16;
  max-width: 540px;
  margin: 0 auto;
}

#editor-canvas,
#preview-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

.canvas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  color: var(--muted);
  text-align: center;
  font-size: 0.96rem;
}

.grid-overlay,
.widget-overlay {
  position: absolute;
  inset: 0;
}

.grid-overlay {
  pointer-events: none;
  z-index: 2;
}

.widget-overlay {
  z-index: 3;
  pointer-events: auto;
}

.grid-cell {
  position: absolute;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  pointer-events: none;
  transition: border-color 160ms ease, background 160ms ease;
}

.grid-cell.active {
  border-color: rgba(126, 228, 255, 0.42);
  background: rgba(126, 228, 255, 0.07);
}

.widget-token {
  position: absolute;
  border-radius: 24px;
  background: transparent;
  touch-action: none;
  user-select: none;
  cursor: grab;
  pointer-events: auto;
  transition: transform 160ms ease, opacity 160ms ease, filter 160ms ease;
  filter: drop-shadow(0 12px 26px rgba(0, 0, 0, 0.18));
}

.widget-token.dragging {
  cursor: grabbing;
  z-index: 5;
  transform: scale(1.03);
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.28));
}

.widget-token * {
  pointer-events: none;
}

.widget-token-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.canvas-meta {
  display: grid;
  gap: 12px;
}

.scrub-wrap {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

input[type='range'] {
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan);
  border: 0;
}

.button,
.button:visited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), #b7f26f);
  color: #071116;
  font-weight: 700;
}

.button-ghost,
.button-subtle {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.button-danger {
  background: rgba(255, 124, 105, 0.12);
  color: #ffd2ca;
  border: 1px solid rgba(255, 124, 105, 0.24);
}

.button[disabled] {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.panel-grid,
.widget-list,
.activity-list,
.project-list,
.preset-list {
  display: grid;
  gap: 12px;
}

.info-row,
.activity-row,
.project-row,
.preset-row,
.metric-row {
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.activity-row,
.project-row,
.preset-row {
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.activity-row:hover,
.project-row:hover,
.preset-row:hover {
  transform: translateY(-1px);
  border-color: rgba(126, 228, 255, 0.24);
}

.activity-row.active,
.project-row.active,
.preset-row.active {
  border-color: rgba(126, 228, 255, 0.42);
  background: rgba(126, 228, 255, 0.08);
}

.activity-row.unsupported {
  opacity: 0.58;
}

.row-title,
.metric-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.row-title strong,
.metric-title strong {
  font-size: 0.98rem;
}

.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.badge.ok {
  background: rgba(143, 216, 95, 0.14);
  color: #dff8c0;
}

.badge.warn {
  background: rgba(255, 124, 105, 0.12);
  color: #ffd7d0;
}

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

.kv {
  display: grid;
  gap: 4px;
}

.kv span,
.meta-label,
.form-label,
.metric-row label {
  font-size: 0.78rem;
  color: var(--muted);
}

.kv strong {
  font-size: 0.96rem;
}

.field,
.select-group {
  display: grid;
  gap: 8px;
}

.range-head,
.range-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-value {
  font-size: 0.78rem;
  color: var(--text);
}

.range-meta {
  color: var(--muted);
  font-size: 0.74rem;
}

.range-meta span:nth-child(2) {
  flex: 1;
  text-align: center;
}

.field input,
.select-group select {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(3, 8, 12, 0.72);
  color: var(--text);
}

.field input[type='range'] {
  padding: 0;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
}

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

.color-swatch {
  width: 100%;
  height: 46px;
  padding: 0;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
}

.segmented {
  gap: 8px;
}

.segmented button,
.widget-toggle {
  flex: 1 1 auto;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.segmented button.active,
.widget-toggle.active {
  background: rgba(126, 228, 255, 0.14);
  border-color: rgba(126, 228, 255, 0.38);
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric-row.disabled {
  opacity: 0.46;
}

.flash {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid rgba(126, 228, 255, 0.26);
  background: rgba(126, 228, 255, 0.08);
  color: #ebfbff;
}

.export-progress {
  display: grid;
  gap: 10px;
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
}

.preview-dialog {
  width: min(1040px, calc(100% - 32px));
  padding: 0;
  border: 0;
  background: transparent;
}

.preview-dialog::backdrop {
  background: rgba(1, 4, 7, 0.74);
  backdrop-filter: blur(10px);
}

.preview-card {
  padding: 20px;
}

.preview-stage {
  margin: 18px 0;
}

.preview-scrub {
  flex: 1 1 280px;
}

@media (max-width: 1180px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    max-width: 14ch;
  }
}

@media (max-width: 720px) {
  body {
    padding: 14px;
  }

  .hero,
  .panel,
  .editor-shell,
  .preview-card {
    padding: 18px;
    border-radius: 24px;
  }

  .hero {
    gap: 18px;
  }

  .hero-visual {
    min-height: 240px;
  }

  .editor-topbar,
  .preview-header,
  .preview-controls,
  .metric-row,
  .row-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-actions,
  .hero-actions,
  .form-actions,
  .inline-actions {
    width: 100%;
  }

  .button {
    width: 100%;
  }

  .color-row,
  .stat-grid,
  .kv-grid {
    grid-template-columns: 1fr;
  }
}
