:root {
  --bg: #11141a;
  --panel: #171b23;
  --panel-2: #202634;
  --panel-3: #2a3140;
  --text: #e9edf5;
  --muted: #98a2b3;
  --line: #303848;
  --accent: #76a7ff;
  --accent-2: #a88bff;
  --danger: #ff6b6b;
  --shadow: rgba(0, 0, 0, 0.32);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(#293142, #1d2330);
  color: var(--text);
  min-height: 30px;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 1px 8px var(--shadow);
}

button:hover {
  border-color: #526078;
  background: linear-gradient(#313a4c, #232a39);
}

button:active,
button.active {
  border-color: var(--accent);
  color: white;
  background: linear-gradient(#365384, #263b63);
}

input[type="color"] {
  width: 42px;
  height: 24px;
  border: 0;
  background: transparent;
  padding: 0;
}

input[type="range"] {
  width: 112px;
  accent-color: var(--accent);
}

input[type="number"],
select {
  width: 100%;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10141c;
  color: var(--text);
  padding: 3px 7px;
}

.app-shell {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 336px;
  grid-template-rows: 50px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
}

.topbar {
  grid-column: 1 / 4;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 50px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(19, 23, 31, 0.96);
  box-shadow: 0 8px 22px var(--shadow);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 178px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: radial-gradient(circle at 30% 25%, #fff, #9dbdff 18%, #6259de 54%, #312455);
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.06em;
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.top-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
}

.top-actions button {
  min-height: 28px;
  padding: 4px 9px;
}

.status-strip {
  margin-left: auto;
  display: flex;
  gap: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.left-rail {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 9px 7px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
}

.tool {
  width: 40px;
  min-height: 36px;
  padding: 0;
  text-align: center;
  font-weight: 700;
}

.workspace {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  background: #0b0e14;
}

.viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  outline: none;
  background: radial-gradient(circle at center, #202536 0, #121722 58%, #0b0e14 100%);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.marquee {
  position: absolute;
  border: 1px solid var(--accent);
  background: rgba(118, 167, 255, 0.14);
  pointer-events: none;
}

.hidden {
  display: none;
}

.right-panel {
  grid-column: 3;
  grid-row: 2;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
}

.panel-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.005));
  padding: 12px;
  margin-bottom: 12px;
}

.panel-section h2 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #cbd5e1;
}

.section-title-row,
.mini-actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-title-row {
  justify-content: space-between;
}

.mini-actions button {
  min-height: 24px;
  padding: 2px 7px;
}

.button-row {
  flex-wrap: wrap;
  margin-top: 10px;
}

.button-row button {
  min-height: 28px;
  padding: 4px 8px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 10px;
}

.control-grid label {
  display: grid;
  grid-template-columns: minmax(74px, 1fr) auto;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

.control-grid label:has(select),
.control-grid label:has(input[type="number"]) {
  grid-template-columns: 1fr;
  align-items: start;
}

.layers-list {
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.layer-item {
  display: grid;
  grid-template-columns: 28px 28px 1fr 58px;
  align-items: center;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #111722;
}

.layer-item.active {
  border-color: var(--accent);
  background: #17213a;
}

.layer-item button {
  min-height: 25px;
  padding: 0;
  box-shadow: none;
}

.layer-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}

.layer-opacity {
  width: 58px;
}

.muted {
  color: var(--muted);
  margin: 8px 0 0;
}

.text-input-float {
  position: absolute;
  z-index: 20;
  min-width: 160px;
  min-height: 44px;
  resize: both;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: rgba(12, 16, 24, 0.94);
  color: white;
  padding: 8px;
  outline: none;
  box-shadow: 0 12px 32px var(--shadow);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .right-panel {
    position: absolute;
    right: 0;
    top: 50px;
    bottom: 0;
    width: 318px;
    z-index: 4;
    box-shadow: -14px 0 32px var(--shadow);
  }

  .top-actions {
    overflow-x: auto;
  }
}
