:root {
  color-scheme: dark;
  --ink: #eef5ff;
  --muted: #9aa8bc;
  --panel: #121c2c;
  --panel-2: #172338;
  --line: #2a3850;
  --accent: #59e6a8;
  --accent-2: #92ffd0;
  --danger: #ff8a7a;
  --bg: #09111d;
  --shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); }
body { margin: 0; min-width: 320px; color: var(--ink); background: radial-gradient(circle at 12% 0%, #142844 0, transparent 34rem), var(--bg); }
button, input { font: inherit; }
button { color: inherit; }

.topbar {
  min-height: 68px;
  padding: 12px clamp(16px, 3vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 17, 29, .88);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; padding: 5px; border: 1px solid #6bffd0; background: #122b28; box-shadow: 0 0 24px rgba(89, 230, 168, .18); }
.brand-mark i { background: var(--accent); }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { opacity: .45; }
.truth-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.truth-row span { padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: #c4d1e3; font-size: .78rem; font-weight: 700; }

.workspace { padding: clamp(16px, 3vw, 40px); }
.editor-shell { max-width: 1480px; margin: 0 auto; border: 1px solid var(--line); background: rgba(15, 25, 41, .94); box-shadow: var(--shadow); }
.editor-head { padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: .74rem; font-weight: 900; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.45rem); letter-spacing: -.055em; }
.privacy-label { max-width: 620px; display: flex; align-items: center; gap: 10px; color: #cbd7e8; font-size: .92rem; line-height: 1.45; }
.privacy-dot { flex: 0 0 auto; width: 11px; height: 11px; background: var(--accent); box-shadow: 0 0 0 5px rgba(89,230,168,.12); }

.editor-grid { min-height: 690px; display: grid; grid-template-columns: minmax(240px, 300px) minmax(410px, 1fr) minmax(240px, 300px); }
.panel { background: #0f1929; }
.source-panel { border-right: 1px solid var(--line); }
.controls-panel { border-left: 1px solid var(--line); }
.panel-section { padding: 20px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; gap: 11px; align-items: center; margin-bottom: 17px; }
.section-heading .step { width: 32px; height: 32px; display: grid; place-items: center; color: var(--accent); border: 1px solid rgba(89,230,168,.4); font-size: .72rem; font-weight: 900; }
.section-heading strong, .section-heading small { display: block; }
.section-heading strong { font-size: .96rem; }
.section-heading small { margin-top: 2px; color: var(--muted); font-size: .76rem; line-height: 1.35; }

.upload-button { display: flex; flex-direction: column; gap: 8px; min-height: 104px; justify-content: center; align-items: center; cursor: pointer; border: 1px dashed #59708d; background: #121f32; transition: .18s ease; }
.upload-button:hover, .upload-button:focus-within { border-color: var(--accent); background: #152a37; }
.upload-button span { font-weight: 800; }
.upload-button b { color: var(--accent); font-size: .78rem; }
.field-note { color: var(--muted); font-size: .74rem; line-height: 1.5; }
.blank-size { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 12px; }
.blank-size button, .segmented button, .tool-group button { min-height: 38px; border: 1px solid var(--line); background: #172338; cursor: pointer; }
.blank-size button:hover, .tool-group button:hover { border-color: #5d718c; }
.blank-size button.active, .segmented button.active, .tool.active { color: #071710; border-color: var(--accent); background: var(--accent); font-weight: 900; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.segmented button { cursor: pointer; }
.switch-row { display: grid; grid-template-columns: auto 1fr; column-gap: 11px; align-items: center; margin-top: 16px; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { grid-row: span 2; width: 42px; height: 24px; border: 1px solid #53647d; background: #243248; position: relative; transition: .18s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #9cabc0; transition: .18s; }
.switch-row input:checked + .switch { background: #173c32; border-color: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(18px); background: var(--accent); }
.switch-row b, .switch-row small { display: block; }
.switch-row b { font-size: .86rem; }
.switch-row small { color: var(--muted); font-size: .72rem; line-height: 1.35; }
.compact-stats { display: grid; gap: 13px; }
.compact-stats div { display: flex; justify-content: space-between; gap: 12px; }
.compact-stats span { color: var(--muted); font-size: .76rem; }
.compact-stats b { text-align: right; font-size: .78rem; overflow-wrap: anywhere; }

.canvas-panel { min-width: 0; display: flex; flex-direction: column; background: #0b1422; overflow: hidden; }
.canvas-toolbar { min-height: 66px; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.tool-group { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-group button { padding: 0 12px; font-size: .8rem; }
.tool-group button:disabled { opacity: .38; cursor: not-allowed; }
.canvas-frame { position: relative; flex: 1; min-height: 520px; display: grid; place-items: center; overflow: auto; padding: 26px; background-color: #111b2a; background-image: linear-gradient(45deg,#172337 25%,transparent 25%),linear-gradient(-45deg,#172337 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#172337 75%),linear-gradient(-45deg,transparent 75%,#172337 75%); background-size: 24px 24px; background-position: 0 0,0 12px,12px -12px,-12px 0; touch-action: none; }
#skinCanvas { image-rendering: pixelated; image-rendering: crisp-edges; width: 640px; height: 640px; max-width: none; background: transparent; box-shadow: 0 0 0 1px #6d7c91, 0 24px 70px rgba(0,0,0,.45); cursor: crosshair; touch-action: none; }
.canvas-frame.grid-on #skinCanvas { background-image: linear-gradient(rgba(124,145,173,.2) 1px,transparent 1px),linear-gradient(90deg,rgba(124,145,173,.2) 1px,transparent 1px); }
.layer-mask { position: absolute; pointer-events: none; color: var(--accent); font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; }
.canvas-foot { min-height: 43px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); border-top: 1px solid var(--line); font-size: .75rem; }

.color-row { display: grid; grid-template-columns: auto 46px 1fr; align-items: center; gap: 10px; margin-bottom: 20px; }
.color-row > span, .range-row b { color: #cbd7e8; font-size: .82rem; }
#colorPicker { width: 46px; height: 38px; padding: 2px; border: 1px solid var(--line); background: #101a2a; cursor: pointer; }
#hexColor { min-width: 0; height: 38px; padding: 0 10px; color: var(--ink); border: 1px solid var(--line); background: #0d1726; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; text-transform: uppercase; }
.range-row { display: block; margin-top: 18px; }
.range-row > span { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.range-row output { color: var(--accent); font-size: .78rem; font-weight: 800; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.export-card { background: linear-gradient(150deg,#142b31,#101a2a 70%); }
.download-button { width: 100%; min-height: 50px; border: 0; background: var(--accent); color: #071710; font-weight: 950; cursor: pointer; box-shadow: 0 10px 30px rgba(89,230,168,.12); }
.download-button:hover { background: var(--accent-2); }
.export-card p { margin: 10px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.45; }
.status { margin: 18px 20px; padding: 12px; border-left: 3px solid var(--accent); background: #121f31; color: #cbd7e8; font-size: .78rem; line-height: 1.4; }
.status.error { border-color: var(--danger); color: #ffd5cf; }

.site-footer { max-width: 1480px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 40px) 34px; display: flex; justify-content: space-between; gap: 18px; color: var(--muted); font-size: .82rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 18px; }
.site-footer a { color: #cbd7e8; text-decoration: none; }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--accent); }
.content-page { width: min(860px, calc(100% - 32px)); margin: 44px auto; padding: clamp(24px, 5vw, 56px); border: 1px solid var(--line); background: rgba(15,25,41,.96); box-shadow: var(--shadow); }
.content-page h1 { margin-bottom: 24px; }
.content-page h2 { margin: 30px 0 10px; font-size: 1.12rem; }
.content-page p, .content-page li { color: #cbd7e8; line-height: 1.75; }
.content-page a { color: var(--accent); }
.content-page .back-link { display: inline-block; margin-bottom: 28px; text-decoration: none; font-weight: 800; }

button:focus-visible, input:focus-visible, label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 1050px) {
  .editor-grid { grid-template-columns: 260px 1fr; }
  .controls-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr auto; border-left: 0; border-top: 1px solid var(--line); }
  .controls-panel .panel-section { border-bottom: 0; border-right: 1px solid var(--line); }
  .status { align-self: center; }
}

@media (max-width: 760px) {
  .topbar, .editor-head { align-items: flex-start; flex-direction: column; }
  .truth-row { justify-content: flex-start; }
  .workspace { padding: 0; }
  .editor-shell { border-left: 0; border-right: 0; }
  .editor-grid { display: flex; flex-direction: column; }
  .source-panel, .controls-panel { border: 0; }
  .source-panel { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
  .source-panel .compact-stats { grid-column: 1 / -1; }
  .source-panel .panel-section:first-child { border-right: 1px solid var(--line); }
  .canvas-toolbar { align-items: flex-start; flex-direction: column; }
  .canvas-frame { min-height: 72vw; padding: 16px; justify-content: start; }
  .controls-panel { display: block; }
  .controls-panel .panel-section { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 520px) {
  .brand { font-size: .94rem; }
  .truth-row span { font-size: .68rem; }
  .editor-head, .panel-section { padding: 16px; }
  .source-panel { display: block; }
  .source-panel .panel-section:first-child { border-right: 0; }
  .canvas-frame { min-height: 92vw; padding: 12px; }
  .canvas-foot { align-items: flex-start; flex-direction: column; justify-content: center; }
  .tool-group button { min-height: 42px; }
  .site-footer { align-items: flex-start; flex-direction: column; }
  .site-footer a { padding: 8px 0; }
  .content-page { width: 100%; margin: 0; border-left: 0; border-right: 0; }
}

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