* {
  box-sizing: border-box;
}

:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Space Grotesk', system-ui, sans-serif;
}

:root[data-theme="dark"] {
  --page-bg: #0a0a10;
  --topbar-bg: rgba(10, 10, 16, 0.55);
  --text: #e8e8f0;
  --text-dim: #9a9ab0;
  --line: rgba(255, 255, 255, 0.08);
  --chip: rgba(255, 255, 255, 0.05);
  --panel: rgba(16, 16, 26, 0.55);
  --select-bg: #16161f;
  --hint-bg: rgba(0, 0, 0, 0.28);
  --vignette: rgba(0, 0, 0, 0.38);
  --accent: linear-gradient(135deg, #ffd6e0, #c9f4e0);
}

:root[data-theme="light"] {
  --page-bg: #f2f3f7;
  --topbar-bg: rgba(242, 243, 247, 0.62);
  --text: #1a1a24;
  --text-dim: #6d6d82;
  --line: rgba(20, 20, 40, 0.1);
  --chip: rgba(20, 20, 40, 0.05);
  --panel: rgba(255, 255, 255, 0.68);
  --select-bg: #ffffff;
  --hint-bg: rgba(255, 255, 255, 0.6);
  --vignette: rgba(120, 120, 160, 0.12);
  --accent: linear-gradient(135deg, #f8c9d7, #bfe8d5);
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  background: var(--topbar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}

.logo {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.02em;
  margin: 0;
  background: linear-gradient(90deg, #ffd6e0, #c9f4e0, #d6e4ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.logo .dot {
  color: rgba(128, 128, 160, 0.4);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--chip);
  border-color: var(--line);
  transform: translateY(-1px);
}

.tab-btn.active {
  color: #101018;
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 0 26px rgba(255, 214, 224, 0.28);
}

.theme-btn {
  margin-left: 8px;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  opacity: 0.35;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.theme-btn:hover {
  opacity: 1;
  background: var(--chip);
  color: var(--text);
  transform: rotate(18deg);
}

.stage {
  position: fixed;
  top: 62px;
  left: 0;
  right: 0;
  bottom: 0;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, var(--vignette) 100%);
  pointer-events: none;
  z-index: 2;
}

.canvas-wrap {
  position: absolute;
  inset: 0;
  display: none;
}

.canvas-wrap.on {
  display: block;
}

.canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

.hint {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--hint-bg);
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
  z-index: 5;
  pointer-events: none;
}

.toolbar {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100% - 40px);
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  z-index: 5;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.tool-btn:hover {
  background: var(--chip);
  transform: translateY(-1px);
}

.tool-btn:active {
  transform: translateY(0) scale(0.94);
}

.tool-btn.accent {
  background: var(--accent);
  color: #101018;
  border-color: transparent;
  box-shadow: 0 0 18px rgba(255, 214, 224, 0.3);
}

.text-btn {
  height: 34px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  font-size: 11px;
  font-family: inherit;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.text-btn:hover {
  background: var(--chip);
  transform: translateY(-1px);
}

.text-btn:active {
  transform: translateY(0) scale(0.96);
}

.text-btn.accent {
  background: var(--accent);
  color: #101018;
  border-color: transparent;
  box-shadow: 0 0 18px rgba(255, 214, 224, 0.3);
}

select.tool-select {
  background: var(--chip);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

select.tool-select:hover {
  background: var(--chip);
}

select.tool-select option {
  background: var(--select-bg);
}

.slider-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 92px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd6e0, #c9f4e0);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--page-bg);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.55);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--page-bg);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.55);
}

@media (max-width: 720px) {
  .logo {
    font-size: 17px;
  }
  .topbar {
    padding: 0 14px;
    gap: 10px;
  }
  .tab-btn {
    padding: 7px 11px;
    font-size: 11px;
  }
  .toolbar {
    bottom: 14px;
    padding: 8px 10px;
  }
}
