:root {
  color-scheme: light;
  --ink: #141519;
  --ink-2: #22242b;
  --muted: #737782;
  --line: rgba(20, 21, 25, 0.12);
  --line-strong: rgba(20, 21, 25, 0.22);
  --surface: #f6f6f8;
  --surface-2: #eceef1;
  --paper: #ffffff;
  --site-accent: #7264f3;
  --site-secondary: #ef7d93;
  --site-warm: #e4c75f;
  --focus-ring: #5d48db;
  --focus-ring-contrast: rgba(255, 255, 255, 0.96);
  --cyan: #61d8d1;
  --mint: #8dd7b5;
  --violet: #7264f3;
  --coral: #ef7d93;
  --shadow: 0 16px 48px rgba(27, 29, 35, 0.12);
  --stage-zoom: 1;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: #e8e9ec;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: #e8e9ec;
  font-family: Inter, "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

body.profile-open {
  overflow: hidden;
}

button,
input,
select,
output {
  font: inherit;
  letter-spacing: 0;
}

button,
a,
label,
select,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  color: inherit;
}

button {
  border: 0;
}

a {
  text-decoration: none;
}

svg {
  display: block;
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

img {
  display: block;
  max-width: 100%;
}

.ambient-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.28;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  padding: 12px;
}

.topbar {
  position: relative;
  z-index: 20;
  min-height: 64px;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(300px, 1fr);
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.brand,
.top-actions,
.project-state,
.user-pill,
.panel-title,
.canvas-toolbar,
.canvas-toolbar > div,
.canvas-tools,
.panel-head,
.result-actions,
.switch-row,
.restore-card,
.hero-showcase-card span,
.profile-actions,
.exhibition-label {
  display: flex;
  align-items: center;
}

.brand {
  width: max-content;
  min-width: 0;
  gap: 11px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
}

.brand-mark svg {
  width: 21px;
  height: 21px;
}

.brand-copy {
  display: grid;
  min-width: 0;
  line-height: 1.05;
}

.brand strong {
  font-size: 15px;
  font-weight: 820;
}

.brand small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.project-state {
  min-width: 0;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
}

.project-state b {
  white-space: nowrap;
  font-weight: 760;
}

.project-state small {
  color: var(--muted);
  white-space: nowrap;
}

.project-dot,
.live-dot,
.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 4px rgba(141, 215, 181, 0.2);
}

.top-actions {
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.top-badges {
  display: flex;
  gap: 5px;
}

.top-badges button,
.panel-status,
.stage-label,
.layer-token,
.rail-label,
.canvas-footer,
.eyebrow {
  font-size: 10px;
  font-weight: 820;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-badges button {
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #5f626b;
  background: #fff;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.top-badges button:hover,
.top-badges button:focus-visible {
  color: #fff;
  border-color: var(--violet);
  background: var(--violet);
  transform: translateY(-1px);
}

.icon-button,
.text-button,
.primary-button,
.ghost-button,
.user-pill,
.tool-tab,
.ratio-card,
.segmented button,
.zoom-readout {
  position: relative;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.84);
}

.icon-button:hover,
.zoom-readout:hover,
.text-button:hover {
  color: var(--violet);
  border-color: rgba(114, 100, 243, 0.36);
  background: #fff;
}

.icon-button.active {
  color: #fff;
  border-color: var(--violet);
  background: var(--violet);
}

.user-pill {
  min-height: 40px;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
  font-weight: 760;
}

.user-pill svg {
  width: 14px;
  height: 14px;
}

.user-orbit {
  width: 18px;
  height: 18px;
  border: 4px solid #15161a;
  border-right-color: var(--violet);
  border-radius: 50%;
}

.user-pill.logged-in .user-orbit {
  border-right-color: var(--mint);
}

.primary-button,
.ghost-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 15px;
  border-radius: 6px;
  font-weight: 780;
  font-size: 12px;
}

.primary-button {
  color: #fff;
  background: var(--ink);
}

.primary-button:hover {
  background: #262832;
  box-shadow: 0 8px 22px rgba(20, 21, 25, 0.18);
}

.button-spinner {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: buttonSpin 720ms linear infinite;
}

@keyframes buttonSpin {
  to { transform: rotate(360deg); }
}

.ghost-button {
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
}

.disabled,
button.disabled,
button:disabled {
  opacity: 0.38;
}

.disabled,
button.disabled {
  pointer-events: none;
}

button:disabled {
  cursor: not-allowed;
}

button.is-pressed,
.primary-button.is-pressed,
.ghost-button.is-pressed {
  transform: translateY(1px) scale(0.985);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
label:focus-within {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--focus-ring-contrast);
}

.eyebrow {
  color: var(--violet);
}

.panel-title {
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-title h1 {
  margin: 7px 0 8px;
  color: #fff;
  font-size: 28px;
  line-height: 1.05;
}

.panel-title p {
  max-width: 260px;
  margin: 0;
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
  line-height: 1.65;
}

.panel-status {
  flex: 0 0 auto;
  padding: 5px 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.62);
}

.settings-panel {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend,
.range-row label {
  display: block;
  margin-bottom: 9px;
  color: rgba(255, 255, 255, 0.52);
  font-size: 11px;
  font-weight: 760;
}

.ratio-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.ratio-card {
  min-width: 0;
  height: 58px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.58);
  background: rgba(255, 255, 255, 0.055);
}

.ratio-card:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

.ratio-card.active {
  color: #121318;
  border-color: #fff;
  background: #fff;
}

.ratio-card span {
  font-size: 9px;
  font-weight: 800;
}

.ratio-icon {
  display: block;
  width: 15px;
  height: 15px;
  border: 1.5px solid currentColor;
  border-radius: 1px;
}

.ratio-icon.portrait { width: 11px; }
.ratio-icon.wide { width: 19px; height: 11px; }
.ratio-icon.tall { width: 9px; height: 17px; }

.select-wrap {
  position: relative;
}

.select-wrap > svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 15px;
  height: 15px;
  color: rgba(255, 255, 255, 0.56);
  transform: translateY(-50%);
  pointer-events: none;
}

select,
.profile-field input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  outline: 0;
}

.select-wrap select {
  padding: 0 34px 0 35px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  appearance: none;
}

.select-wrap::after {
  content: "⌄";
  position: absolute;
  top: 9px;
  right: 12px;
  color: rgba(255, 255, 255, 0.5);
  pointer-events: none;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
}

.segmented button {
  min-width: 0;
  min-height: 38px;
  padding: 0 8px;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.56);
  background: transparent;
  font-size: 11px;
  font-weight: 760;
}

.segmented button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

.range-row > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.range-row output {
  margin-bottom: 9px;
  color: #fff;
  font-size: 10px;
  font-weight: 820;
}

input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--coral));
}

input[type="range"]::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  margin-top: -6px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
  appearance: none;
}

.switch-row {
  justify-content: space-between;
  gap: 16px;
}

.switch-row > span {
  display: grid;
  gap: 3px;
}

.switch-row b {
  color: #fff;
  font-size: 11px;
}

.switch-row small {
  color: rgba(255, 255, 255, 0.46);
  font-size: 9px;
}

.switch {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch i {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  transition: background 160ms ease;
}

.switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
}

.switch input:checked + i {
  background: var(--violet);
}

.switch input:checked + i::after {
  transform: translateX(16px);
}

.restore-card {
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.restore-card > svg {
  color: var(--cyan);
}

.restore-card div {
  min-width: 0;
  display: grid;
  flex: 1;
  gap: 3px;
}

.restore-card b { font-size: 11px; }
.restore-card small { color: rgba(255,255,255,.5); font-size: 9px; line-height: 1.4; }
.restore-card > span { color: var(--mint); font-size: 9px; font-weight: 820; }

.text-button {
  padding: 5px 0;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 760;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 11px 15px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: #fff;
  background: rgba(20, 21, 25, 0.92);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 720;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
