:root {
  color-scheme: dark;
  --bg: #060912;
  --panel: rgba(16, 22, 38, 0.92);
  --panel-2: rgba(23, 31, 50, 0.9);
  --line: rgba(163, 188, 235, 0.16);
  --line-strong: rgba(155, 207, 255, 0.34);
  --text: #f5f8ff;
  --muted: #a7b2c8;
  --dim: #758199;
  --cyan: #66e5ff;
  --violet: #b48cff;
  --gold: #ffd77b;
  --radius: 20px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
  font-family: Inter, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); min-height: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 14% -10%, rgba(56, 89, 157, 0.24), transparent 33rem),
    radial-gradient(circle at 92% 4%, rgba(114, 47, 154, 0.18), transparent 28rem),
    linear-gradient(180deg, #080d19 0%, #05070d 100%);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; }
button, select, input[type="range"], input[type="color"] { touch-action: manipulation; }
button { color: inherit; }
.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  border-bottom: 1px solid rgba(172, 207, 255, 0.13);
  background: rgba(6, 9, 18, 0.9);
  backdrop-filter: blur(18px) saturate(140%);
}
.brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  padding: 5px;
  background: conic-gradient(from 220deg, #67e5ff, #685dff, #d371ff, #ffcf6e, #67e5ff);
  box-shadow: 0 0 22px rgba(103, 214, 255, 0.3);
}
.brand-mark::before, .brand-mark span { position: absolute; border-radius: 50%; content: ""; }
.brand-mark::before { inset: 4px; background: #080c16; }
.brand-mark span { inset: 11px; border: 2px solid rgba(237, 247, 255, 0.94); }
.brand-copy { min-width: 0; }
.brand-copy h1 { margin: 0; font-size: 1rem; line-height: 1.25; letter-spacing: 0.02em; }
.brand-copy p { margin: 0; color: var(--dim); font-size: 0.7rem; line-height: 1.2; letter-spacing: 0.14em; text-transform: uppercase; }
.quality-badge {
  margin-left: auto;
  padding: 6px 9px;
  border: 1px solid rgba(102, 229, 255, 0.25);
  border-radius: 999px;
  color: #baf4ff;
  background: rgba(62, 172, 206, 0.1);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.workspace { width: min(1180px, 100%); margin: 0 auto; padding: 12px 12px max(42px, env(safe-area-inset-bottom)); }
.preview-panel {
  position: sticky;
  top: 60px;
  z-index: 50;
  margin: 0 auto 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(9, 13, 24, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.preview-heading, .section-heading, .slider-control > span, .preview-bottom, .quick-actions { display: flex; align-items: center; }
.preview-heading { justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.preview-heading > div:first-child { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.preview-heading strong { overflow: hidden; font-size: 0.95rem; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.eyebrow { color: var(--cyan); font-size: 0.65rem; font-weight: 800; letter-spacing: 0.15em; }
.seed-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-variant-numeric: tabular-nums;
}
.seed-chip span { color: var(--dim); font-size: 0.58rem; letter-spacing: 0.1em; }
.seed-chip output { font-size: 0.72rem; font-weight: 750; }
.canvas-frame {
  position: relative;
  overflow: hidden;
  width: min(100%, 43vh);
  max-width: 540px;
  aspect-ratio: 1;
  margin: 0 auto;
  border: 1px solid rgba(197, 220, 255, 0.24);
  border-radius: 16px;
  background: #02040a;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
#artCanvas { display: block; width: 100%; height: 100%; }
.preview-mask, .ring-guide, .ring-guide span { position: absolute; inset: 0; pointer-events: none; }
.preview-mask { opacity: 0; transition: opacity 180ms ease; }
.canvas-frame[data-preview="circle"] .preview-mask {
  opacity: 1;
  background: radial-gradient(circle at center, transparent 0 48.2%, rgba(2, 4, 10, 0.94) 48.8% 100%);
}
.canvas-frame[data-preview="ring"] .preview-mask {
  opacity: 1;
  background: radial-gradient(circle at center, rgba(4, 6, 12, 0.94) 0 31.5%, transparent 32.2% 48.1%, rgba(2, 4, 10, 0.94) 48.8% 100%);
}
.ring-guide { opacity: 0; transition: opacity 180ms ease; }
.canvas-frame[data-preview="circle"] .ring-guide, .canvas-frame[data-preview="ring"] .ring-guide { opacity: 1; }
.ring-guide span {
  margin: auto;
  border: 1px solid rgba(233, 243, 255, 0.56);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}
.ring-guide-outer { width: 97%; height: 97%; }
.ring-guide-inner { display: none; width: 64%; height: 64%; }
.canvas-frame[data-preview="ring"] .ring-guide-inner { display: block; }
.render-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: linear-gradient(135deg, #161b2a, #090b12);
}
.render-fallback span { color: var(--muted); font-size: 0.88rem; line-height: 1.6; }
.preview-bottom { justify-content: space-between; gap: 10px; margin-top: 9px; }
.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  min-width: 188px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}
.segmented button {
  min-height: 32px;
  padding: 4px 10px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.segmented button.is-active {
  color: #07111d;
  background: linear-gradient(135deg, #bff5ff, #7fddf6);
  box-shadow: 0 4px 14px rgba(88, 216, 247, 0.18);
}
.preview-note { color: var(--dim); font-size: 0.68rem; line-height: 1.35; text-align: right; }
.quick-actions { gap: 9px; margin-top: 9px; }
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 43px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}
.action-random { width: 42%; border: 1px solid rgba(174, 203, 250, 0.22); background: rgba(255, 255, 255, 0.055); }
.action-save {
  flex: 1;
  border: 1px solid rgba(142, 234, 255, 0.42);
  color: #06101b;
  background: linear-gradient(135deg, #c1f6ff 0%, #6ddff8 52%, #a4b5ff 100%);
  box-shadow: 0 10px 24px rgba(74, 203, 235, 0.2);
}
.action-icon { font-size: 1.05rem; line-height: 1; }
.control-panel { display: grid; gap: 14px; }
.control-section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(23, 31, 50, 0.92), rgba(12, 17, 30, 0.94));
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.2);
}
.section-heading { justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-heading > div { display: flex; align-items: center; gap: 9px; }
.section-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(102, 229, 255, 0.26);
  border-radius: 8px;
  color: var(--cyan);
  background: rgba(102, 229, 255, 0.07);
  font-size: 0.69rem;
  font-weight: 850;
}
.section-heading h2 { margin: 0; font-size: 1rem; }
.section-hint, .text-button { color: var(--dim); font-size: 0.75rem; }
.text-button { min-height: 34px; padding: 4px 8px; border: 0; background: transparent; cursor: pointer; }
.preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.preset-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 66px;
  padding: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
}
.preset-card.is-active {
  border-color: rgba(102, 229, 255, 0.52);
  background: linear-gradient(135deg, rgba(76, 203, 235, 0.13), rgba(138, 101, 241, 0.1));
  box-shadow: inset 0 0 0 1px rgba(102, 229, 255, 0.1);
}
.preset-art {
  display: block;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.preset-galaxy {
  background: radial-gradient(ellipse at 38% 56%, transparent 0 11%, rgba(123, 93, 201, 0.75) 19%, transparent 38%), radial-gradient(ellipse at 66% 38%, rgba(110, 220, 255, 0.85), transparent 23%), #030816;
}
.preset-lacquer {
  background: radial-gradient(circle at 20% 24%, #ffd777 0 3%, transparent 4%), radial-gradient(circle at 66% 68%, #e5a831 0 5%, transparent 6%), linear-gradient(132deg, #210006, #9e071e 44%, #3e000b 68%, #db1638);
}
.preset-aurora {
  background: radial-gradient(circle at 70% 10%, #ffdc4f, transparent 42%), radial-gradient(circle at 8% 14%, #d0006f, transparent 48%), radial-gradient(circle at 83% 90%, #155ab4, transparent 49%), #7d2d92;
}
.preset-geometric {
  background: linear-gradient(150deg, transparent 34%, rgba(2, 34, 83, 0.78) 35% 48%, transparent 49%), radial-gradient(circle at 8% 8%, #a8faff, transparent 50%), #0d3d75;
}
.preset-nebula {
  background: radial-gradient(circle at 77% 20%, rgba(119, 235, 244, 0.95), transparent 29%), radial-gradient(circle at 56% 67%, rgba(244, 48, 181, 0.92), transparent 42%), radial-gradient(circle at 12% 80%, #2337c8, transparent 48%), #220833;
}
.preset-eclipse {
  background: radial-gradient(circle at 52% 50%, #020204 0 34%, #ff7512 37%, rgba(255, 142, 24, 0.25) 42%, transparent 55%), radial-gradient(circle at 82% 48%, #ce2b18, transparent 42%), #10142b;
}
.preset-pastel {
  background: radial-gradient(circle at 78% 22%, #f4acd2, transparent 45%), radial-gradient(circle at 22% 24%, #76ddd6, transparent 48%), radial-gradient(circle at 53% 78%, #aaa9e8, transparent 52%), #f4efbc;
}
.preset-gold-dust {
  background: radial-gradient(circle at 72% 22%, rgba(255, 210, 80, 0.95) 0 3%, transparent 5%), radial-gradient(circle at 30% 72%, rgba(238, 159, 34, 0.88) 0 2%, transparent 4%), radial-gradient(ellipse at 72% 20%, #8b4c0b, transparent 55%), #100703;
}
.preset-amber {
  background: radial-gradient(circle at 18% 12%, #fff1a0, transparent 42%), linear-gradient(145deg, transparent 39%, rgba(255, 239, 139, 0.82) 43%, transparent 48%), linear-gradient(130deg, #ffcf2b, #f36b00 72%);
}
.preset-silver-river {
  background: radial-gradient(ellipse at 54% 54%, rgba(245, 239, 255, 0.9), transparent 8%), linear-gradient(132deg, transparent 37%, rgba(153, 166, 218, 0.22) 39%, rgba(227, 220, 246, 0.85) 48%, rgba(80, 100, 157, 0.42) 57%, transparent 62%), radial-gradient(circle at 18% 24%, rgba(255, 255, 255, 0.74) 0 1%, transparent 2%), #07152d;
}
.preset-creation-pillars {
  background: radial-gradient(circle at 72% 18%, rgba(156, 238, 233, 0.82), transparent 22%), radial-gradient(ellipse at 53% 93%, rgba(190, 70, 40, 0.94), transparent 48%), radial-gradient(ellipse at 24% 72%, rgba(111, 42, 32, 0.88), transparent 36%), radial-gradient(ellipse at 72% 64%, rgba(144, 61, 39, 0.76), transparent 28%), linear-gradient(145deg, #02080e, #0d3c4b 52%, #03131c);
}
.preset-star-lake {
  background: linear-gradient(172deg, transparent 0 58%, rgba(2, 3, 10, 0.95) 59% 67%, transparent 68%), linear-gradient(90deg, transparent 37%, rgba(225, 214, 255, 0.74) 48% 53%, transparent 64%), linear-gradient(180deg, #091330 0 58%, #130d2c 59% 76%, #05050c 100%);
}
.preset-violet-river {
  background: radial-gradient(ellipse at 39% 64%, rgba(247, 218, 242, 0.87), transparent 15%), linear-gradient(108deg, transparent 22%, rgba(95, 73, 143, 0.55) 30%, rgba(220, 186, 225, 0.8) 46%, rgba(31, 25, 65, 0.9) 54%, rgba(126, 96, 166, 0.42) 63%, transparent 74%), #080b25;
}
.preset-stellar-bloom {
  background: radial-gradient(ellipse at 35% 52%, rgba(226, 255, 255, 0.96), transparent 18%), radial-gradient(ellipse at 54% 48%, rgba(241, 71, 190, 0.88), transparent 43%), radial-gradient(circle at 82% 62%, rgba(24, 191, 224, 0.74), transparent 34%), #041729;
}
.preset-copy { min-width: 0; }
.preset-copy strong, .preset-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-copy strong { font-size: 0.85rem; }
.preset-copy small { margin-top: 3px; color: var(--dim); font-size: 0.66rem; }
.preset-check {
  position: absolute;
  top: 6px;
  right: 7px;
  display: none;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  color: #071018;
  background: var(--cyan);
  font-size: 0.7rem;
  font-weight: 900;
}
.preset-card.is-active .preset-check { display: grid; }
.color-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.color-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 55px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}
.color-control input {
  width: 37px;
  height: 37px;
  flex: 0 0 auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}
.color-control input::-webkit-color-swatch-wrapper { padding: 0; }
.color-control input::-webkit-color-swatch { border: 0; }
.color-control span, .color-control small, .color-control output { display: block; }
.color-control small { color: var(--dim); font-size: 0.68rem; }
.color-control output { margin-top: 2px; color: var(--muted); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }
.slider-grid { display: grid; gap: 15px; }
.slider-control { display: block; }
.slider-control > span { justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.slider-control strong { font-size: 0.84rem; }
.slider-control output {
  min-width: 40px;
  padding: 3px 7px;
  border-radius: 6px;
  color: #c8f6ff;
  background: rgba(102, 229, 255, 0.07);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
input[type="range"] { width: 100%; height: 26px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 5px; border-radius: 99px; background: linear-gradient(90deg, rgba(102, 229, 255, 0.58), rgba(180, 140, 255, 0.58)); }
input[type="range"]::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -8.5px;
  appearance: none;
  border: 3px solid #e8fbff;
  border-radius: 50%;
  background: #25bfdf;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 99px; background: linear-gradient(90deg, rgba(102, 229, 255, 0.58), rgba(180, 140, 255, 0.58)); }
input[type="range"]::-moz-range-thumb { width: 17px; height: 17px; border: 3px solid #e8fbff; border-radius: 50%; background: #25bfdf; }
.export-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.export-options label > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.75rem; font-weight: 700; }
select {
  width: 100%;
  min-height: 44px;
  padding: 0 36px 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--text);
  background: #111a2b;
}
.recipe-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 12px; }
.secondary-button {
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}
.export-help { margin: 11px 0 0; color: var(--dim); font-size: 0.75rem; line-height: 1.65; }
.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 5, 10, 0.78);
  backdrop-filter: blur(9px);
}
.busy-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(280px, 90vw);
  padding: 25px;
  border: 1px solid var(--line-strong);
  border-radius: 19px;
  background: #101727;
  box-shadow: var(--shadow);
}
.busy-card small { color: var(--muted); }
.spinner {
  width: 34px;
  height: 34px;
  margin-bottom: 4px;
  border: 3px solid rgba(117, 224, 248, 0.17);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 250;
  max-width: calc(100vw - 30px);
  padding: 11px 16px;
  border: 1px solid rgba(140, 228, 250, 0.3);
  border-radius: 12px;
  opacity: 0;
  color: #eafcff;
  background: rgba(14, 24, 38, 0.95);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.38);
  font-size: 0.83rem;
  font-weight: 700;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
[hidden] { display: none !important; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid rgba(102, 229, 255, 0.62); outline-offset: 2px; }
button:active { transform: translateY(1px); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (min-width: 760px) {
  .topbar { height: 68px; padding-inline: 22px; }
  .brand-copy h1 { font-size: 1.08rem; }
  .workspace {
    display: grid;
    grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
    align-items: start;
    gap: 18px;
    padding: 20px;
  }
  .preview-panel { top: 88px; width: 100%; margin: 0; padding: 16px; }
  .canvas-frame { width: min(100%, 64vh); }
  .control-panel { gap: 18px; }
  .control-section { padding: 20px; }
  .slider-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 22px; }
}
@media (max-width: 380px) {
  .quality-badge { display: none; }
  .workspace { padding-inline: 8px; }
  .preview-panel { padding: 9px; border-radius: 17px; }
  .canvas-frame { width: min(100%, 40vh); }
  .preset-grid { grid-template-columns: 1fr; }
  .preview-note { display: none; }
  .segmented { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
