*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --studio: #171411;
  --studio-mid: #211c18;
  --glow: rgba(196, 92, 42, 0.16);
  --glass: rgba(28, 23, 20, 0.78);
  --glass-border: rgba(255, 228, 196, 0.16);
  --ink: #f6eee4;
  --muted: #cbbba8;
  --quiet: #9c8d7c;
  --cadmium: #c2411a;
  --cadmium-hover: #d24c28;
  --cadmium-press: #a83614;
  --focus: #e8c07a;
  --active: #f3e6d2;
  --active-ink: #1c1612;
  --paper: #ffffff;
  --hairline: rgba(255, 228, 196, 0.1);
  --shadow-dock:
    0 1px 0 rgba(255, 236, 214, 0.08) inset,
    0 18px 40px rgba(0, 0, 0, 0.38),
    0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-sheet:
    0 24px 60px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(255, 228, 196, 0.08);
  --radius-dock: 22px;
  --radius-sheet: 18px;
  --radius-ctl: 12px;
  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", Candara,
    "Liberation Sans", "Nimbus Sans", sans-serif;
  --mono: "Bahnschrift", "Segoe UI Variable Display", "Liberation Sans Narrow",
    ui-sans-serif, sans-serif;
}

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

body {
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: var(--studio);
  color-scheme: dark;
  overflow: hidden;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px 16px;
  background:
    radial-gradient(900px 480px at 50% -8%, var(--glow), transparent 58%),
    radial-gradient(700px 380px at 100% 110%, rgba(80, 42, 22, 0.35), transparent 60%),
    var(--studio);
}

.toolbar {
  z-index: 2;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px 10px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-dock);
  box-shadow: var(--shadow-dock);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  animation: dock-in 480ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes dock-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 6px 0 4px;
  user-select: none;
}

.brand-mark {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: conic-gradient(from 210deg, #d24c28, #e6b35a, #6ea37a, #d24c28);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25) inset;
}

.brand-name {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}

.tools {
  padding: 3px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  gap: 4px;
}

.actions {
  margin-left: auto;
  gap: 8px;
}

.toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 38px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-ctl);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    background 140ms ease,
    color 140ms ease,
    border-color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.toolbar button:hover {
  background: rgba(255, 236, 214, 0.08);
  color: var(--ink);
}

.toolbar button:active {
  transform: translateY(1px);
}

.toolbar button:focus {
  outline: none;
}

.toolbar button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  color: var(--ink);
}

.toolbar button.active {
  background: var(--active);
  color: var(--active-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset;
}

.toolbar button.active:hover {
  background: #f8efe2;
  color: var(--active-ink);
}

.toolbar button.ghost {
  color: var(--muted);
  background: rgba(255, 236, 214, 0.04);
  border-color: var(--hairline);
}

.toolbar button.ghost:hover {
  background: rgba(255, 236, 214, 0.1);
  color: var(--ink);
}

.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  color: var(--muted);
  white-space: nowrap;
}

.field-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--quiet);
}

.swatch {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 228, 196, 0.28);
  background:
    linear-gradient(var(--studio-mid), var(--studio-mid)) padding-box,
    conic-gradient(#d24c28, #e6b35a, #6ea37a, #5b8ad6, #d24c28) border-box;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.2);
}

.swatch:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 50%;
}

input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 50%;
}

.size-field {
  min-width: 148px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 96px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 228, 196, 0.18);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--studio);
  box-shadow: 0 0 0 1px rgba(255, 228, 196, 0.35);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--studio);
  box-shadow: 0 0 0 1px rgba(255, 228, 196, 0.35);
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

.size-val {
  min-width: 1.6em;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  color: var(--ink);
}

.toolbar button.download {
  min-height: 42px;
  padding: 0 12px;
  flex: 0 0 auto;
  background: var(--cadmium);
  color: #fff;
  border-color: rgba(255, 220, 190, 0.18);
  font-weight: 650;
  letter-spacing: 0.01em;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.22) inset,
    0 10px 22px rgba(194, 65, 26, 0.32);
}

.toolbar button.download:hover {
  background: var(--cadmium-hover);
  color: #fff;
  transform: translateY(-1px);
}

.toolbar button.download:active {
  background: var(--cadmium-press);
  color: #fff;
  transform: translateY(0);
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  width: 100%;
  margin: 0 auto;
}

.sheet {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  background: var(--paper);
  border-radius: var(--radius-sheet);
  box-shadow: var(--shadow-sheet);
  overflow: hidden;
}

#canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  background: var(--paper);
}

@media (max-width: 980px) {
  .toolbar,
  .group {
    flex-wrap: wrap;
  }

  .brand-name {
    display: none;
  }

  .actions {
    margin-left: 0;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 10px;
    gap: 10px;
  }

  .toolbar {
    width: 100%;
    border-radius: 18px;
    padding: 8px;
    flex-wrap: wrap;
  }

  .toolbar button,
  .toolbar button.download {
    min-height: 44px;
  }

  .actions {
    width: 100%;
  }

  .download {
    flex: 1 1 auto;
  }

  .stage {
    width: 100%;
  }

  .sheet {
    border-radius: 14px;
  }

  .size-field {
    min-width: 0;
    flex: 1 1 160px;
  }
}

@media (max-width: 560px) {
  .tool-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .tool {
    min-width: 44px;
    padding: 0 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toolbar {
    animation: none;
  }

  .toolbar button,
  .download {
    transition: none;
  }
}
