:root {
  --ink: #392038;
  --ink-soft: #665273;
  --plum: #693e93;
  --lilac: #d8c5e8;
  --mint: #c9eec1;
  --mint-deep: #49bda9;
  --peach: #f7ac87;
  --sun: #ffc45b;
  --paper: #fff9e8;
  --paper-dark: #f2e7d0;
  --line: rgba(57, 32, 56, .16);
  --shadow: 5px 6px 0 rgba(57, 32, 56, .14);
  font-family: "Zen Maru Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  color: var(--ink);
  background: #eadcf0;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 87% 8%, rgba(255, 196, 91, .42), transparent 18rem),
    linear-gradient(135deg, #e4d3ec 0%, #f9efe1 52%, #d4eee1 100%);
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .44; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

.paper-grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .2;
  background-image: radial-gradient(rgba(57, 32, 56, .15) .6px, transparent .6px);
  background-size: 5px 5px;
  mix-blend-mode: multiply;
}

.site-header, .workbench, .site-footer { width: min(1220px, calc(100% - 40px)); margin: 0 auto; }

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 40px 0 24px;
}

.brand-lockup { display: flex; align-items: center; gap: 15px; }
.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  color: var(--paper);
  background: var(--plum);
  border: 2px solid var(--ink);
  border-radius: 13px 5px 14px 5px;
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 27px;
}
.eyebrow, .section-kicker {
  margin: 0 0 5px;
  color: var(--plum);
  font-family: "DotGothic16", monospace;
  font-size: .75rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.site-header h1 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.3rem); line-height: 1.15; letter-spacing: -.06em; }
.header-note { margin: 0; color: var(--ink-soft); text-align: right; font-size: .8rem; line-height: 1.65; }

.intro-panel {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 34%);
  align-items: center;
  gap: 28px;
  min-height: 280px;
  padding: 36px 42px;
  border: 2px solid var(--ink);
  border-radius: 26px 9px 26px 9px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.intro-copy h2 { margin: 0 0 15px; font-size: clamp(1.85rem, 4vw, 3.55rem); line-height: 1.13; letter-spacing: -.09em; }
.intro-copy h2 em { color: var(--plum); font-style: normal; text-decoration: underline; text-decoration-color: var(--sun); text-decoration-thickness: .18em; text-underline-offset: .06em; }
.intro-copy > p:not(.section-kicker) { max-width: 610px; margin: 0; color: var(--ink-soft); font-size: .95rem; line-height: 1.9; }
.feature-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 19px; }
.feature-tags span { padding: 5px 11px; border: 1px solid var(--ink); border-radius: 999px; background: var(--mint); font-family: "DotGothic16", monospace; font-size: .72rem; }
.toolbox-art-wrap { position: relative; min-height: 194px; border: 2px solid var(--ink); border-radius: 47% 10px 10px 47%; background: var(--mint); overflow: hidden; transform: rotate(2deg); }
.toolbox-art-wrap::before { content: ""; position: absolute; inset: 18px; border: 2px dashed rgba(57, 32, 56, .28); border-radius: 40% 9px; }
#toolbox-art { display: block; width: 100%; height: 100%; min-height: 194px; object-fit: cover; opacity: .92; mix-blend-mode: multiply; }
.toolbox-fallback { display: none; }
.toolbox-fallback:not([hidden]) { display: grid; }
#toolbox-art[hidden] { display: none; }
.toolbox-fallback { position: absolute; inset: 0; grid-template-columns: repeat(3, 1fr); place-items: center; color: var(--plum); font-size: 2.2rem; }
.toolbox-fallback span:nth-child(1) { transform: rotate(-20deg) translateY(20px); }
.toolbox-fallback span:nth-child(2) { transform: translateY(-25px); }
.toolbox-fallback span:nth-child(3) { transform: rotate(15deg) translateY(19px); }
.art-caption { position: absolute; right: 12px; bottom: 11px; padding: 3px 8px; border: 1px solid var(--ink); border-radius: 999px; background: var(--paper); font-size: .66rem; }

.workbench-grid { display: grid; grid-template-columns: minmax(220px, .72fr) minmax(350px, 1.34fr) minmax(220px, .78fr); gap: 16px; margin-top: 28px; }
.panel-card { border: 2px solid var(--ink); border-radius: 18px 6px 18px 6px; background: rgba(255, 249, 232, .88); box-shadow: 3px 4px 0 rgba(57, 32, 56, .1); }
.control-rail, .canvas-panel, .preview-panel { padding: 20px; }
.panel-heading, .timeline-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-heading h2, .timeline-header h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.05em; }
.status-dot { display: block; width: 11px; height: 11px; margin-top: 4px; border: 2px solid var(--ink); border-radius: 50%; background: var(--mint-deep); box-shadow: 0 0 0 4px rgba(73, 189, 169, .2); }
.field-label { display: grid; gap: 6px; margin-top: 20px; color: var(--ink-soft); font-size: .76rem; letter-spacing: .03em; }
.control-input { width: 100%; min-height: 44px; padding: 8px 10px; border: 1.5px solid var(--ink); border-radius: 8px 4px; color: var(--ink); background: #fffdf4; font-size: 16px; }
.control-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.subsection-title { display: flex; align-items: center; gap: 9px; margin-top: 21px; color: var(--ink-soft); font-family: "DotGothic16", monospace; font-size: .74rem; }
.rule { flex: 1; height: 1px; background: var(--line); }
.tool-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; }
.tool-button, .outline-button, .quiet-button, .mint-button, .primary-button, .play-button { min-height: 44px; border: 1.5px solid var(--ink); border-radius: 8px 4px; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.tool-button:hover, .outline-button:hover, .quiet-button:hover, .mint-button:hover, .primary-button:hover, .play-button:hover { transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--ink); }
.tool-button { display: flex; align-items: center; justify-content: center; gap: 7px; background: #fffdf4; font-size: .84rem; }
.tool-button.is-selected { color: var(--paper); background: var(--plum); }
.quiet-button { width: 100%; margin-top: 10px; color: var(--ink-soft); background: transparent; border-color: var(--line); font-size: .76rem; }
.palette { display: grid; grid-template-columns: repeat(5, minmax(28px, 1fr)); gap: 7px; margin-top: 11px; }
.swatch { position: relative; width: 100%; min-width: 28px; aspect-ratio: 1; border: 1.5px solid var(--ink); border-radius: 7px 3px; background: var(--swatch); }
.swatch:last-child { background-color: #fff; background-image: linear-gradient(45deg, #ddd 25%, transparent 25%), linear-gradient(-45deg, #ddd 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ddd 75%), linear-gradient(-45deg, transparent 75%, #ddd 75%); background-position: 0 0, 0 5px, 5px -5px, -5px 0; background-size: 10px 10px; }
.swatch.is-selected { box-shadow: 0 0 0 3px var(--sun); }
.color-field { grid-template-columns: 1fr auto; align-items: center; }
.color-field input { width: 55px; min-height: 44px; padding: 1px; border: 1.5px solid var(--ink); border-radius: 6px; background: #fff; font-size: 16px; }
.memory-note { display: grid; gap: 4px; margin-top: 22px; padding: 11px; border-left: 4px solid var(--mint-deep); background: rgba(201, 238, 193, .5); font-size: .72rem; }
.memory-note strong { font-family: "DotGothic16", monospace; font-size: .82rem; }
.memory-note small { color: var(--ink-soft); line-height: 1.45; }

.canvas-panel { min-width: 0; }
.canvas-heading { align-items: center; }
.frame-badge { padding: 5px 9px; border-radius: 999px; color: var(--plum); background: var(--lilac); font-family: "DotGothic16", monospace; font-size: .72rem; }
.canvas-stage { position: relative; display: grid; place-items: center; min-height: 390px; margin-top: 14px; padding: 27px; border: 1.5px solid var(--line); border-radius: 13px 4px; background-color: #f6ecd6; background-image: linear-gradient(45deg, rgba(105, 62, 147, .08) 25%, transparent 25%), linear-gradient(-45deg, rgba(105, 62, 147, .08) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(105, 62, 147, .08) 75%), linear-gradient(-45deg, transparent 75%, rgba(105, 62, 147, .08) 75%); background-position: 0 0, 0 11px, 11px -11px, -11px 0; background-size: 22px 22px; }
.pixel-canvas-wrap { width: min(100%, 360px); aspect-ratio: 1; border: 5px solid var(--ink); box-shadow: 8px 8px 0 var(--plum); background: transparent; }
#editor-canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; }
.canvas-ruler { position: absolute; color: var(--ink-soft); font-family: "DotGothic16", monospace; font-size: .63rem; }
.ruler-top { top: 8px; right: 24px; left: 24px; display: flex; justify-content: space-between; }
.ruler-side { top: 29px; bottom: 29px; left: 7px; display: flex; flex-direction: column; justify-content: space-between; }
.canvas-tip, .preview-note, .timeline-note { color: var(--ink-soft); font-size: .74rem; line-height: 1.65; }
.canvas-tip { margin: 20px 0 11px; }
.history-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.outline-button { padding: 7px 11px; color: var(--ink); background: transparent; font-size: .76rem; }
.shortcut-hint { margin-left: auto; color: var(--ink-soft); font-size: .68rem; }

.preview-panel { display: flex; flex-direction: column; }
.play-button { padding: 6px 10px; color: var(--paper); background: var(--mint-deep); font-size: .75rem; }
.preview-stage { display: grid; place-items: center; min-height: 238px; margin-top: 14px; border: 1.5px dashed var(--plum); border-radius: 50% 8px 50% 8px; background: var(--mint); }
#preview-canvas { width: min(100%, 190px); height: auto; aspect-ratio: 1; image-rendering: pixelated; filter: drop-shadow(7px 7px 0 rgba(57, 32, 56, .16)); }
.preview-note { margin: 15px 0 13px; }
.export-actions { margin-top: auto; }
.primary-button { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 9px 13px; color: var(--paper); background: var(--plum); font-size: .82rem; }
.secondary-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.export-detail { margin: 12px 0 0; color: var(--ink-soft); font-size: .68rem; }

.timeline-panel { margin-top: 16px; padding: 20px; }
.timeline-header { align-items: center; }
.timeline-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.mint-button { padding: 7px 11px; color: var(--ink); background: var(--mint); font-size: .76rem; }
.timeline { display: flex; gap: 12px; overflow-x: auto; margin-top: 17px; padding: 4px 4px 11px; }
.timeline-card { flex: 0 0 112px; padding: 7px; border: 1.5px solid var(--line); border-radius: 10px 3px; background: #fffdf4; }
.timeline-card.is-active { border-color: var(--plum); box-shadow: 3px 3px 0 var(--plum); }
.frame-select { display: block; width: 100%; padding: 0; border: 0; background: transparent; }
.mini-canvas { display: block; width: 96px; height: 96px; image-rendering: pixelated; background-color: #f6ecd6; background-image: linear-gradient(45deg, rgba(105, 62, 147, .09) 25%, transparent 25%), linear-gradient(-45deg, rgba(105, 62, 147, .09) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(105, 62, 147, .09) 75%), linear-gradient(-45deg, transparent 75%, rgba(105, 62, 147, .09) 75%); background-size: 12px 12px; }
.timeline-card > span { display: block; margin-top: 6px; color: var(--ink-soft); font-family: "DotGothic16", monospace; font-size: .65rem; text-align: center; }
.timeline-note { margin: 0; }
.status-message { min-height: 24px; margin: 14px 2px 0; color: var(--ink-soft); font-size: .8rem; }
.status-message[data-tone="success"] { color: #1d766a; }
.status-message[data-tone="error"] { color: #ae3f55; }
.status-message[data-tone="info"] { color: var(--plum); }

.info-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 44px 0 42px; }
.info-card { min-width: 0; padding: 18px; border-top: 2px solid var(--ink); }
.info-number { display: inline-block; margin-bottom: 15px; color: var(--plum); font-family: "DotGothic16", monospace; font-size: .75rem; }
.info-card h2 { margin: 0 0 8px; font-size: 1rem; }
.info-card p { margin: 0; color: var(--ink-soft); font-size: .74rem; line-height: 1.8; }
.info-card a { color: var(--plum); }
.site-footer { display: flex; justify-content: space-between; gap: 16px; padding: 18px 0 34px; border-top: 1px solid var(--line); color: var(--ink-soft); font-family: "DotGothic16", monospace; font-size: .65rem; }

@media (max-width: 980px) {
  .workbench-grid { grid-template-columns: minmax(220px, .8fr) minmax(330px, 1.2fr); }
  .preview-panel { grid-column: 1 / -1; }
  .preview-stage { min-height: 190px; }
  #preview-canvas { width: 145px; }
  .export-actions { margin-top: 0; }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  .site-header, .workbench, .site-footer { width: min(100% - 24px, 600px); }
  .site-header { align-items: flex-start; padding: 24px 0 16px; }
  .header-note { display: none; }
  .brand-mark { width: 44px; height: 44px; font-size: 22px; }
  .intro-panel { grid-template-columns: 1fr; padding: 25px 21px; }
  .toolbox-art-wrap { min-height: 150px; }
  #toolbox-art { min-height: 150px; }
  .workbench-grid { grid-template-columns: 1fr; gap: 12px; margin-top: 17px; }
  .preview-panel { grid-column: auto; }
  .control-rail, .canvas-panel, .preview-panel, .timeline-panel { padding: 16px; }
  .canvas-stage { min-height: 300px; padding: 24px; }
  .pixel-canvas-wrap { width: min(100%, 275px); }
  .ruler-side { top: 26px; bottom: 26px; }
  .timeline-header { align-items: flex-start; flex-direction: column; }
  .timeline-actions { justify-content: flex-start; }
  .info-grid { grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 30px; }
  .info-card { padding: 13px 8px; }
  .site-footer { flex-direction: column; gap: 4px; padding-bottom: 23px; }
}

@media (max-width: 370px) {
  .site-header, .workbench, .site-footer { width: calc(100% - 16px); }
  .intro-panel { padding: 21px 15px; }
  .intro-copy h2 { font-size: 1.75rem; }
  .feature-tags { gap: 5px; }
  .feature-tags span { padding: 4px 7px; font-size: .65rem; }
  .canvas-stage { min-height: 265px; padding: 18px; }
  .pixel-canvas-wrap { width: min(100%, 238px); border-width: 4px; box-shadow: 5px 5px 0 var(--plum); }
  .secondary-actions { grid-template-columns: 1fr; }
  .timeline-actions { width: 100%; }
  .timeline-actions button { flex: 1; min-width: 0; padding-inline: 5px; font-size: .68rem; }
}
