* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-0: #06080c;
  --bg-1: #0d1118;
  --bg-2: #121a26;
  --bg-3: #182231;
  --line: #25354a;
  --line-strong: #3d5a77;
  --text: #d7e7f7;
  --text-dim: #8da7c3;
  --text-soft: #6d87a4;
  --accent: #68e7ff;
  --accent-2: #ff5c89;
  --ok: #65f3c8;
  --warn: #ffbb67;
  --font-main: 'Chakra Petch', sans-serif;
  --font-brand: 'Orbitron', sans-serif;
  --topbar-h: 48px;
  --bottombar-h: 68px;
  --left-w: 220px;
  --right-w: 270px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 13px;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: linear-gradient(180deg, #101722, #0d141f);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

#logo {
  display: flex;
  align-items: center;
  gap: 7px;
  border-right: 1px solid var(--line);
  padding-right: 10px;
}

.logo-ghost {
  font-family: var(--font-brand);
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.logo-text {
  font-family: var(--font-brand);
  font-size: 15px;
  letter-spacing: 0.14em;
  color: #ecf8ff;
}

.logo-sub {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--text-soft);
}

#topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

#topbar-mode {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tb-btn {
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text-dim);
  padding: 0 10px;
  font-family: var(--font-main);
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 600;
  cursor: pointer;
  transition: 0.16s ease;
}

.tb-btn:hover {
  color: #f1fbff;
  border-color: var(--line-strong);
  background: #1d2b3d;
}

.tb-btn.accent {
  border-color: rgba(104, 231, 255, 0.65);
  color: #cbf5ff;
  background: linear-gradient(180deg, rgba(35, 62, 82, 0.8), rgba(20, 33, 48, 0.84));
}

.tb-btn.accent:hover {
  box-shadow: 0 0 14px rgba(104, 231, 255, 0.35);
}

.tb-btn.icon-only {
  min-width: 30px;
  padding: 0 7px;
}

.tb-btn.toggle-btn[data-active="true"] {
  border-color: rgba(104, 231, 255, 0.7);
  color: #d8faff;
}

.tb-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 3px;
}

#zoom-display {
  min-width: 44px;
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
}

.mode-btn {
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 0 10px;
  cursor: pointer;
  transition: 0.16s ease;
}

.mode-btn.active,
.mode-btn:hover {
  color: #e7fbff;
  border-color: rgba(104, 231, 255, 0.7);
}

#main-area {
  flex: 1;
  display: flex;
  min-height: 0;
}

#left-sidebar {
  width: var(--left-w);
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#right-sidebar {
  width: var(--right-w);
  background: var(--bg-1);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-soft);
  border-bottom: 1px solid var(--line);
}

.palette-search {
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.palette-search input {
  width: 100%;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-0);
  color: var(--text);
  padding: 0 9px;
  font-family: var(--font-main);
  outline: none;
}

.palette-search input:focus { border-color: rgba(104, 231, 255, 0.7); }

#object-palette {
  flex: 1;
  overflow: auto;
  padding: 4px 0 10px;
}

#object-palette::-webkit-scrollbar { width: 6px; }
#object-palette::-webkit-scrollbar-thumb { background: #2d4058; border-radius: 8px; }

.group-label {
  padding: 8px 12px 4px;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: grab;
  border-left: 2px solid transparent;
  user-select: none;
  transition: 0.12s ease;
}

.palette-item:hover {
  border-left-color: var(--accent);
  background: rgba(104, 231, 255, 0.08);
}

.palette-item:active {
  cursor: grabbing;
  background: rgba(104, 231, 255, 0.12);
}

.obj-icon {
  min-width: 28px;
  height: 22px;
  border: 1px solid rgba(104, 231, 255, 0.4);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-brand);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: #b8f7ff;
  background: rgba(24, 35, 48, 0.8);
  box-shadow: 0 0 8px rgba(104, 231, 255, 0.15) inset;
}

.palette-item span:last-child {
  font-size: 12px;
  color: var(--text-dim);
}

.palette-item:hover span:last-child {
  color: #ebf9ff;
}

.sidebar-section {
  border-top: 1px solid var(--line);
}

.layer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  color: var(--text-dim);
}

.layer-count {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0 7px;
  font-size: 10px;
}

#viewport-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#viewport-overlay-top,
#viewport-overlay-bottom {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 3;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-soft);
}

#viewport-overlay-top { top: 0; }
#viewport-overlay-bottom { bottom: 0; background: linear-gradient(180deg, transparent, rgba(6, 8, 12, 0.78)); }

#editor-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
}

#import-drop-zone {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(104, 231, 255, 0.8);
  background: rgba(7, 12, 18, 0.88);
  z-index: 20;
}

#import-drop-zone.active { display: flex; }

.drop-content {
  text-align: center;
  color: #cbf8ff;
  letter-spacing: 0.08em;
}

.drop-icon {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-brand);
  font-size: 20px;
}

#properties-panel {
  flex: 1;
  overflow: auto;
}

#properties-panel::-webkit-scrollbar { width: 6px; }
#properties-panel::-webkit-scrollbar-thumb { background: #2d4058; border-radius: 8px; }

#no-selection {
  height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-soft);
}

.no-sel-icon {
  border: 1px solid var(--line);
  padding: 6px 8px;
  border-radius: 6px;
  font-family: var(--font-brand);
  font-size: 11px;
}

.no-sel-text {
  font-size: 12px;
}

#properties-content { padding-bottom: 8px; }

.prop-group {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.prop-group-label {
  padding: 0 12px 6px;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--text-soft);
}

.prop-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
}

.prop-row label {
  width: 72px;
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 11px;
}

.prop-input,
.prop-select {
  flex: 1;
  min-width: 0;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-0);
  color: var(--text);
  padding: 0 8px;
  font-family: var(--font-main);
  font-size: 12px;
  outline: none;
}

.prop-input:focus,
.prop-select:focus {
  border-color: rgba(104, 231, 255, 0.7);
}

.prop-value-display {
  font-size: 11px;
  color: var(--accent);
  font-family: var(--font-brand);
}

.color-input-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
}

.prop-color {
  width: 32px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
}

.prop-btn {
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text-dim);
  padding: 0 12px;
  margin: 4px 12px;
  width: calc(100% - 24px);
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.prop-btn:hover {
  color: #f1fbff;
  border-color: var(--line-strong);
}

.prop-btn.accent {
  border-color: rgba(104, 231, 255, 0.7);
  color: #d2fbff;
}

.prop-btn.danger {
  border-color: rgba(255, 108, 145, 0.62);
  color: #ffb2c8;
}

.prop-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toggle-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle-switch input { display: none; }

.slider {
  width: 34px;
  height: 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-0);
  position: relative;
}

.slider::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-soft);
  top: 2px;
  left: 2px;
  transition: 0.16s ease;
}

.toggle-switch input:checked + .slider {
  border-color: rgba(104, 231, 255, 0.72);
}

.toggle-switch input:checked + .slider::after {
  left: 18px;
  background: var(--accent);
}

#bottom-bar {
  height: var(--bottombar-h);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  background: linear-gradient(180deg, #101722, #0d141f);
  border-top: 1px solid var(--line);
}

#bottom-bar::-webkit-scrollbar { height: 6px; }
#bottom-bar::-webkit-scrollbar-thumb { background: #2d4058; border-radius: 8px; }

.bottom-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  border-right: 1px solid var(--line);
  padding: 5px 10px;
}

.bottom-label {
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--text-soft);
}

.bottom-fields {
  display: flex;
  gap: 8px;
  align-items: center;
}

.bottom-field {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bottom-field label {
  font-size: 11px;
  color: var(--text-dim);
}

.bottom-field input[type="text"],
.bottom-field input[type="number"] {
  width: 68px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-0);
  color: var(--text);
  padding: 0 7px;
  font-family: var(--font-main);
  font-size: 11px;
  outline: none;
}

.bottom-field input[type="text"] { width: 96px; }
.bottom-field input[type="color"] {
  width: 30px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: transparent;
}

#modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.74);
  z-index: 300;
}

#modal-box {
  width: min(700px, 92vw);
  max-height: 84vh;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #111925, #0d141f);
  padding: 16px;
}

#modal-title {
  font-family: var(--font-brand);
  letter-spacing: 0.12em;
  color: #e8f8ff;
  margin-bottom: 12px;
}

#modal-body {
  margin-bottom: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

#modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#modal-actions .prop-btn {
  width: auto;
  margin: 0;
}

#toast-container {
  position: fixed;
  right: 14px;
  bottom: 80px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 400;
  pointer-events: none;
}

.toast {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: rgba(12, 17, 24, 0.94);
  color: var(--text);
  font-size: 12px;
}

.toast.success { border-color: rgba(101, 243, 200, 0.65); color: #b8ffe9; }
.toast.error { border-color: rgba(255, 108, 145, 0.7); color: #ffc2d5; }
.toast.info { border-color: rgba(104, 231, 255, 0.65); color: #d2fbff; }

@media (max-width: 1200px) {
  :root {
    --left-w: 190px;
    --right-w: 250px;
  }
}

@media (max-width: 980px) {
  :root {
    --left-w: 170px;
    --right-w: 220px;
  }

  .palette-item span:last-child {
    font-size: 11px;
  }
}
