:root {
  --ink: #11131b;
  --ink-soft: #1a1d27;
  --paper: #f4f0e8;
  --paper-dim: #c7c4bc;
  --line: rgba(244, 240, 232, .16);
  --line-strong: rgba(244, 240, 232, .32);
  --citrus: #d7ff3f;
  --orange: #ff7d53;
  --muted: #92939b;
  --shadow: 0 24px 80px rgba(0, 0, 0, .24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--paper);
  background: var(--ink);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--ink); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 20; background: var(--citrus); color: var(--ink); padding: .7rem 1rem; border-radius: .35rem; font-weight: 800; }
.skip-link:focus { top: 1rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; clip-path: inset(50%); }

.topbar { border-bottom: 1px solid var(--line); }
.topbar-inner { width: min(1440px, calc(100% - 48px)); margin: 0 auto; min-height: 72px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--paper); text-decoration: none; font-size: .88rem; letter-spacing: .02em; font-weight: 800; }
.brand-glyph { display: grid; grid-template-columns: repeat(2, 8px); grid-template-rows: repeat(2, 8px); gap: 3px; transform: rotate(-8deg); }
.brand-glyph span { display: block; background: var(--citrus); }
.brand-glyph span:nth-child(2) { background: var(--orange); }
.brand-glyph span:nth-child(3) { background: var(--paper); }
.privacy-chip { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .72rem; letter-spacing: .04em; }
.privacy-dot { width: .45rem; height: .45rem; border-radius: 50%; background: var(--citrus); box-shadow: 0 0 0 4px rgba(215,255,63,.1); }

.editor-shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 4.2rem 0 5rem; }
.editor-heading { display: flex; justify-content: space-between; align-items: end; gap: 2rem; padding-bottom: 2.4rem; }
.kicker { margin: 0 0 .8rem; color: var(--citrus); font: 700 .7rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2.5rem, 5vw, 5.7rem); line-height: .92; letter-spacing: -.08em; font-weight: 850; }
.heading-note { max-width: 19rem; margin: 0 0 .25rem; color: var(--paper-dim); line-height: 1.5; font-size: .95rem; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 1px; border: 1px solid var(--line); background: var(--line); box-shadow: var(--shadow); }
.stage-column { min-width: 0; padding: clamp(1.1rem, 2.3vw, 2rem); background: #151821; }
.stage-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1rem; }
.stage-label { display: block; color: var(--paper); font-size: .77rem; text-transform: uppercase; letter-spacing: .14em; font-weight: 800; }
.stage-hint { display: block; margin-top: .35rem; color: var(--muted); font-size: .78rem; }
.selected-label { color: var(--citrus); font-size: .76rem; font-weight: 750; }
.canvas-wrap { position: relative; width: min(100%, 720px); margin: 0 auto; background: #0f1117; overflow: hidden; }
#previewCanvas { display: block; width: 100%; height: auto; aspect-ratio: 1; touch-action: none; outline: none; }
#previewCanvas:focus-visible { box-shadow: inset 0 0 0 3px var(--citrus); }
.canvas-empty { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; gap: .55rem; color: var(--paper-dim); pointer-events: none; text-align: center; }
.canvas-empty[hidden] { display: none; }
.canvas-empty strong { color: var(--paper); font-size: 1.05rem; }
.canvas-empty span:last-child { color: var(--muted); font-size: .8rem; }
.empty-mark { display: grid; place-items: center; width: 3rem; height: 3rem; border: 1px solid var(--line-strong); color: var(--citrus); font-size: 1.8rem; line-height: 1; }
.gesture-note { margin-top: .9rem; color: var(--muted); font-size: .73rem; text-align: center; }
.gesture-note span { color: var(--citrus); margin-right: .35rem; }

.control-panel { min-width: 0; background: var(--paper); color: var(--ink); }
.panel-section { padding: 1.35rem 1.4rem; border-bottom: 1px solid rgba(17, 19, 27, .13); }
.panel-section:last-child { border-bottom: 0; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .9rem; }
.section-title-row h2 { margin: 0; font-size: .72rem; letter-spacing: .13em; text-transform: uppercase; font-weight: 900; }
.section-meta { color: #6d6b67; font: 700 .67rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--ink); font-size: .75rem; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.text-button:hover, .text-button:focus-visible { color: #7a4c00; }
.text-button.muted { color: #8d8980; }
.layout-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .45rem; }
.layout-button { display: grid; grid-template-rows: 42px auto; gap: .35rem; min-width: 0; padding: .35rem; border: 1px solid rgba(17,19,27,.18); background: transparent; color: var(--ink); text-align: left; }
.layout-button:hover, .layout-button:focus-visible { background: #ebe6da; outline: none; }
.layout-button.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.layout-button small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .62rem; font-weight: 800; }
.layout-diagram { display: grid; gap: 2px; padding: 3px; background: #d7d0c4; }
.layout-button.active .layout-diagram { background: #353943; }
.layout-diagram span { background: var(--orange); min-width: 0; min-height: 0; }
.layout-diagram.two-horizontal { grid-template-columns: 1fr 1fr; }
.layout-diagram.two-vertical { grid-template-rows: 1fr 1fr; }
.layout-diagram.three-left { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.layout-diagram.three-left span:first-child, .layout-diagram.three-right span:last-child { grid-row: 1 / span 2; }
.layout-diagram.three-right span:last-child { grid-column: 2; }
.layout-diagram.three-top, .layout-diagram.three-bottom { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.layout-diagram.three-top span:first-child, .layout-diagram.three-bottom span:last-child { grid-column: 1 / span 2; }
.layout-diagram.four-grid { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.layout-diagram.nine-grid { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.layout-diagram.sixteen-grid { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }
.fit-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; margin-bottom: 1rem; }
.fit-button { padding: .55rem .4rem; border: 1px solid rgba(17,19,27,.2); background: transparent; color: #65615b; font-size: .7rem; font-weight: 800; }
.fit-button.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.range-row { display: flex; justify-content: space-between; gap: .8rem; margin: .75rem 0 .45rem; color: #4b4945; font-size: .75rem; font-weight: 800; }
.range-row output { color: #89837a; font: 700 .7rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
input[type="range"] { display: block; width: 100%; accent-color: var(--ink); }
.setting-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin-top: 1.05rem; }
.setting-grid label { display: grid; gap: .35rem; color: #4b4945; font-size: .7rem; font-weight: 800; }
.setting-grid input, .setting-grid select { width: 100%; height: 2.25rem; border: 1px solid rgba(17,19,27,.2); background: #fbf8f2; color: var(--ink); padding: .35rem .45rem; }
.setting-grid input[type="color"] { padding: .2rem; }
.download-button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.2rem; padding: .85rem .95rem; border: 0; background: var(--orange); color: var(--ink); font-weight: 900; }
.download-button:hover:not(:disabled), .download-button:focus-visible:not(:disabled) { background: var(--citrus); outline: none; }
.download-button:disabled { cursor: not-allowed; opacity: .4; }
.status { min-height: 2.2em; margin: .7rem 0 0; color: #78736a; font-size: .7rem; line-height: 1.4; }
.status.error { color: #a4361e; }
.status.success { color: #427238; }
.site-footer { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 1.4rem 0 2.4rem; display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .7rem; }
.site-footer a { color: var(--paper-dim); }

@media (max-width: 940px) {
  .workspace { grid-template-columns: 1fr; }
  .control-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-section { border-right: 1px solid rgba(17,19,27,.13); }
  .panel-section:last-child { grid-column: 1 / -1; border-right: 0; }
}
@media (max-width: 640px) {
  .topbar-inner, .editor-shell, .site-footer { width: min(100% - 28px, 560px); }
  .topbar-inner { min-height: 62px; }
  .privacy-chip { font-size: .65rem; }
  .editor-shell { padding-top: 2.4rem; }
  .editor-heading { display: block; padding-bottom: 1.5rem; }
  h1 { font-size: clamp(2.8rem, 15vw, 4.8rem); }
  .heading-note { margin-top: 1rem; font-size: .85rem; }
  .workspace { display: block; }
  .stage-column { padding: .9rem; }
  .control-panel { display: block; }
  .panel-section { border-right: 0; }
  .layout-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .layout-button { grid-template-rows: 36px auto; padding: .25rem; }
  .layout-button small { font-size: .56rem; }
  .site-footer { display: block; line-height: 2; }
  .site-footer a { display: block; }
}
