:root {
  color-scheme: light;
  --bg: #eef1f5;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: rgba(15, 23, 42, 0.14);
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 30%),
    radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.12), transparent 26%),
    var(--bg);
  color: var(--text);
}

button,
input,
label {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar,
.canvas-toolbar,
.panel-card {
  backdrop-filter: blur(14px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p,
ul {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  text-decoration: none;
  user-select: none;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.35);
}

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

.button-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  border-color: transparent;
}

.button-ghost {
  background: rgba(255, 255, 255, 0.5);
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
}

.canvas-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.canvas-toolbar {
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.mode-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-button {
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
}

.mode-button.is-active {
  color: var(--text);
  background: white;
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.12);
}

.hint {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.stage-wrap {
  position: relative;
  flex: 1;
  min-height: 480px;
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid rgba(15, 23, 42, 0.12);
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(15, 23, 42, 0.05) 25%, transparent 25%, transparent 75%, rgba(15, 23, 42, 0.05) 75%, rgba(15, 23, 42, 0.05)),
    linear-gradient(45deg, rgba(15, 23, 42, 0.05) 25%, transparent 25%, transparent 75%, rgba(15, 23, 42, 0.05) 75%, rgba(15, 23, 42, 0.05));
  background-position: 0 0, 16px 16px;
  background-size: 32px 32px;
}

#stage {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#stage.is-panning {
  cursor: grabbing;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
}

.empty-card {
  pointer-events: auto;
  text-align: center;
  max-width: 320px;
  padding: 24px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: var(--shadow);
}

.empty-title {
  font-size: 20px;
  margin-bottom: 8px;
}

.empty-copy {
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.6;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-card {
  padding: 16px;
}

.panel-card h2 {
  font-size: 16px;
  margin-bottom: 10px;
}

.panel-card p,
.panel-card li {
  color: var(--muted);
  line-height: 1.7;
}

.panel-card ul {
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.small-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.overlay-controls {
  display: grid;
  gap: 10px;
}

.overlay-group {
  display: grid;
  gap: 8px;
}

.overlay-group-title {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.overlay-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.6);
}

.overlay-item.is-active {
  border-color: rgba(37, 99, 235, 0.28);
  background: rgba(255, 255, 255, 0.92);
}

.overlay-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.color-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex: 0 0 auto;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
  flex: 0 0 auto;
}

.swatch-sample {
  cursor: default;
  pointer-events: none;
}

.swatch-point {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.45);
}

.control-stack {
  display: grid;
  gap: 10px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.control-row input[type='range'] {
  flex: 1;
}

.mobile-note {
  margin-top: auto;
}

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

.fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: #0b1220;
}

.fullscreen-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
}

.fullscreen-title {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.72);
}

.fullscreen-stage-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.04) 75%, rgba(255, 255, 255, 0.04)),
    linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.04) 75%, rgba(255, 255, 255, 0.04));
  background-position: 0 0, 16px 16px;
  background-size: 32px 32px;
}

#fullscreenStage {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#fullscreenStage.is-panning {
  cursor: grabbing;
}

body.is-fullscreen-open {
  overflow: hidden;
}

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

  .side-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .canvas-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .actions {
    justify-content: stretch;
  }

  .actions .button,
  .actions label {
    flex: 1 1 auto;
    text-align: center;
  }

  .hint {
    text-align: left;
  }

  .stage-wrap {
    min-height: 54vh;
  }
}
