/* ==========================================================================
   gomoney Gradient Studio
   Layout: top bar · full-bleed canvas with floating dock · right inspector
   ========================================================================== */

:root {
  --bg: #111214;
  --surface: #1a1b1e;
  --control: #222327;
  --control-hover: #2a2b30;
  --fill: #34363d;
  --line: #24252a;
  --text: #e8e9eb;
  --muted: #8d9098;
  --faint: #5c5f67;
  --accent: #0075ff;
  --accent-hover: #1a85ff;
  --radius: 7px;
  --panel-width: 304px;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; font-size: 13px; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Line icons only; gradient SVGs keep their own paint */
svg[viewBox="0 0 24 24"] { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

button {
  background: var(--control);
  border: 0;
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: background .15s, color .15s;
}
button:hover { background: var(--control-hover); }
button:disabled { opacity: .35; cursor: default; background: var(--control); }

button.icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  color: var(--muted);
}
button.icon:hover:not(:disabled) { background: var(--control); color: var(--text); }
button.icon svg { width: 17px; height: 17px; }

button.primary { background: var(--accent); color: #fff; font-weight: 500; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }

/* ---------- Shell ---------- */

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-width);
  grid-template-rows: 56px minmax(0, 1fr);
  grid-template-areas: "top top" "stage panel";
  height: 100dvh;
}

/* ---------- Top bar ---------- */

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 20px;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand b { font-size: 19px; letter-spacing: -.9px; display: flex; align-items: center; }
.brand-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin: 7px 0 0 2px; }
.product { color: var(--muted); font-size: 12px; }

.top-actions { display: flex; align-items: center; gap: 4px; }
.history-count {
  font: 11px var(--mono);
  color: var(--faint);
  margin: 0 12px 0 4px;
  min-width: 34px;
}
.top-actions .primary { padding: 7px 14px; font-size: 12px; }

/* ---------- Stage ---------- */

.stage {
  grid-area: stage;
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
}
.fit {
  flex: 1;
  min-width: 0;
  /* room for the frame label above and the dock below */
  margin: 40px 40px 96px;
  display: grid;
  place-items: center;
}
.frame { position: relative; }

.frame-meta {
  position: absolute;
  bottom: 100%;
  left: 0;
  display: flex;
  gap: 6px;
  padding-bottom: 8px;
}
.chip {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--control);
  color: var(--muted);
  white-space: nowrap;
}
.chip-accent { background: color-mix(in srgb, var(--accent) 22%, transparent); color: #b8d6ff; }
#seed { font-family: var(--mono); font-size: 10px; }

.frame-foot {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}
#dimensions { font-family: var(--mono); }

#artboard {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 3px;
  isolation: isolate;
  box-shadow: 0 20px 60px #0008;
}
#art, #art svg, #art canvas, #handles { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#handles { pointer-events: none; }

.handle {
  pointer-events: auto;
  position: absolute;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1.5px solid #fffc;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff14;
  box-shadow: 0 1px 10px #0005;
  cursor: grab;
  touch-action: none;
}
.handle::after { content: ""; position: absolute; inset: 6px; background: #fff; border-radius: 50%; }
.handle:hover { background: #ffffff38; }
.handle.selected { outline: 1.5px solid #fff; outline-offset: 4px; }

/* ---------- Dock ---------- */

.dock {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid #2c2d33;
  border-radius: 11px;
  box-shadow: 0 10px 30px #0007;
}
.dock-count {
  font: 11px var(--mono);
  color: var(--muted);
  min-width: 52px;
  text-align: center;
  white-space: nowrap;
}
.dock-sep { width: 1px; height: 20px; background: #2e3036; margin: 0 5px; }
.dock-generate {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
}
.dock-generate svg { width: 16px; height: 16px; color: #00f5d4; }

#clean .off { display: none; }
#clean[aria-pressed="false"] .on { display: none; }
#clean[aria-pressed="false"] .off { display: block; }
#clean[aria-pressed="true"] { color: var(--text); }

/* ---------- Inspector ---------- */

.panel {
  grid-area: panel;
  overflow-y: auto;
  padding: 2px 16px 40px 8px;
  scrollbar-width: thin;
  scrollbar-color: #2c2d33 transparent;
}

details { padding: 12px 0 14px; border-bottom: 1px solid var(--line); }
details:last-child { border-bottom: 0; }
summary {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 2px 0;
  user-select: none;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "";
  margin-left: auto;
  width: 6px;
  height: 6px;
  border: solid var(--faint);
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .15s;
}
details:not([open]) summary::after { transform: rotate(-45deg); }
summary:hover { color: var(--text); }
details[open] > summary { margin-bottom: 12px; }
.summary-note { text-transform: none; letter-spacing: 0; color: var(--faint); font-weight: 400; }

.panel > details > * + * { margin-top: 6px; }
.panel > details > .seg + div:not(:empty) { margin-top: 6px; }

/* Field: label left, value right, in a control-coloured box */
.field {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius);
  background: var(--control);
  color: var(--muted);
  font-size: 12px;
}
.field output { color: var(--text); font: 12px var(--mono); }
.field select {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: right;
  font-size: 12px;
  padding: 0 0 0 4px;
  min-width: 0;
}
.field select option { background: var(--surface); }
.field:has(select):hover { background: var(--control-hover); }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.readout { justify-content: flex-start; }
.readout span { color: var(--faint); }

.swatch-field { justify-content: flex-start; }
.swatch-field output { margin-left: auto; color: var(--muted); }
.swatch-field span { color: var(--text); }
input[type=color] {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
input[type=color]:disabled { cursor: default; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 4px; }
input[type=color]::-moz-color-swatch { border: 0; border-radius: 4px; }

.toggle { cursor: pointer; }
.toggle input {
  appearance: none;
  width: 28px;
  height: 16px;
  margin: 0;
  border-radius: 99px;
  background: var(--fill);
  position: relative;
  cursor: pointer;
  transition: background .15s;
}
.toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s;
}
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(12px); }

/* Slider: the whole box is the track, the fill shows the value */
.slider {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius);
  background: var(--control);
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
}
.slider::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--p, 0%);
  background: var(--fill);
}
.slider span, .slider output { position: relative; pointer-events: none; }
.slider output { color: var(--text); font: 12px var(--mono); }
.slider input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}
.slider:hover { color: var(--text); }
.slider:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.slider + .slider { margin-top: 6px; }

/* Segmented control */
.seg { display: flex; gap: 4px; }
.seg button {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  font-size: 12px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}
.seg button:hover:not(:disabled) { background: var(--control); color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--control-hover); color: var(--text); }

/* Presets */
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.preset {
  position: relative;
  padding: 0;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--control);
  border-radius: var(--radius);
}
.preset svg { width: 100%; height: 100%; display: block; }
.preset span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 6px 5px;
  font-size: 10px;
  text-align: left;
  color: #fff;
  background: linear-gradient(transparent, #0009);
  opacity: 0;
  transition: opacity .15s;
}
.preset:hover span, .preset.active span, .preset:focus-visible span { opacity: 1; }
.preset.active { outline: 1.5px solid #fff; outline-offset: 2px; }

/* Lights */
.light-tabs { display: flex; gap: 4px; }
.light-tabs button {
  flex: 1;
  padding: 6px 0;
  font: 11px var(--mono);
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.light-tabs button i { width: 8px; height: 8px; border-radius: 50%; }
.light-tabs button:hover { background: var(--control); color: var(--text); }
.light-tabs button[aria-pressed="true"] { background: var(--control-hover); color: var(--text); }

.hint { margin: 8px 0 0; font-size: 11px; line-height: 1.5; color: var(--faint); }

/* Export */
.export-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.export-actions button { font-size: 12px; padding: 9px 4px; }

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  left: calc((100vw - var(--panel-width)) / 2);
  bottom: 84px;
  transform: translate(-50%, 6px);
  padding: 9px 14px;
  border-radius: 8px;
  background: #f2f3f5;
  color: #15161a;
  font-size: 12px;
  box-shadow: 0 8px 24px #0006;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Small screens: canvas on top, inspector below ---------- */

@media (max-width: 820px) {
  .app {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
  }
  .topbar { height: 56px; flex: none; padding: 0 10px 0 16px; }
  .product, .history-count, .tagline { display: none; }
  .stage { height: 52dvh; min-height: 320px; flex: none; }
  .fit { margin: 34px 16px 84px; }
  .dock { bottom: 16px; }
  .panel { overflow: visible; padding: 0 16px 48px; }
  #toast { left: 50%; bottom: 24px; position: fixed; }
}
