:root {
  --bg: #14151a;
  --panel: #1c1e26;
  --panel-2: #23252f;
  --border: #33353f;
  --text: #e8e9ee;
  --text-dim: #9a9caa;
  --accent: #6c7dff;
  --accent-2: #4fd1ff;
}

* { box-sizing: border-box; }

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

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

.topbar {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar__back {
  flex: 0 0 auto;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 100px;
  white-space: nowrap;
}
.topbar__back:hover { color: #fff; border-color: #8cff3c; }
.topbar h1 { margin: 0; font-size: 20px; }
.topbar .subtitle { margin: 4px 0 0; color: var(--text-dim); font-size: 13px; }

.layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 340px;
  flex: 0 0 340px;
  overflow-y: auto;
  padding: 16px;
  border-right: 1px solid var(--border);
  background: var(--panel);
}

.panel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}
.panel h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 10px;
}

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin: 10px 0 4px;
}
label:first-of-type { margin-top: 0; }

input[type="text"], textarea, select, input[type="number"] {
  width: 100%;
  background: #14151a;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] {
  width: 100%;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #14151a;
  padding: 2px;
}

.row { display: flex; gap: 10px; }
.row .col { flex: 1; min-width: 0; }
.checks { align-items: center; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}
.checkbox input { width: auto; margin: 0; }

.style-options { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.style-options.active { display: block; }

.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-label {
  display: block;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  margin-top: 8px;
}
.file-label:hover { border-color: var(--accent-2); color: var(--text); }

.logo-preview-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 8px;
  background: #14151a;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.logo-preview-wrap img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background-image: repeating-conic-gradient(#2a2c36 0% 25%, #1a1b21 0% 50%);
  background-size: 12px 12px;
  border-radius: 4px;
}
.logo-preview-wrap .small-btn { margin-left: auto; }

.primary-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b0c10;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  cursor: pointer;
}
.primary-btn:disabled { opacity: 0.6; cursor: default; }
.primary-btn:hover:not(:disabled) { filter: brightness(1.08); }

.hint { font-size: 11px; color: var(--text-dim); margin: 10px 0 0; line-height: 1.4; }

.export-progress { margin-top: 12px; }
.export-progress progress { width: 100%; }
.export-progress p { font-size: 12px; color: var(--text-dim); margin: 6px 0 0; }

.preview-area {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px;
}

.preview-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.preview-toolbar .hint { margin: 0; }

.small-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.small-btn:hover { filter: brightness(1.15); }

.preview-container {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  border-radius: 10px;
  background-image:
    repeating-conic-gradient(#2a2c36 0% 25%, #1a1b21 0% 50%);
  background-size: 24px 24px;
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.preview-container.dragging { cursor: grabbing; }

#canvas2d, #canvas3d {
  position: absolute;
  display: none;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06);
  pointer-events: none;
}
#canvas3d { z-index: 1; }
#canvas2d { z-index: 2; }

.anchor-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid var(--accent-2);
  border-radius: 50%;
  background: rgba(79, 209, 255, 0.25);
  pointer-events: none;
  opacity: 0.55;
  transition: opacity 0.15s;
}
.preview-container:hover .anchor-marker,
.preview-container.dragging .anchor-marker {
  opacity: 1;
}

.emotion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.emotion-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: #14151a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: inherit;
}
.emotion-card:hover { border-color: var(--accent-2); }
.emotion-card.active {
  border-color: var(--accent-2);
  background: linear-gradient(135deg, rgba(108,125,255,0.18), rgba(79,209,255,0.12));
}
.emotion-card .emoji { font-size: 20px; }
.emotion-card .label { font-size: 13px; font-weight: 600; }
.emotion-card .desc { font-size: 11px; color: var(--text-dim); line-height: 1.3; }

.transport {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.transport button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}
.transport input[type="range"] { flex: 1; }
