:root {
  --bg: #0b1220;
  --panel: #121b2d;
  --text: #f5f7fb;
  --muted: #a8b3c7;
  --line: #23304a;
  --accent: #7dd3fc;
  --accent-dark: #2190c5;
  --canvas-bg: #3a3a3a;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

body {
  font: 15px/1.5 "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }

/* ---- Header / Footer ---- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}
.site-header a { color: var(--text); font-weight: 600; }
.site-footer {
  padding: 12px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

/* ---- Layout shell ---- */
body {
  display: flex;
  flex-direction: column;
}

/* ---- Landing ---- */
.page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}
.hero {
  max-width: 600px;
  padding: 48px 24px;
  text-align: center;
}
h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  margin-bottom: 16px;
}
.hero-sub {
  font-size: 1.15rem;
  color: var(--muted);
  margin-bottom: 24px;
}
.features {
  list-style: none;
  padding: 0;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.features li {
  color: var(--muted);
  font-size: 0.95rem;
}
.features li::before {
  content: "\2713  ";
  color: var(--accent);
  font-weight: 700;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn.active {
  background: var(--accent);
  color: #08111d;
  border-color: var(--accent);
}
.btn-primary {
  background: var(--accent);
  color: #08111d;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.cta { padding: 14px 36px; font-size: 1.1rem; border-radius: 12px; }

/* ---- Editor panels ---- */
#editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-panel {
  max-width: 700px;
  margin: 0 auto;
  padding: 32px 24px;
  overflow-y: auto;
  flex: 1;
}
.entry-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.entry-actions .btn { padding: 14px 28px; font-size: 1rem; }

/* ---- Setup ---- */
.setup-section { margin-bottom: 24px; }
.setup-section h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.setup-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.setup-hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
.bg-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}
.bg-input {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: none;
  cursor: pointer;
  padding: 0;
}
.brush-grid { gap: 6px; }
.brush-pick {
  padding: 6px 12px;
  font-size: 13px;
}
.brush-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  vertical-align: middle;
  margin-right: 4px;
}
.brush-icon.flat {
  border-radius: 2px;
  width: 16px;
  height: 8px;
}

/* ---- Color grid (setup) ---- */
.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, transform 0.1s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.chosen { border-color: var(--accent); }
.check {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.btn-begin { margin-top: 16px; padding: 14px 36px; font-size: 1rem; }

/* ---- Workspace ---- */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}
.toolbar-group { display: flex; gap: 6px; align-items: center; }
.medium-label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.workspace-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ---- Tools panel ---- */
.tools-panel {
  width: 160px;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  flex-shrink: 0;
}
.panel-section { margin-bottom: 16px; }
.panel-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.12s;
}
.tool-btn:hover { background: rgba(125,211,252,0.08); }
.tool-btn.active {
  background: var(--accent);
  color: #08111d;
  border-color: var(--accent);
}
.slider {
  width: 100%;
  accent-color: var(--accent);
}
.thinner-btn { margin-top: 8px; }
.clean-btn { color: var(--muted); border-style: dashed; }

/* ---- Canvas ---- */
.canvas-wrap {
  flex: 1;
  background: var(--canvas-bg);
  position: relative;
  overflow: hidden;
}
#view-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
#view-canvas.brush-loaded { cursor: crosshair; }
#view-canvas:active { cursor: grabbing; }
#view-canvas.brush-loaded:active { cursor: crosshair; }

/* ---- Palette panel ---- */
.palette-panel {
  width: 170px;
  padding: 12px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  flex-shrink: 0;
}
.palette-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.4;
}
.palette-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.palette-swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.palette-swatch:hover { transform: scale(1.12); }
.palette-swatch.loaded {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(125,211,252,0.35), 0 2px 4px rgba(0,0,0,0.3);
}

/* ---- Status bar ---- */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 14px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}
.zoom-label { font-variant-numeric: tabular-nums; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .tools-panel { width: 120px; }
  .palette-panel { width: 120px; }
  .palette-swatch { width: 36px; height: 36px; }
  .color-swatch { width: 34px; height: 34px; }
  .hero { padding: 32px 16px; }
}

@media (max-width: 540px) {
  .workspace-body { flex-direction: column; }
  .tools-panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 8px;
    padding: 8px;
    overflow-x: auto;
    flex-shrink: 0;
  }
  .panel-section { margin-bottom: 0; min-width: max-content; }
  .tool-btn { width: auto; }
  .palette-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
  }
  .palette-grid { flex-wrap: nowrap; overflow-x: auto; }
  .canvas-wrap { min-height: 200px; }
}
