:root {
  --bg: #0d0d0f;
  --panel: rgba(22, 22, 25, 0.74);
  --panel-solid: #17171a;
  --line: rgba(255,255,255,0.11);
  --line-strong: rgba(255,255,255,0.19);
  --text: #f4f0e8;
  --muted: #8e8a84;
  --acid: #dfff63;
  --coral: #ff6d59;
  --blue: #9bc4ff;
  --shadow: 0 24px 80px rgba(0,0,0,0.42);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 82% 8%, rgba(155,196,255,0.08), transparent 28%),
    radial-gradient(circle at 12% 28%, rgba(255,109,89,0.06), transparent 30%),
    var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, textarea, input { font: inherit; }
button { color: inherit; }
button, input[type="range"] { touch-action: manipulation; }

.ambient { position: fixed; inset: auto; pointer-events: none; filter: blur(80px); opacity: .28; }
.ambient-a { width: 180px; height: 180px; top: 18vh; right: -80px; background: var(--acid); border-radius: 44% 56% 31% 69%; }
.ambient-b { width: 150px; height: 150px; bottom: 12vh; left: -90px; background: var(--coral); border-radius: 70% 30% 64% 36%; }

.shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(34px, env(safe-area-inset-bottom));
}

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 22px; height: 22px; border: 1px solid var(--line-strong); border-radius: 50%; position: relative; }
.brand-mark::after { content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--acid); top: 2px; right: 2px; box-shadow: 0 0 18px rgba(223,255,99,.5); }
.brand-name { font-size: 13px; letter-spacing: .18em; font-weight: 700; }
.brand-code { font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); margin-top: 2px; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 14px; cursor: pointer; }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.45; }

.input-zone { position: relative; margin-bottom: 18px; }
.ghost-label, .tiny-label { display: block; font: 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; color: var(--muted); }
.ghost-label { position: absolute; top: 14px; left: 15px; z-index: 1; }
#seedInput {
  width: 100%; min-height: 88px; resize: vertical; color: var(--text);
  border: 1px solid var(--line); border-radius: 20px; outline: none;
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.018));
  padding: 36px 15px 15px; font-size: 17px; line-height: 1.45; box-shadow: inset 0 1px rgba(255,255,255,.025);
}
#seedInput::placeholder { color: #57555a; }
#seedInput:focus { border-color: rgba(223,255,99,.42); box-shadow: 0 0 0 3px rgba(223,255,99,.05); }

.seg-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
.seg-block { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 12px; backdrop-filter: blur(18px); }
.seg-block .tiny-label { margin: 1px 3px 10px; }
.segmented { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; }
.segmented button { border: 0; border-radius: 11px; padding: 11px 5px; background: transparent; color: #77747a; font-size: 11px; font-weight: 730; letter-spacing: .08em; cursor: pointer; transition: .18s ease; }
.segmented button.is-active { background: #f0ece3; color: #121214; box-shadow: 0 6px 24px rgba(0,0,0,.22); }

.control-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
.field-card, .length-card { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 14px; backdrop-filter: blur(18px); }
.field-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font: 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; color: var(--muted); }

.weight-pad { position: relative; height: 174px; border: 1px solid rgba(255,255,255,.08); border-radius: 14px; overflow: hidden; cursor: crosshair; outline: none; background: linear-gradient(135deg, rgba(223,255,99,.025), transparent 40%, rgba(155,196,255,.04)); }
.weight-pad:focus-visible { box-shadow: 0 0 0 3px rgba(223,255,99,.08); }
.gridline { position: absolute; background: rgba(255,255,255,.055); pointer-events: none; }
.g1,.g2 { height: 1px; left: 0; right: 0; }
.g1 { top: 33.333%; } .g2 { top: 66.666%; }
.v1,.v2 { width: 1px; top: 0; bottom: 0; }
.v1 { left: 33.333%; } .v2 { left: 66.666%; }
.weight-puck { position: absolute; width: 30px; height: 30px; transform: translate(-50%,-50%); border-radius: 50%; border: 1px solid rgba(223,255,99,.75); background: rgba(13,13,15,.78); box-shadow: 0 0 0 7px rgba(223,255,99,.06), 0 6px 20px rgba(0,0,0,.5); pointer-events: none; transition: box-shadow .15s ease; }
.weight-puck span { position: absolute; width: 6px; height: 6px; background: var(--acid); border-radius: 50%; top: 50%; left: 50%; transform: translate(-50%,-50%); box-shadow: 0 0 12px rgba(223,255,99,.8); }
.corner { position: absolute; font: 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; color: #5c595f; pointer-events: none; }
.c1 { left: 8px; top: 8px; } .c2 { right: 8px; top: 8px; } .c3 { left: 8px; bottom: 8px; } .c4 { right: 8px; bottom: 8px; }

.switch-stack { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch-row { min-height: 82px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 14px; display: flex; justify-content: space-between; align-items: center; text-align: left; cursor: pointer; backdrop-filter: blur(18px); }
.switch-row > span:first-child { display: flex; flex-direction: column; gap: 7px; font-size: 12px; letter-spacing: .08em; font-weight: 700; }
.switch-row small { font: 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); letter-spacing: .15em; }
.switch-row b { font: inherit; }
.range-open { display: none; }
#sensitiveToggle.is-on .range-clean { display: none; }
#sensitiveToggle.is-on .range-open { display: inline; color: var(--coral); }
.switch { width: 34px; height: 20px; padding: 3px; border-radius: 999px; background: #2b2b2f; border: 1px solid rgba(255,255,255,.08); transition: .18s ease; flex: 0 0 auto; }
.switch i { display: block; width: 12px; height: 12px; border-radius: 50%; background: #77747a; transition: .18s ease; }
.switch-row.is-on .switch { background: rgba(223,255,99,.13); border-color: rgba(223,255,99,.24); }
.switch-row.is-on .switch i { transform: translateX(14px); background: var(--acid); box-shadow: 0 0 10px rgba(223,255,99,.36); }
#sensitiveToggle.is-on .switch { background: rgba(255,109,89,.12); border-color: rgba(255,109,89,.23); }
#sensitiveToggle.is-on .switch i { background: var(--coral); box-shadow: 0 0 10px rgba(255,109,89,.32); }

.length-card { margin-bottom: 13px; }
.length-input-wrap { display: flex; align-items: center; gap: 5px; }
.length-input-wrap input { width: 72px; color: var(--text); text-align: right; border: 0; outline: none; background: transparent; font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.length-input-wrap span { color: #5f5c62; }
.length-range { width: 100%; height: 24px; margin: 0; appearance: none; background: transparent; }
.length-range::-webkit-slider-runnable-track { height: 3px; border-radius: 99px; background: linear-gradient(90deg, var(--acid), #403f43 18%); }
.length-range::-webkit-slider-thumb { appearance: none; width: 22px; height: 22px; border-radius: 50%; margin-top: -9px; background: #efebe2; border: 5px solid #141416; box-shadow: 0 0 0 1px rgba(255,255,255,.23); }
.length-range::-moz-range-track { height: 3px; border-radius: 99px; background: #403f43; }
.length-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #efebe2; border: 4px solid #141416; }
.range-ends { display: flex; justify-content: space-between; color: #555259; font: 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: 2px; }

.cast-button { position: relative; width: 100%; height: 62px; border: 0; border-radius: 18px; overflow: hidden; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 10px; color: #101012; background: var(--acid); font-size: 13px; font-weight: 820; letter-spacing: .15em; box-shadow: 0 14px 35px rgba(223,255,99,.12); margin-bottom: 14px; }
.cast-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.cast-orbit { position: absolute; width: 150px; height: 150px; left: -60px; top: -95px; border: 1px solid rgba(0,0,0,.16); border-radius: 50%; }
.cast-button.pulse { animation: castPulse .28s ease; }
@keyframes castPulse { 50% { transform: scale(.985); filter: brightness(1.08); } }

.output-card { position: relative; border: 1px solid var(--line); border-radius: 22px; background: rgba(240,236,227,.96); color: #1c1b1e; overflow: hidden; box-shadow: var(--shadow); }
.output-meta { display: flex; gap: 8px; align-items: center; padding: 13px 14px 10px; border-bottom: 1px solid rgba(0,0,0,.09); color: #6a6662; font: 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .11em; }
.output-meta span:last-child { margin-left: auto; }
.output-text { min-height: 190px; max-height: 52vh; overflow-y: auto; padding: 19px 16px 72px; font: 15.5px/1.63 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -.015em; white-space: pre-wrap; overflow-wrap: anywhere; scrollbar-width: thin; }
.output-actions { position: absolute; right: 12px; bottom: 12px; }
.copy-button { min-width: 94px; height: 40px; border-radius: 12px; border: 1px solid rgba(0,0,0,.12); background: rgba(255,255,255,.62); color: #252327; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 10px; font-weight: 780; letter-spacing: .11em; cursor: pointer; backdrop-filter: blur(12px); }
.copy-button svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.copy-done { display: none; }
.copy-button[data-state="copied"] .copy-default { display: none; }
.copy-button[data-state="copied"] .copy-done { display: inline; }

footer { display: flex; justify-content: space-between; margin: 18px 2px 0; color: #555259; font: 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; }

.history-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.42); backdrop-filter: blur(4px); z-index: 19; opacity: 0; pointer-events: none; transition: opacity .22s ease; }
.history-backdrop.is-open { opacity: 1; pointer-events: auto; }
.history-panel { position: fixed; z-index: 20; right: 0; top: 0; bottom: 0; width: min(92vw, 460px); background: rgba(17,17,20,.96); border-left: 1px solid var(--line); transform: translateX(102%); transition: transform .24s cubic-bezier(.2,.8,.2,1); backdrop-filter: blur(24px); display: flex; flex-direction: column; padding: max(17px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); }
.history-panel.is-open { transform: translateX(0); }
.history-head { display: flex; align-items: center; justify-content: space-between; padding: 3px 3px 14px; border-bottom: 1px solid var(--line); }
.history-head strong { display: block; margin-top: 5px; font-size: 14px; letter-spacing: .12em; }
.history-head-actions { display: flex; align-items: center; gap: 8px; }
.history-head-actions > button:first-child { border: 0; background: transparent; color: #6c6970; font: 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; cursor: pointer; }
.history-head .icon-button { font-size: 22px; line-height: 1; }
.history-list { overflow-y: auto; padding: 12px 0 30px; display: grid; gap: 8px; }
.history-item { border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); padding: 12px; text-align: left; cursor: pointer; }
.history-meta { display: block; color: #67646a; font: 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; margin-bottom: 7px; }
.history-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: #bbb6ae; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.history-empty { padding: 44px 10px; text-align: center; color: #4c494e; font: 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; }
body.drawer-open { overflow: hidden; }

@media (min-width: 640px) {
  .shell { padding-left: 24px; padding-right: 24px; }
  .seg-grid { grid-template-columns: 1fr 1fr; }
  .control-grid { grid-template-columns: 1.35fr .85fr; }
  .switch-stack { grid-template-columns: 1fr; }
  .weight-pad { height: 188px; }
  .switch-row { min-height: 88px; }
  .output-text { min-height: 230px; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
