:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --panel: #151a22;
  --panel-2: #1c232e;
  --line: #2c3544;
  --text: #e8edf5;
  --muted: #93a0b5;
  --amber: #ffb020;
  --cyan: #5ad7ff;
  --green: #3ddc97;
  --danger: #ff6b6b;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
}

button:hover { border-color: #4c5b73; }

button.primary {
  background: #3a2a10;
  border-color: #8a641c;
  color: #ffd78a;
}

button.active, button[aria-pressed="true"] {
  background: #243044;
  border-color: var(--cyan);
  color: white;
}

button.danger { color: #ffc1c1; }

input[type="number"], input[type="text"], input[type="password"], select {
  background: #0e131b;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  width: 100%;
}

input[type="range"] { width: 100%; }

label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #10151c;
}

.brand { display: flex; flex-direction: column; min-width: 180px; }
.brand strong { font-size: 16px; letter-spacing: 0.02em; }
.brand span { color: var(--muted); font-size: 12px; }

.file-chip {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 280px;
}

.panel {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  background: var(--panel);
}

.panel.left { border-right: 1px solid var(--line); }
.panel.right { border-left: 1px solid var(--line); }

.stage-wrap {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top, rgba(255, 176, 32, 0.08), transparent 42%),
    var(--bg);
}

.stage-toolbar, .transport {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  flex-wrap: wrap;
}

.transport { border-top: 1px solid var(--line); }

.stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-frame {
  display: inline-block;
  padding: 12px;
  border-radius: 16px;
  background: #07090d;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

canvas { display: block; cursor: crosshair; }

h2 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }

.analysis {
  font-size: 13px;
  line-height: 1.45;
  background: #10151c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  white-space: pre-wrap;
}

body.locked .app { display: none; }
body:not(.locked) .login-screen { display: none; }

.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(255, 176, 32, 0.12), transparent 36%),
    var(--bg);
}

.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px 22px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.guide {
  background: #10151c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.guide summary {
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
}

.guide p,
.guide li {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.guide p { margin: 8px 0 0; }
.guide ul { margin: 8px 0 0; padding-left: 18px; }

.swatches, .tools, .programs { display: flex; flex-wrap: wrap; gap: 6px; }

#programs {
  max-height: 320px;
  overflow: auto;
  flex-direction: column;
  align-items: stretch;
  flex-wrap: nowrap;
}

#programs button { text-align: left; }

#pattern-list {
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.pattern-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.swatches button, .tools button { min-width: 42px; }

.timeline-wrap {
  border-top: 1px solid var(--line);
  background: #10151c;
  padding: 8px 12px 12px;
}

.timeline-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.timeline {
  overflow-x: auto;
  padding-bottom: 4px;
}

#timeline { display: block; }

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-size: 13px;
}

.status {
  min-width: 240px;
  color: var(--muted);
  font-size: 13px;
}

.drop {
  outline: 2px dashed var(--amber);
  outline-offset: -8px;
}

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .panel.left, .panel.right { border: 0; border-top: 1px solid var(--line); }
  .app { height: auto; }
}
