:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d9e1ea;
  --line-strong: #b9c5d2;
  --text: #172033;
  --muted: #64748b;
  --button: #eef3f8;
  --button-hover: #e2eaf3;
  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 18px 45px rgba(30, 41, 59, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

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

button {
  border: 1px solid var(--line-strong);
  background: var(--button);
  color: var(--text);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 650;
}

button:hover:not(:disabled) {
  background: var(--button-hover);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 40px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  min-height: 96px;
  padding: 10px;
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1;
}

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

.select-wrap {
  width: min(360px, 52vw);
}

.primary-button,
.blue-button {
  border-color: transparent;
  background: var(--blue);
  color: #ffffff;
}

.primary-button:hover:not(:disabled),
.blue-button:hover:not(:disabled) {
  background: var(--blue-hover);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(292px, 1fr);
  gap: 14px;
  align-items: start;
}

.canvas-column {
  min-width: 0;
}

.toolbar,
.panel-block,
.canvas-frame {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 12px;
}

.toolbar-divider {
  display: block;
  width: 1px;
  height: 28px;
  background: var(--line);
  margin: 0 2px;
}

.snap-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 8px;
  color: var(--muted);
  font-weight: 650;
  user-select: none;
}

.snap-toggle input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--text);
}

.canvas-frame {
  border-radius: 10px;
  padding: 10px;
  overflow: auto;
}

#graph {
  display: block;
  width: 100%;
  min-width: 620px;
  height: auto;
  background: #ffffff;
  touch-action: none;
  user-select: none;
}

.graph-label,
.move-hit,
.drag-handle {
  cursor: move;
}

.drag-handle {
  cursor: grab;
}

.hint,
.muted,
.empty-state {
  color: var(--muted);
  font-size: 0.82rem;
}

.hint {
  margin: 10px 0 0;
  text-align: center;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.panel-block {
  border-radius: 10px;
  padding: 14px;
}

.panel-block > * + * {
  margin-top: 10px;
}

.block-label {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.axis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.selected-panel {
  min-height: 182px;
}

.selected-controls {
  display: grid;
  gap: 12px;
}

.field-stack {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.range-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

input[type="range"] {
  min-height: 24px;
  padding: 0;
  accent-color: var(--text);
  background: transparent;
  border: 0;
}

.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.color-palette button {
  width: 28px;
  min-height: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border-color: #ffffff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.18);
}

.color-palette button.selected {
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 5px #64748b;
}

#dash-toggle.active,
#arrow-toggle.active {
  border-color: transparent;
  background: var(--blue);
  color: #ffffff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .select-wrap {
    width: 100%;
  }

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

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 16px 0;
  }

  .top-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar button {
    flex: 1 1 92px;
  }

  .toolbar-divider {
    display: none;
  }

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

/* AI helper (ChatGPT prompt guidance) */
.ai-help { margin-top: 10px; border: 1px solid #e2e8f0; border-radius: 8px; background: #f8fafc; padding: 8px 10px; }
.ai-help summary { cursor: pointer; font-size: 13px; font-weight: 600; color: #1d4ed8; list-style: none; }
.ai-help summary::-webkit-details-marker { display: none; }
.ai-help[open] summary { margin-bottom: 6px; }
.ai-steps { margin: 6px 0 8px; padding-left: 18px; font-size: 12.5px; color: #334155; line-height: 1.5; }
.ai-steps a { color: #1d4ed8; font-weight: 600; }
.ghost-button { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 7px; background: #ffffff; color: #0f172a; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.ghost-button:hover { background: #f1f5f9; border-color: #94a3b8; }
.ai-help .muted { display: block; margin-top: 6px; font-size: 12px; color: #16a34a; min-height: 14px; }
