:root {
  --bg: #081018;
  --panel: #101924;
  --panel-alt: #172230;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #edf3fb;
  --muted: rgba(237, 243, 251, 0.65);
  --accent: #4aa8ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

body {
  min-height: 100vh;
  overflow: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: 100vh;
}

.sidebar {
  padding: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0)), var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  min-height: 0;
}

.workspace {
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    #0a1119;
  background-size: 28px 28px;
  min-height: 100vh;
  overflow: hidden;
}

.brandbar,
.panel,
.workspace__topbar,
.canvas-frame,
.library-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brandbar {
  padding: 16px;
  margin-bottom: 16px;
  background: var(--panel-alt);
}

.brandbar__title {
  font-size: 24px;
  font-weight: 700;
}

.brandbar__meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  padding: 14px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.025);
}

.panel__title,
.library-panel__title {
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preset-grid,
.stack-actions,
.split-grid {
  display: grid;
  gap: 10px;
}

.category-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

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

.stack-actions,
.split-grid {
  grid-template-columns: 1fr 1fr;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.field span {
  font-size: 12px;
  color: var(--muted);
}

.field input[type="number"],
.field input[type="color"],
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e151d;
  color: var(--text);
  padding: 8px 10px;
}

.field input[type="range"] {
  width: 100%;
}

.preset-btn,
.category-tab,
.action-btn {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #121c27;
  color: var(--text);
  cursor: pointer;
}

.preset-btn:hover,
.category-tab:hover,
.action-btn:hover {
  background: #1a2633;
}

.preset-btn.active,
.category-tab.active,
.action-btn--primary {
  background: var(--accent);
  color: #03121f;
  border-color: transparent;
  font-weight: 600;
}

.preset-btn.is-hidden {
  display: none;
}

.info-box,
.recipe {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.workspace__topbar {
  min-height: 54px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-size: 13px;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
  height: calc(100vh - 90px);
}

.canvas-frame {
  height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.05), transparent 48%),
    #0d1721;
  padding: 18px;
  overflow: hidden;
}

canvas {
  width: min(100%, 900px);
  height: auto;
  max-height: calc(100vh - 160px);
  background: #0a1119;
  border-radius: 8px;
}

.library-panel {
  background: rgba(255,255,255,0.03);
  padding: 14px;
  height: 100%;
  overflow-y: auto;
}

.library-grid {
  display: grid;
  gap: 12px;
}

.variant-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  padding: 10px;
  cursor: pointer;
}

.variant-card:hover {
  border-color: rgba(255,255,255,0.28);
}

.variant-card canvas {
  width: 100%;
  display: block;
  border-radius: 6px;
  margin-bottom: 8px;
}

.variant-card__meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

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

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage {
    grid-template-columns: 1fr;
    height: auto;
  }

  .workspace {
    min-height: auto;
    overflow: visible;
  }

  .canvas-frame {
    height: auto;
    min-height: 60vh;
  }

  .library-panel {
    height: auto;
    max-height: none;
  }
}
