:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-soft: #f1f2ef;
  --line: rgba(20, 22, 24, .14);
  --text: #151719;
  --muted: #66706d;
  --accent: #815e55;
  --accent-2: #0f766e;
  --focus: #f59e0b;
  --danger: #b42318;
  --shadow: 0 16px 38px rgba(15, 23, 42, .08);
}

html[data-theme="dark"] {
  --bg: #111312;
  --surface: #181b1a;
  --surface-soft: #202523;
  --line: rgba(255, 255, 255, .14);
  --text: #edf1ef;
  --muted: #a6afac;
  --accent: #c8998d;
  --accent-2: #5eead4;
  --focus: #fbbf24;
  --danger: #f97066;
  --shadow: 0 16px 38px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

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

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  opacity: .46;
  cursor: not-allowed;
}

.cc-topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.cc-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.cc-logo {
  width: min(360px, 48vw);
  height: auto;
  display: block;
}

.cc-title {
  color: var(--accent);
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

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

.cc-main {
  padding: 16px;
}

.cc-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
  align-items: start;
}

.cc-stage,
.cc-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.cc-stage {
  min-width: 0;
  padding: 12px;
}

.cc-panel {
  padding: 14px;
}

@media (min-width: 1121px) {
  .cc-stage,
  .cc-panel {
    position: sticky;
    top: 16px;
  }

  .cc-panel {
    max-height: calc(100vh - 118px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }
}

.cc-panel h1,
.cc-panel h2 {
  margin: 0 0 10px;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
}

.cc-panel h1 {
  font-size: 20px;
}

.cc-panel h2 {
  margin-top: 16px;
  font-size: 14px;
}

.cc-dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 92px;
  margin-bottom: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
  cursor: pointer;
}

.cc-dropzone strong {
  color: var(--text);
}

.cc-dropzone span {
  font-size: 12px;
}

.cc-dropzone.is-dragover {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.cc-canvas-wrap {
  position: relative;
  width: 100%;
  height: min(72vh, 760px);
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(120, 130, 125, .12) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(120, 130, 125, .12) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(120, 130, 125, .12) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(120, 130, 125, .12) 75%);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}

.cc-canvas-wrap.is-empty {
  display: none;
}

#mainCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.cc-toolbar {
  display: inline-flex;
  gap: 0;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.cc-toolbar button {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.cc-toolbar button:last-child {
  border-right: 0;
}

.cc-toolbar button.is-active {
  background: var(--accent);
  color: #fff;
}

.cc-row,
.cc-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.cc-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: 38px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
}

input[type="range"] {
  width: 100%;
  margin-top: 8px;
  accent-color: var(--accent);
}

input[type="color"] {
  width: 100%;
  height: 38px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  background: var(--surface);
}

.cc-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px;
}

.cc-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.cc-mini,
.cc-meta {
  color: var(--muted);
  font-size: 12px;
}

.cc-meta {
  min-height: 18px;
  margin: 8px 0 0;
}

.cc-feedback {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--accent-2);
  font-weight: 800;
}

.cc-list {
  display: grid;
  gap: 8px;
  padding-right: 2px;
}

.cc-group-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding-right: 2px;
}

.cc-group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-soft);
  cursor: pointer;
}

.cc-group-item.is-active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.cc-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-soft);
  cursor: pointer;
}

.cc-item.is-active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.cc-thumb {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: #fff;
  object-fit: cover;
}

.cc-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}

.cc-item-meta {
  color: var(--muted);
  font-size: 11px;
}

.cc-index {
  min-width: 26px;
  color: var(--accent);
  text-align: right;
  font-size: 12px;
  font-weight: 800;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 1120px) {
  .cc-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .cc-topbar,
  .cc-brand,
  .cc-actions {
    align-items: flex-start;
  }

  .cc-topbar {
    flex-direction: column;
  }

  .cc-brand {
    flex-direction: column;
  }

  .cc-logo {
    width: min(320px, 88vw);
  }

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

  .cc-toolbar {
    display: grid;
    width: 100%;
  }

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

  .cc-toolbar button:last-child {
    border-bottom: 0;
  }
}
