/* static/app.css */
:root {
  --bg: #0b1220;
  --fg: #e6e9f0;
  --muted: #9aa4b2;
  --accent: #7c3aed; /* indigo/violet */
  --accent-2: #06b6d4; /* cyan */
  --card: rgba(255,255,255,0.06);
  --card-border: rgba(255,255,255,0.12);
  --glow: 0 0 30px rgba(120, 70, 255, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: radial-gradient(1200px 600px at 10% 20%, #7c3aed22, transparent 60%),
              radial-gradient(1000px 500px at 90% 80%, #06b6d422, transparent 60%),
              radial-gradient(800px 800px at 50% 50%, #f59e0b22, transparent 60%),
              var(--bg);
  color: var(--fg);
  font: 16px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

.header {
  text-align: center; padding: 3rem 1rem 1rem;
}
.title {
  font-weight: 900; letter-spacing: -0.02em;
  font-size: clamp(2rem, 4vw, 3.25rem);
  text-shadow: 0 0 12px rgba(130, 90, 255, .7), 0 0 42px rgba(130, 90, 255, .25);
}
.subtitle { color: var(--muted); margin-top: .4rem; }

.container {
  max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 4rem;
  display: grid; gap: 1rem; grid-template-columns: repeat(12, 1fr);
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,.11), rgba(255,255,255,.04));
  border: 1px solid var(--card-border);
  border-radius: 18px; padding: 1rem;
  box-shadow: var(--glow);
}
.card h2 { margin: 0 0 .75rem; font-size: 1.1rem; }

.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }
@media (max-width: 900px){ .col-6 { grid-column: span 12; } }

.row { display: flex; gap: .75rem; align-items: center; }
.gap { gap: .75rem; }
.full { width: 100%; }

input[type="color"] {
  width: 3.25rem; height: 3.25rem; border: none; border-radius: 9999px; overflow: hidden;
  background: transparent; padding: 0;
}
input[type="range"] {
  width: 100%;
  -webkit-appearance: none; background: transparent; height: 28px;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; background: #2b3444; border-radius: 9999px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  margin-top: -6px; background: white; box-shadow: 0 0 0 4px rgba(124,58,237,.25);
}
label { font-size: .7rem; color: var(--muted); display: block; margin-bottom: .25rem; }

.button {
  border: 1px solid var(--card-border);
  background: linear-gradient(180deg, rgba(124,58,237,.7), rgba(124,58,237,.5));
  color: white; padding: .6rem 1rem; border-radius: 9999px;
  cursor: pointer; font-weight: 600; transition: transform .05s ease, filter .15s ease;
}
.button:hover { filter: brightness(1.05); }
.button:active { transform: translateY(1px); }
.button--cyan {
  background: linear-gradient(180deg, rgba(6,182,212,.7), rgba(6,182,212,.5));
}
.button--pink {
  background: linear-gradient(180deg, rgba(217,70,239,.7), rgba(217,70,239,.5));
}
.button--amber {
  background: linear-gradient(180deg, rgba(245,158,11,.75), rgba(245,158,11,.55));
}

.grid-nodes {
  display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.node {
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.05));
  border: 1px solid var(--card-border);
  border-radius: 16px; padding: .9rem;
  display: flex; align-items: center; gap: .75rem;
}
.node .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 12px #22c55eaa;
}
.node .name { font-weight: 700; }
.node .kind { font-size: .75rem; color: var(--muted); }

.footer {
  text-align: center; color: var(--muted); font-size: .75rem; padding: 2rem 0 3rem;
}

.motion-schedule-grid {
  --motion-schedule-columns: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
  align-items: stretch;
}

.motion-schedule-column {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  flex: 1 1 calc(100% / var(--motion-schedule-columns));
  min-width: 0;
}

.motion-schedule-slot {
  background: var(--slot-color, rgba(148,163,184,.25));
  color: var(--slot-text, #e2e8f0);
  border-radius: 16px;
  padding: .9rem .95rem;
  text-align: left;
  font-weight: 600;
  font-size: .8rem;
  letter-spacing: .03em;
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.18);
  transition: transform .12s ease, box-shadow .12s ease;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: .5rem;
  line-height: 1.35;
}
.motion-schedule-slot:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.24), 0 14px 28px rgba(15,23,42,.35);
}
.motion-schedule-slot--selected {
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.28), 0 0 0 2px rgba(59,130,246,.65), 0 14px 32px rgba(59,130,246,.25);
  transform: translateY(-1px);
}
.motion-schedule-slot--selected:hover {
  transform: translateY(-1px);
}
.motion-schedule-hour {
  text-transform: uppercase;
  font-size: .72rem;
  letter-spacing: .08em;
  opacity: .85;
}

.motion-schedule-label {
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: .01em;
  text-transform: none;
  word-break: break-word;
}

.motion-schedule-slot--empty .motion-schedule-label {
  opacity: .82;
  font-weight: 500;
}

.motion-schedule-controls {
  position: relative;
  scroll-margin-top: 96px;
  transition: box-shadow .3s ease, transform .3s ease;
}

.motion-schedule-controls--active {
  box-shadow: 0 0 0 2px rgba(129,140,248,.55), 0 0 32px rgba(129,140,248,.35);
  transform: translateZ(0);
  animation: motion-schedule-controls-pulse 1.1s ease;
}

@keyframes motion-schedule-controls-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(129,140,248,.55), 0 0 12px rgba(129,140,248,.25);
  }
  45% {
    box-shadow: 0 0 0 8px rgba(129,140,248,.15), 0 0 36px rgba(129,140,248,.45);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(129,140,248,0), 0 0 18px rgba(129,140,248,.2);
  }
}

@media (max-width: 900px) {
  .motion-schedule-grid {
    gap: .75rem;
  }
  .motion-schedule-column {
    gap: .65rem;
  }
  .motion-schedule-slot {
    padding: .8rem .85rem;
  }
}

@media (max-width: 640px) {
  .motion-schedule-grid {
    gap: .6rem;
  }
  .motion-schedule-slot {
    padding: .7rem .78rem;
  }
  .motion-schedule-label {
    font-size: .88rem;
  }
}
.motion-field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.motion-field-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(148,163,184,.9);
}
.motion-select {
  background: rgba(15,23,42,.55);
  border: 1px solid rgba(148,163,184,.35);
  border-radius: 12px;
  padding: .55rem .75rem;
  color: #e2e8f0;
  min-width: 120px;
}
.motion-select:focus {
  outline: none;
  border-color: rgba(59,130,246,.85);
  box-shadow: 0 0 0 2px rgba(59,130,246,.35);
}
.motion-button {
  border-radius: 9999px;
  padding: .55rem 1.25rem;
  font-weight: 600;
  background: linear-gradient(180deg, rgba(148,163,184,.45), rgba(30,41,59,.75));
  border: 1px solid rgba(148,163,184,.35);
  color: #f8fafc;
  transition: filter .15s ease, transform .05s ease;
  cursor: pointer;
  white-space: nowrap;
}
.motion-button:hover { filter: brightness(1.08); }
.motion-button:active { transform: translateY(1px); }

.preset-item {
  position: relative;
  display: inline-flex;
  align-items: center;
}

#presetList.is-editing .preset-item.is-draggable,
#presetList[data-editing="true"] .preset-item.is-draggable {
  cursor: grab;
}

#presetList.is-editing .preset-item.is-draggable.is-dragging,
#presetList[data-editing="true"] .preset-item.is-draggable.is-dragging {
  cursor: grabbing;
  opacity: 0.7;
}

#presetList.is-editing .preset-item.drop-target-before::before,
#presetList.is-editing .preset-item.drop-target-after::after,
#presetList[data-editing="true"] .preset-item.drop-target-before::before,
#presetList[data-editing="true"] .preset-item.drop-target-after::after {
  content: '';
  position: absolute;
  top: -8px;
  bottom: -8px;
  width: 4px;
  border-radius: 9999px;
  background: rgba(129, 140, 248, 0.85);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.55);
  z-index: 1;
}

#presetList.is-editing .preset-item.drop-target-before::before,
#presetList[data-editing="true"] .preset-item.drop-target-before::before {
  left: -6px;
}

#presetList.is-editing .preset-item.drop-target-after::after,
#presetList[data-editing="true"] .preset-item.drop-target-after::after {
  right: -6px;
}

.preset-delete {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 9999px;
  border: 1px solid rgba(248, 250, 252, 0.45);
  background: rgba(15, 23, 42, 0.85);
  color: rgba(248, 113, 113, 0.95);
  font-size: 0.75rem;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s ease, filter .15s ease;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.45);
  z-index: 2;
}

.preset-delete:hover {
  filter: brightness(1.15);
}

.preset-delete:active {
  transform: translateY(1px);
}

#presetList.is-editing .preset-item[data-custom="true"] .preset-delete,
#presetList[data-editing="true"] .preset-item[data-custom="true"] .preset-delete {
  display: inline-flex;
}
.motion-button--primary {
  background: linear-gradient(180deg, rgba(129,140,248,.85), rgba(99,102,241,.75));
  border-color: rgba(129,140,248,.6);
}
.motion-button--dirty {
  box-shadow: 0 0 0 2px rgba(245,158,11,.35);
}
.motion-button[disabled] {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}

.motion-legend-item {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .45rem .9rem;
  border-radius: 9999px;
  background: rgba(15,23,42,.55);
  border: 1px solid rgba(148,163,184,.28);
  color: #e2e8f0;
}

button.motion-legend-item {
  font: inherit;
}

.motion-legend-item--editable {
  cursor: pointer;
  background: linear-gradient(180deg, rgba(30,41,59,.82), rgba(15,23,42,.7));
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  box-shadow: 0 6px 18px rgba(15,23,42,.4);
}

.motion-legend-item--editable:hover {
  transform: translateY(-1px);
  border-color: rgba(148,163,184,.55);
  box-shadow: 0 12px 26px rgba(15,23,42,.45);
}

.motion-legend-item--editable:focus-visible {
  outline: none;
  border-color: rgba(99,102,241,.75);
  box-shadow: 0 0 0 3px rgba(99,102,241,.45), 0 12px 26px rgba(15,23,42,.45);
}

.motion-legend-item--editable:active {
  transform: translateY(0);
  box-shadow: 0 6px 18px rgba(15,23,42,.4);
}

.motion-legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--swatch-color, rgba(148,163,184,.35));
  box-shadow: 0 0 0 3px rgba(15,23,42,.55);
}

.motion-legend-label {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
}

.motion-legend-color-input {
  position: fixed;
  width: 1px;
  height: 1px;
  border: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}
