/*
 * FracGen HTML — clean, accessible light interface.
 * All visuals are authored locally: no fonts, images, UI kits or CDNs.
 * The fractal itself retains its full palette on a black drawing canvas.
 */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --paper: #ffffff;
  --sidebar-bg: #fbfbfd;
  --surface: #f7f8fb;
  --ink: #24243a;
  --muted: #6c7186;
  --soft-muted: #9399a8;
  --line: #e9e9f0;
  --accent: #6b4db0;
  --accent-dark: #563c97;
  --accent-light: #f3eefc;
  --shadow: 0 16px 44px rgb(32 35 63 / 6%);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--ink);
}
* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; background: var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid #a18bcf; outline-offset: 2px; }
[hidden] { display: none !important; }

.masthead { height: 83px; display: flex; align-items: center; gap: 24px; padding: 0 41px; border-bottom: 1px solid var(--line); background: #fff; }
.brand { display: flex; align-items: center; gap: 11px; flex: none; }
.brand-logo { background: #6b4db0; width: 44px; height: 44px; border-radius: 13px; display: inline-flex; justify-content: center; align-items: center; font-size: 33px; color: #fff; font-weight: 650; letter-spacing: -5px; padding-right: 7px; box-shadow: 0 5px 13px #6b4db032; }
.brand-dot { color: #f4b0d3; }
.brand-text { display: grid; gap: 2px; }
.brand-text strong { font-size: 21px; letter-spacing: -.85px; font-weight: 760; line-height: 1; }
.brand-text small { letter-spacing: 2.3px; font-size: 8px; font-weight: 800; color: #a49cae; }
.masthead-note { font-size: 12px; color: #9093a4; border-left: 1px solid var(--line); padding-left: 24px; margin-left: 12px; }
.masthead-separator { margin: 0 5px; color: #cbc8d2; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 23px; white-space: nowrap; }
.version-pill { background: #f4effb; color: #7255b4; padding: 7px 11px; border-radius: 7px; font-size: 10px; font-weight: 800; letter-spacing: 1px; }
.header-link { font-size: 12px; color: #64647b; font-weight: 650; }
.header-link:hover { color: var(--accent); }
.header-link span { color: var(--accent); font-size: 17px; margin-left: 2px; }
.layout { display: grid; grid-template-columns: 335px minmax(0, 1fr); min-height: calc(100vh - 83px); }
.sidebar { border-right: 1px solid var(--line); background: var(--sidebar-bg); }
.sidebar-scroll { padding: 31px 28px 32px; }
.eyebrow { font-size: 9px; font-weight: 850; letter-spacing: 2.25px; color: var(--accent); }
.intro { margin-bottom: 31px; }
.intro h1 { font-size: 31px; line-height: 1.1; letter-spacing: -1.25px; margin: 14px 0 11px; font-weight: 760; }
.intro h1 em { color: var(--accent); font-weight: 650; font-style: normal; }
.intro p { margin: 0; color: #8a8c9f; font-size: 12px; line-height: 1.75; max-width: 250px; }
.control-section { padding: 21px 0 23px; border-top: 1px solid #e8e8f0; }
.section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 17px; }
.section-count { width: 25px; height: 25px; display: inline-grid; place-items: center; font-size: 10px; border-radius: 7px; background: #eee8fa; color: #7656b6; font-weight: 800; }
.section-heading h2 { font-size: 13px; margin: 0; font-weight: 750; letter-spacing: -.2px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span { display: flex; align-items: baseline; justify-content: space-between; gap: 5px; font-size: 11px; font-weight: 650; color: #555971; }
.field code { font: 10px "SFMono-Regular", Consolas, monospace; color: #9992a9; font-weight: 450; }
.field input, .field select { width: 100%; height: 36px; border-radius: 7px; border: 1px solid #dfe1ea; background: #fff; color: #34334b; padding: 0 10px; transition: border-color .15s, box-shadow .15s; }
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23778094' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-size: 17px; background-repeat: no-repeat; background-position: right 10px center; padding-right: 31px; }
.field input:hover, .field select:hover { border-color: #b4b4c8; }
.field input:focus, .field select:focus { border-color: #8b6cce; outline: none; box-shadow: 0 0 0 3px #eae2fa; }
.field input:invalid { border-color: #d17b87; }
.two-fields { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px; }
.three-fields { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.top-gap { margin-top: 16px; }
.field-help { color: #9596a5; line-height: 1.55; margin: 10px 0 0; font-size: 10px; }
.formula-card { border: 1px solid #ece8f5; background: #f5f1fc; border-radius: 7px; padding: 12px 13px; display: grid; gap: 4px; margin-top: 13px; }
.formula-label, .subsection-label { font-size: 9px; font-weight: 800; color: #9284ac; letter-spacing: 1.2px; }
.formula-card strong { font-size: 18px; letter-spacing: -.5px; color: #6749a6; }
.palette-strip { height: 14px; border: 2px solid #fff; border-radius: 7px; margin-top: 11px; box-shadow: 0 0 0 1px #dedfe8; }
.julia-settings { margin-top: 15px; border-top: 1px dashed #e5e2eb; padding-top: 14px; }
.julia-settings .two-fields { margin-top: 11px; }
.resolution-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { border: 1px solid #e2e1e9; background: #fff; border-radius: 6px; font-size: 10px; font-weight: 650; color: #717185; padding: 8px 9px; }
.chip:hover { border-color: #a48acb; color: var(--accent); }
.advanced-details { padding: 17px 0; border-top: 1px solid #e8e8f0; border-bottom: 1px solid #e8e8f0; }
.advanced-details summary { cursor: pointer; display: flex; justify-content: space-between; gap: 5px; align-items: center; font-size: 12px; font-weight: 740; color: #544d72; list-style: none; }
.advanced-details summary::-webkit-details-marker { display: none; }
.advanced-details[open] .chevron { transform: rotate(180deg); }
.details-inner { padding-top: 17px; }
.details-inner > p { margin: 0 0 16px; color: #85869a; font-size: 11px; line-height: 1.6; }
.details-inner .subsection-label { margin: 17px 0 10px; line-height: 1.5; }
.details-inner .field { gap: 5px; }
.details-inner .field input { height: 32px; padding: 0 7px; }
.actions-sidebar { display: grid; gap: 9px; padding-top: 22px; }
.button { height: 39px; border-radius: 8px; border: 1px solid transparent; font-size: 12px; font-weight: 740; display: inline-flex; justify-content: center; align-items: center; gap: 9px; white-space: nowrap; }
.button-primary { background: #6b4db0; color: #fff; box-shadow: 0 6px 15px #6b4db026; }
.button-primary:hover:not(:disabled) { background: #5a3a9f; }
.button-primary span:last-child { margin-left: auto; padding-right: 13px; }
.button-primary span:first-child { margin-left: auto; font-size: 18px; line-height: 1; }
.button-muted { background: transparent; color: #85869a; }
.button-muted:hover { background: #f0edf7; color: #604592; }
.button-outline { border-color: #e4e2eb; background: #fff; color: #59566d; padding: 0 16px; }
.button-outline:hover:not(:disabled) { border-color: #bba8dd; color: #6b4db0; background: #faf8ff; }
.button-light { background: #f3effb; color: var(--accent); padding: 0 15px; }
.button-light:hover:not(:disabled) { background: #e8ddf7; }
.button-small { height: 34px; font-size: 11px; }
.form-error { margin: 0; color: #b13749; background: #fff1f2; padding: 10px; border-radius: 7px; font-size: 11px; line-height: 1.5; }

.workspace { min-width: 0; background: #fff; padding: 32px 39px 22px; }
.work-header { display: flex; gap: 24px; align-items: center; justify-content: space-between; margin-bottom: 27px; }
.work-header .eyebrow { letter-spacing: 1.6px; }
.eyebrow-line { display: inline-block; vertical-align: middle; width: 20px; border-top: 1px solid #c9b9e6; margin: 0 9px; }
.work-header h2 { font-size: clamp(25px, 2.8vw, 36px); letter-spacing: -1.3px; line-height: 1.15; margin: 11px 0 9px; font-weight: 760; }
.work-header h2 em { color: #7958b8; font-style: normal; }
.work-header p { color: #9093a3; font-size: 12px; margin: 0; line-height: 1.6; }
.work-header-buttons { display: flex; flex: none; gap: 8px; }
.content-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; gap: 12px; }
.content-heading > span:first-child { color: #7e8091; font-size: 9px; letter-spacing: 1.5px; font-weight: 850; }
.content-heading > span:last-child { color: #a8abb8; font-size: 10px; }
.preset-list { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 9px; margin-bottom: 19px; }
.preset { min-width: 0; border: 1px solid #e9e7ef; background: #fff; border-radius: 9px; min-height: 87px; padding: 10px 10px 10px; text-align: left; box-shadow: 0 2px 6px #24243a04; transition: background .15s,border-color .15s,transform .15s; }
.preset:hover { border-color: #b7a4d8; transform: translateY(-1px); }
.preset[aria-pressed="true"] { background: #f9f5ff; border-color: #a891d4; box-shadow: 0 0 0 1px #a891d42e; }
.preset-dot { display: block; width: 20px; height: 5px; border-radius: 20px; margin-bottom: 13px; }
.preset strong { display: block; font-size: 10px; font-weight: 790; overflow-wrap: anywhere; margin-bottom: 4px; color: #39364d; }
.preset small { display: block; color: #9898aa; font-size: 9px; line-height: 1.35; }
.visual-card { border-radius: 13px; border: 1px solid #e6e6ee; background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.visual-toolbar { height: 50px; display: flex; justify-content: space-between; align-items: center; padding: 0 18px; gap: 12px; }
.visual-heading, .visual-toolbar-right { display: flex; align-items: center; gap: 10px; }
.live-dot { width: 7px; height: 7px; background: #8d65cb; box-shadow: 0 0 0 3px #f3eaff; border-radius: 50%; }
.visual-heading strong { color: #33334a; font-size: 12px; }
.visual-heading > span:last-child { color: #a2a1b2; font-size: 11px; }
.visual-divider { color: #d3d1dd; }
.visual-toolbar-right { color: #8e91a4; font-size: 11px; flex: none; }
.toolbar-rule { height: 16px; border-left: 1px solid #eae8f0; margin: 0 3px; }
.icon-button { display: inline-grid; place-items: center; width: 27px; height: 27px; background: #fff; border: 1px solid #e9e8ef; border-radius: 6px; color: #71677e; font-size: 18px; line-height: 1; }
.icon-button:hover { color: var(--accent); border-color: #c2b1dd; background: #f9f5ff; }
.icon-text-button { border: 0; background: transparent; font-size: 10px; color: #af5866; font-weight: 800; }
.canvas-surround { min-height: 520px; background-color: #f8f9fb; background-image: radial-gradient(#e1e3e9 0.7px, transparent 0.7px); background-size: 16px 16px; display: flex; align-items: center; justify-content: center; padding: 26px 28px; }
.canvas-wrap { width: min(100%, 590px); position: relative; background: #000; box-shadow: 0 14px 36px #24243a24; user-select: none; }
canvas { display: block; width: 100%; height: auto; background: #000; touch-action: none; cursor: crosshair; image-rendering: auto; }
.zoom-box { position: absolute; border: 2px dashed #faf8ff; background: #946de833; box-shadow: 0 0 0 1px #8255b4; pointer-events: none; }
.render-overlay { position: absolute; inset: 0; background: #101021c4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #fff; }
.render-overlay strong { font-size: 13px; }
.render-overlay small { font-size: 11px; color: #d8d3e8; }
.loader { width: 25px; height: 25px; border-radius: 50%; border: 3px solid #fff4; border-top-color: #c59cfb; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.visual-status { display: flex; align-items: center; justify-content: space-between; min-height: 42px; gap: 15px; padding: 8px 18px; }
.status-text { color: #7f8195; display: inline-flex; align-items: center; gap: 8px; font-size: 10px; }
.status-indicator { width: 6px; height: 6px; border-radius: 50%; background: #65b8a3; }
.status-indicator.busy { background: #c59a54; }
.canvas-hint { color: #9b9baa; font-size: 10px; text-align: right; }
.hint-bullet { color: #d0cbd9; margin: 0 4px; }
.progress-track { height: 3px; background: #eee9f4; }
.progress-track span { display: block; height: 100%; width: 0%; transition: width .1s; background: #7b58bc; }
.below-canvas { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 17px; }
.info-card { border: 1px solid #e8e8ee; border-radius: 10px; padding: 17px 18px 15px; min-width: 0; }
.info-title { display: flex; align-items: center; gap: 8px; color: #4b475e; font-size: 10px; font-weight: 840; letter-spacing: 1px; }
.info-icon { display: inline-grid; place-items: center; width: 23px; height: 23px; border-radius: 6px; background: #f3eefc; color: #7759b9; font-size: 17px; font-weight: normal; }
.info-tag { margin-left: auto; color: #aaa4b4; font-size: 9px; letter-spacing: .7px; font-weight: 670; }
.info-data { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding-top: 15px; }
.info-data > div { min-width: 0; }
.info-data small { display: block; font-size: 9px; color: #a0a0b0; font-weight: 780; letter-spacing: 1px; margin-bottom: 5px; }
.info-data strong { font-size: 11px; font-family: Consolas, "SFMono-Regular", monospace; color: #4f456c; font-weight: 700; overflow-wrap: anywhere; }
.info-foot { color: #a5a4b4; font-size: 10px; border-top: 1px solid #f0eff3; margin: 13px 0 0; padding-top: 11px; }
.info-card-export > p { color: #9392a4; font-size: 11px; line-height: 1.5; margin: 12px 0; }
.export-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.footer { display: flex; justify-content: space-between; gap: 12px; color: #a5a4b0; font-size: 10px; padding: 22px 1px 0; }
.footer-mark { color: var(--accent); margin: 0 4px; }
@media (min-width: 1460px) { .workspace { padding-left: 52px; padding-right: 52px; } .canvas-wrap { width: min(100%, 720px); } }
@media (max-width: 1170px) { .masthead-note { display: none; } .workspace { padding: 28px 25px; } .preset-list { grid-template-columns: repeat(4,1fr); } }
@media (max-width: 920px) { .layout { grid-template-columns: 290px minmax(0,1fr); } .sidebar-scroll { padding: 25px 19px; } .work-header { flex-wrap: wrap; } .preset-list { grid-template-columns: repeat(3,1fr); } .canvas-surround { min-height: 390px; padding: 16px; } .below-canvas { grid-template-columns: 1fr; } }
@media (max-width: 710px) { .masthead { padding: 0 18px; height: 72px; } .header-actions { gap: 7px; } .version-pill { display: none; } .layout { display: block; } .sidebar { border-right: 0; border-bottom: 1px solid var(--line); } .sidebar-scroll { padding: 23px 22px; } .intro h1 { font-size: 28px; } .workspace { padding: 24px 17px; } .preset-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } .work-header h2 { font-size: 28px; } .canvas-hint { display: none; } .footer { flex-wrap: wrap; } }
@media (max-width: 410px) { .masthead { gap: 10px; } .header-link { font-size: 10px; } .brand-text strong { font-size: 19px; } .work-header-buttons { flex-wrap: wrap; } .preset-list { grid-template-columns: repeat(2, minmax(0,1fr)); } .visual-toolbar { padding: 0 9px; } .visual-toolbar-right { gap: 4px; font-size: 10px; } .visual-heading { gap: 5px; } }
@media (prefers-reduced-motion: reduce) { .loader { animation: none; } .preset, .field input, .field select { transition: none; } }


/* --------------------------------------------------------------------------
 * Living background — FracGen v1.1
 *
 * The artwork is sampled from the completed fractal canvas, not calculated
 * separately. Black pixels are made transparent in the downscaled wallpaper,
 * leaving brighter fractal filaments on the white interface.
 * The entire effect is cosmetic: it never affects the exported PNG.
 * -------------------------------------------------------------------------- */
:root {
  --ambient-artwork: none;
  --ambient-opacity: 0;
  --ambient-panel-opacity: 0;
}

.workspace {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: #fff;
}
.workspace > :not(.ambient-backdrop) {
  position: relative;
  z-index: 1;
}
.ambient-backdrop {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  top: -160px;
  right: -170px;
  width: min(1150px, 120%);
  height: 1120px;
  background-image: var(--ambient-artwork);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--ambient-opacity);
  filter: saturate(1.2) contrast(1.08) blur(.7px);
  transform: rotate(-18deg) scale(1.12);
  transform-origin: center;
  -webkit-mask-image: radial-gradient(ellipse 66% 57% at 54% 44%, #000 8%, rgb(0 0 0 / 88%) 40%, transparent 98%);
  mask-image: radial-gradient(ellipse 66% 57% at 54% 44%, #000 8%, rgb(0 0 0 / 88%) 40%, transparent 98%);
  transition: opacity .3s ease;
}
.workspace[data-ambient-style="texture"] .ambient-backdrop {
  filter: saturate(1.35) contrast(1.16);
  transform: rotate(-6deg) scale(1.06);
  -webkit-mask-image: radial-gradient(ellipse 75% 69% at 55% 47%, #000 10%, transparent 100%);
  mask-image: radial-gradient(ellipse 75% 69% at 55% 47%, #000 10%, transparent 100%);
}

.ambient-console {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: -7px 0 23px;
  padding: 13px 16px;
  border: 1px solid #e7e0f2;
  border-radius: 11px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 4px 28px rgb(87 57 140 / 5%);
}
.ambient-description {
  display: flex;
  align-items: center;
  gap: 11px;
}
.ambient-symbol {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  background: #f2eafb;
  color: #7654be;
  font-size: 22px;
}
.ambient-description strong {
  color: #4d3f67;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.ambient-new {
  border-radius: 4px;
  background: #efe9fb;
  color: #7854b4;
  padding: 3px 5px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .8px;
}
.ambient-description small {
  display: block;
  margin-top: 3px;
  color: #8b879a;
  font-size: 10px;
}
.ambient-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.ambient-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  color: #514961;
  cursor: pointer;
}
.ambient-checkbox input {
  width: 15px;
  height: 15px;
  accent-color: #7551b5;
  cursor: pointer;
}
.ambient-control-label {
  color: #888496;
  font-size: 10px;
  font-weight: 650;
}
#ambientStrength {
  width: 92px;
  accent-color: #7752bd;
  cursor: pointer;
}
#ambientStrengthValue {
  width: 31px;
  font-size: 10px;
  color: #645185;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
#ambientStyle {
  height: 30px;
  max-width: 105px;
  padding: 0 7px;
  color: #645185;
  background: #fff;
  border: 1px solid #e0d8ee;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}
.ambient-controls :disabled {
  opacity: .45;
  cursor: not-allowed;
}

.canvas-surround {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.canvas-surround::before {
  content: "";
  pointer-events: none;
  position: absolute;
  z-index: 0;
  inset: -25%;
  background-image: var(--ambient-artwork);
  background-position: center 43%;
  background-size: cover;
  background-repeat: no-repeat;
  filter: saturate(1.3) contrast(1.05) blur(4px);
  opacity: var(--ambient-panel-opacity);
  transform: scale(1.08);
  transition: opacity .3s ease;
}
.canvas-wrap {
  z-index: 1;
}
.info-card {
  background: rgb(255 255 255 / 95%);
}

@media (max-width: 1000px) {
  .ambient-console { align-items: flex-start; }
  .ambient-controls { width: 100%; }
  .ambient-backdrop { right: -330px; width: 1150px; }
}
@media (max-width: 710px) {
  .ambient-console { padding: 13px; }
  .ambient-backdrop { top: 0; right: -450px; opacity: calc(var(--ambient-opacity) * .65); }
  .ambient-control-label { display: none; }
  .ambient-controls { gap: 11px; }
  .ambient-description small { line-height: 1.3; }
}
@media (prefers-reduced-motion: reduce) {
  .ambient-backdrop, .canvas-surround::before { transition: none; }
}
