:root {
  --bg: #0e1116;
  --bg-elevated: #141922;
  --panel: #171d27;
  --panel-2: #1d2430;
  --panel-3: #0f141c;
  --text: #f3f6fb;
  --muted: #93a0b7;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #4f8cff;
  --accent-2: #ff8f5c;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(79, 140, 255, 0.1), transparent 24%),
    radial-gradient(circle at bottom right, rgba(255, 143, 92, 0.08), transparent 20%),
    linear-gradient(180deg, #0b0e13 0%, #10151c 100%);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  overflow: hidden;
}

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

button {
  border: 0;
  border-radius: 12px;
  padding: 0.55rem 0.8rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}

button:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.pseudo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  cursor: pointer;
}

.pseudo-button:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

button:disabled:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: none;
}

button.primary {
  background: linear-gradient(135deg, var(--accent), #6b8cff);
}

button.primary:hover {
  background: linear-gradient(135deg, #6b8cff, var(--accent));
}

input[type="file"] {
  display: none;
}

input[type="number"],
input[type="range"],
select {
  width: 100%;
}

input[type="number"],
select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  background: #11161f;
  color: var(--text);
}

input[type="color"] {
  width: 100%;
  min-height: 42px;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #11161f;
}

input[type="password"] {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  background: #11161f;
  color: var(--text);
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #11161f;
  color: var(--text);
}

input[type="password"]::placeholder,
textarea::placeholder {
  color: var(--muted);
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: 10px;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(20, 25, 34, 0.92);
  box-shadow: var(--shadow);
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-copy h1 {
  margin: 0;
  font-size: 1.05rem;
}

.eyebrow {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.topbar-status {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.status-label {
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

#statusText {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.82rem;
}

.topbar-actions,
.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-2), #ffb36a);
  color: #16110f;
  font-weight: 700;
  cursor: pointer;
}

.secondary-action {
  background: rgba(255, 255, 255, 0.08);
}

.accent-action {
  background: linear-gradient(135deg, #8b5cff, #4f8cff);
  color: #f8fbff;
  box-shadow: 0 10px 24px rgba(79, 140, 255, 0.18);
}

.accent-action:hover {
  background: linear-gradient(135deg, #9b6cff, #69a0ff);
}

.editor-shell {
  min-height: 0;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 360px;
  gap: 10px;
}

.side-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(20, 25, 34, 0.92);
  box-shadow: var(--shadow);
}

.workspace-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(20, 25, 34, 0.92);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(9, 13, 19, 0.78);
  backdrop-filter: blur(6px);
}

.drop-overlay[hidden] {
  display: none !important;
}

.drop-card {
  display: grid;
  gap: 8px;
  min-width: min(360px, calc(100% - 32px));
  padding: 22px 24px;
  border: 1px dashed rgba(79, 140, 255, 0.48);
  border-radius: 18px;
  background: rgba(79, 140, 255, 0.1);
  text-align: center;
  box-shadow: 0 0 0 1px rgba(79, 140, 255, 0.16) inset;
}

.drop-card strong {
  font-size: 1rem;
}

.drop-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.workspace-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 4px 2px;
}

.workspace-head strong {
  display: block;
  font-size: 1rem;
}

.workspace-head small,
.workspace-label {
  color: var(--muted);
  font-size: 0.72rem;
}

.composition-preview {
  min-height: 0;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)),
    #0f141c;
  display: grid;
  position: relative;
}

#compositionCanvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  border-radius: 12px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.05) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.05) 75%);
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  touch-action: none;
  cursor: grab;
}

#compositionCanvas.is-sampling {
  cursor: crosshair;
  box-shadow:
    0 0 0 1px rgba(255, 143, 92, 0.28) inset,
    0 0 0 2px rgba(255, 143, 92, 0.12);
}

#compositionCanvas.is-brushing {
  cursor: crosshair;
  box-shadow:
    0 0 0 1px rgba(79, 140, 255, 0.26) inset,
    0 0 0 2px rgba(79, 140, 255, 0.1);
}

#compositionCanvas.is-blur-painting {
  cursor: crosshair;
  box-shadow:
    0 0 0 1px rgba(255, 143, 92, 0.28) inset,
    0 0 0 2px rgba(255, 143, 92, 0.12);
}

#compositionCanvas.is-dragging {
  cursor: grabbing;
}

#compositionCanvas.is-panning {
  cursor: move;
}

#compositionCanvas.is-rotating {
  cursor: grabbing;
}

.inline-text-editor {
  position: absolute;
  z-index: 6;
  min-width: 120px;
  min-height: 48px;
  resize: none;
  border: 1px solid rgba(79, 140, 255, 0.45);
  box-shadow:
    0 0 0 1px rgba(79, 140, 255, 0.18) inset,
    0 12px 24px rgba(0, 0, 0, 0.24);
  background: rgba(15, 20, 28, 0.96);
}

.inline-text-editor[hidden] {
  display: none !important;
}

.inspector-panel {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 4px;
}

.control-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  background: rgba(23, 29, 39, 0.96);
  box-shadow: var(--shadow);
}

.control-card.is-focused {
  border-color: rgba(79, 140, 255, 0.45);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(79, 140, 255, 0.18) inset;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.card-header h2,
.control-card h2 {
  margin: 0;
  font-size: 0.9rem;
}

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

.compact-grid {
  margin-top: 8px;
}

.grid-2 label,
.slider-list label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.slider-list {
  display: grid;
  gap: 8px;
}

.slider-list label span {
  color: var(--text);
}

.toggle-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

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

.filter-chip {
  min-height: 34px;
}

.filter-chip.is-active {
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.92), rgba(107, 140, 255, 0.82));
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.brush-switch {
  margin-top: -2px;
}

.mode-chip {
  min-height: 34px;
}

.mode-chip.is-active {
  background: rgba(79, 140, 255, 0.22);
  color: #dfe9ff;
  box-shadow: 0 0 0 1px rgba(79, 140, 255, 0.22) inset;
}

.mode-hint {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.sample-badge {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(79, 140, 255, 0.14);
  border: 1px solid rgba(79, 140, 255, 0.22);
  color: #dfe9ff;
  font-size: 0.72rem;
}

.sample-badge::before {
  content: "+ ";
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(6, 9, 14, 0.72);
  backdrop-filter: blur(8px);
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-card {
  width: min(560px, 100%);
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(23, 29, 39, 0.98);
  box-shadow: var(--shadow);
}

.canvas-stage.hidden-editor {
  display: none;
}

.empty-state {
  display: none;
}

@media (max-width: 1180px) {
  .editor-shell {
    grid-template-columns: 52px minmax(0, 1fr) 320px;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    gap: 8px;
    padding: 8px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .editor-shell {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .side-actions {
    flex-direction: row;
    padding: 6px;
    border-radius: 14px;
  }

  .workspace-panel {
    min-height: 52vh;
    padding: 8px;
    border-radius: 14px;
  }

  .workspace-head {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }

  .composition-preview {
    padding: 8px;
    border-radius: 12px;
  }

  #compositionCanvas {
    min-height: 340px;
    max-height: 62vh;
  }

  .inspector-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0;
  }

  .control-card {
    border-radius: 14px;
    padding: 10px;
  }

  .mini-actions,
  .topbar-actions {
    gap: 6px;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  #statusText {
    white-space: normal;
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding: 6px;
  }

  .topbar {
    border-radius: 12px;
    padding: 8px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 0.78rem;
  }

  .brand-copy h1 {
    font-size: 0.95rem;
  }

  .eyebrow,
  .workspace-head small,
  .workspace-label,
  .status-label {
    font-size: 0.64rem;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .upload-button,
  .secondary-action,
  button {
    min-height: 38px;
    padding: 0.55rem 0.7rem;
    font-size: 0.72rem;
  }

  .editor-shell {
    gap: 6px;
  }

  .side-actions {
    padding: 4px;
    gap: 6px;
    border-radius: 12px;
  }

  .workspace-panel {
    min-height: auto;
    border-radius: 12px;
  }

  .composition-preview {
    padding: 6px;
    border-radius: 10px;
  }

  #compositionCanvas {
    min-height: 300px;
    max-height: 56vh;
    border-radius: 10px;
  }

  .inspector-panel {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .control-card {
    padding: 8px;
    border-radius: 12px;
  }

  .card-header {
    align-items: start;
    flex-direction: column;
  }

  .card-header h2,
  .control-card h2 {
    font-size: 0.86rem;
  }

  .slider-list,
  .grid-2,
  .filter-grid {
    gap: 6px;
  }

  .grid-2,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .mode-switch {
    gap: 4px;
  }

  .sample-badge,
  .mode-hint,
  .grid-2 label,
  .slider-list label {
    font-size: 0.7rem;
  }
}

@media (max-width: 420px) {
  #compositionCanvas {
    min-height: 260px;
    max-height: 50vh;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .topbar-actions .primary,
  .topbar-actions .upload-button,
  .topbar-actions .pseudo-button,
  .topbar-actions .secondary-action,
  .topbar-actions button {
    width: 100%;
    justify-content: center;
  }
}
