/* style.css — all styling */
:root {
  --bg: #0e1116;
  --bg-2: #161b22;
  --panel: #1b212b;
  --panel-2: #222a36;
  --stroke: #2c3543;
  --text: #e8edf5;
  --muted: #8b95a7;
  --accent: #ff5ca8;
  --accent-2: #5b6cff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --bg-2: #ffffff;
    --panel: #ffffff;
    --panel-2: #eef1f7;
    --stroke: #e2e7f0;
    --text: #1a2230;
    --muted: #6b7689;
    --accent: #e0408a;
    --accent-2: #4454e8;
    --shadow: 0 8px 24px rgba(20,30,60,.12);
    color-scheme: light;
  }
}
html[data-theme="dark"] {
  --bg: #0e1116; --bg-2: #161b22; --panel: #1b212b; --panel-2: #222a36;
  --stroke: #2c3543; --text: #e8edf5; --muted: #8b95a7; --accent: #ff5ca8;
  --accent-2: #5b6cff; --shadow: 0 8px 30px rgba(0,0,0,.35); color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f4f6fb; --bg-2: #ffffff; --panel: #ffffff; --panel-2: #eef1f7;
  --stroke: #e2e7f0; --text: #1a2230; --muted: #6b7689; --accent: #e0408a;
  --accent-2: #4454e8; --shadow: 0 8px 24px rgba(20,30,60,.12); color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: radial-gradient(1200px 800px at 80% -10%, var(--bg-2), var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}

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

/* ---- Top bar ---- */
.topbar {
  flex: 0 0 auto;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border-bottom: 1px solid var(--stroke);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.brand .logo {
  font-size: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 6px rgba(255,92,168,.4));
}
.brand h1 {
  font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.tools-row {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}

/* ---- Brushes ---- */
.brushes {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.brush {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-width: 52px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  transition: transform .12s ease, background .15s, color .15s, border-color .15s, box-shadow .15s;
  font: inherit;
}
.brush .ic { font-size: 16px; line-height: 1; }
.brush .lb { font-size: 10px; letter-spacing: .2px; }
.brush:hover { transform: translateY(-1px); color: var(--text); border-color: var(--accent); }
.brush:active { transform: translateY(0) scale(.96); }
.brush.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-color: transparent;
  box-shadow: 0 4px 14px rgba(255,92,168,.35);
}
.brush.active .lb { color: #fff; }

/* ---- Palette ---- */
.palette { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--stroke);
  cursor: pointer; padding: 0;
  transition: transform .12s ease, box-shadow .15s, border-color .15s;
}
.swatch:hover { transform: scale(1.12); }
.swatch:active { transform: scale(.94); }
.swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  transform: scale(1.1);
}

/* ---- Size control ---- */
.size-control {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}
.size-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(255,92,168,.5);
  flex: 0 0 auto;
  transition: width .1s, height .1s, background .15s, box-shadow .15s;
}
.size-control input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 90px; height: 4px; border-radius: 4px;
  background: var(--stroke);
  outline: none;
}
.size-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  cursor: pointer; border: 2px solid #fff2;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.size-control input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: none;
}

#customColor {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--stroke);
  background: none; cursor: pointer; padding: 2px;
}
#customColor::-webkit-color-swatch-wrapper { padding: 0; }
#customColor::-webkit-color-swatch { border: none; border-radius: 50%; }
#customColor::-moz-color-swatch { border: none; border-radius: 50%; }

/* ---- Actions ---- */
.actions { display: flex; gap: 6px; margin-left: auto; }
.act {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: var(--panel-2);
  color: var(--text);
  font-size: 17px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease, background .15s, border-color .15s, box-shadow .15s;
}
.act:hover { transform: translateY(-1px); border-color: var(--accent); }
.act:active { transform: translateY(0) scale(.95); }
.act.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-color: transparent;
  box-shadow: 0 4px 14px rgba(91,108,255,.3);
}

/* ---- Stage ---- */
.stage {
  flex: 1 1 auto; position: relative;
  background:
    linear-gradient(var(--bg-2), var(--bg-2)),
    repeating-linear-gradient(45deg, rgba(255,255,255,.02) 0 10px, transparent 10px 20px);
  border-top: 1px solid var(--stroke);
  overflow: hidden;
}
#canvas {
  position: absolute; inset: 0;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
.hint {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted); font-size: 14px;
  pointer-events: none; opacity: .9;
  letter-spacing: .3px;
  background: var(--panel); border: 1px solid var(--stroke);
  padding: 8px 14px; border-radius: 999px;
  box-shadow: var(--shadow);
  transition: opacity .5s ease;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .topbar { padding: 8px 10px; }
  .brand { margin-bottom: 6px; }
  .brand h1 { font-size: 16px; }
  .tools-row { gap: 8px; }
  .brush { min-width: 44px; padding: 5px 6px; }
  .brush .ic { font-size: 15px; }
  .brush .lb { font-size: 9px; }
  .swatch { width: 22px; height: 22px; }
  .size-control input[type="range"] { width: 70px; }
  .act { width: 34px; height: 34px; font-size: 15px; }
}
@media (max-width: 400px) {
  .brush .lb { display: none; }
  .brush { min-width: 38px; }
  .actions { gap: 5px; }
}
