
:root {
  --navy: #16283D;
  --yellow: #E0A106;
  --paper: #FFFFFF;
  --canvas: #EDF1F2;
  --muted: #607184;
  --border: #A8B6C2;
  --soft-blue: #EFF4F7;
  --soft-green: #EEF7EF;
  --soft-purple: #F5F0FA;
  --soft-orange: #FFF6E8;
  --soft-red: #FFF0EC;
  --text-color: #16283D;
  --body-size: 28px;
  --body-leading: 1.85;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  padding: 28px;
  color: var(--navy);
  background:
    radial-gradient(circle at 0 0, rgba(224,161,6,.09), transparent 28rem),
    var(--canvas);
  font-family: "Yu Gothic", "YuGothic", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}
button, input, textarea, select { font: inherit; }
.site-header,
.layout,
.site-footer {
  width: min(1540px, 100%);
  margin-inline: auto;
}
.site-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 8px 4px 24px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.site-header h1,
.preview-toolbar h2 { margin: 0; }
.site-header h1 { font-size: clamp(30px, 4vw, 52px); line-height: 1.08; }
.lead {
  max-width: 760px;
  margin: 10px 0 0;
  color: #43576B;
  font-size: 16px;
  line-height: 1.7;
}
.header-badge,
.count-label,
.save-state {
  border-radius: 999px;
  background: var(--navy);
  color: white;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.save-state {
  padding: 5px 9px;
  background: var(--soft-blue);
  color: var(--muted);
}
.layout {
  display: grid;
  grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.panel {
  background: rgba(255,255,255,.94);
  border: 2px solid var(--navy);
  border-radius: 22px;
  box-shadow: 0 12px 34px rgba(22,40,61,.10);
}
.editor-panel { padding: 20px; }
.editor-panel section + section { margin-top: 26px; padding-top: 24px; border-top: 1px solid #D7E0E7; }
.editor-panel h2 { margin: 0 0 8px; font-size: 18px; }
.section-head,
.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.block-head { align-items: flex-start; }
.hint {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}
.hint.small { font-size: 12px; }
code {
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--soft-blue);
}
#jsonInput {
  width: 100%;
  min-height: 390px;
  resize: vertical;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  outline: none;
  color: #172B4D;
  background: #FBFCFD;
  font: 12.5px/1.55 ui-monospace, "Cascadia Code", Consolas, monospace;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#jsonInput:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 4px rgba(224,161,6,.12);
}
.input-actions,
.stack-actions,
.actions,
.mini-actions,
.export-setting-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.input-actions { margin-bottom: 10px; }
.stack-actions { flex-direction: column; }
.stack-actions.compact { gap: 8px; }
.button,
.file-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.25;
  cursor: pointer;
  text-align: center;
  transition: transform .08s ease, opacity .15s ease, box-shadow .15s ease;
}
.button:hover,
.file-button:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(22,40,61,.12); }
.button:active,
.file-button:active { transform: translateY(0); }
.button:disabled { opacity: .45; cursor: wait; }
.primary { background: var(--navy); color: white; }
.accent { background: var(--yellow); color: #17202A; }
.secondary { background: #61758C; color: white; }
.subtle { background: var(--soft-blue); color: var(--navy); }
.danger { color: #A23B30; }
.wide { width: 100%; }
.small-btn { padding: 8px 10px; font-size: 12px; }
.file-button {
  display: inline-flex;
  align-items: center;
  background: var(--soft-blue);
  color: var(--navy);
}
.file-button input { position: absolute; opacity: 0; pointer-events: none; }
.status {
  min-height: 18px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.status.error { color: #A23B30; }
.status.success { color: #2F7045; }
.settings { display: grid; gap: 12px; }
.setting-row,
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 13px;
  font-weight: 700;
}
.setting-row select,
.setting-row input[type="color"],
.block-export-settings select {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  min-height: 34px;
}
.range-wrap { display: grid; grid-template-columns: 150px 48px; gap: 8px; align-items: center; }
.range-wrap input { width: 100%; }
.range-wrap output { color: var(--muted); font-size: 12px; text-align: right; }
.toggle-row { justify-content: flex-start; font-weight: 600; }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--yellow); }
.preview-panel { min-height: 700px; padding: 22px; }
.preview-toolbar { margin-bottom: 18px; }
.preview-toolbar h2 { font-size: 26px; }
.count-label { background: var(--soft-blue); color: var(--navy); }
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 22px;
}
.preview-item { min-width: 0; }
.block-card {
  position: relative;
  overflow: hidden;
  border: 3px solid var(--navy);
  border-radius: 18px;
  padding: 18px 20px;
  background: white;
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
  color: var(--text-color);
}
.style-lead_box,
.style-article_box,
.style-plain { background: white; }
.style-callout_box { background: var(--soft-orange); }
.style-mini_column_box { background: var(--soft-purple); }
.style-experiment_box { background: var(--soft-green); }
.style-note_box { background: #FFF8D9; }
.style-summary_box { background: #EFF3F8; }
.style-trivia_box { background: #F9F3E8; }
.style-safety_box { background: var(--soft-red); }
.style-reference_box { background: #F8F8F8; }
.meta {
  margin-bottom: 8px;
  color: #66788A;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
}
.title {
  margin-bottom: 14px;
  color: var(--text-color);
  font-size: calc(var(--body-size) * 1.12);
  font-weight: 800;
  line-height: 1.25;
}
.content {
  color: var(--text-color);
  font-size: var(--body-size);
  font-weight: 700;
  line-height: var(--body-leading);
  overflow-wrap: anywhere;
  word-break: auto-phrase;
}
.content p { margin: 0 0 .5em; }
.content p:last-child { margin-bottom: 0; }
.content ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .35em; }
.content li { line-height: var(--body-leading); }
.content li::before { content: "・"; margin-right: .15em; }
.steps { display: flex; flex-direction: column; gap: .55em; }
.step { display: flex; gap: 10px; align-items: flex-start; }
.step-num {
  width: 1.45em;
  height: 1.45em;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin-top: .3em;
  background: var(--yellow);
  color: white;
  font-size: .72em;
  font-weight: 900;
  line-height: 1;
}
.step-text { min-width: 0; }
.block-type {
  position: absolute;
  top: 12px;
  right: 12px;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(237,241,242,.94);
  color: var(--navy);
  font-size: 10px;
  font-weight: 800;
}
.block-tools {
  margin-top: 10px;
  border: 1px solid #D9E2E9;
  border-radius: 14px;
  background: #FCFDFE;
  padding: 10px;
}
.tools-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 8px;
  margin-bottom: 8px;
}
.tools-head strong { font-size: 12px; }
.preset-tag {
  border-radius:999px;
  background: var(--soft-blue);
  color: var(--navy);
  padding:4px 8px;
  font-size:11px;
  font-weight:700;
}
.block-export-settings {
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.block-export-settings label {
  display:grid;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #51667B;
}
.block-export-settings select { width:100%; padding:6px 8px; font-size:12px; }
.actions { margin-top: 10px; }
.actions .button { padding: 8px 11px; font-size: 12px; }
.mini-actions { margin-top: 8px; }
.mini-actions .button { padding: 7px 10px; font-size: 11px; }
ruby { ruby-position: over; ruby-align: center; }
rt { font-size: .52em; font-weight: 500; line-height: 1; }
.empty-state {
  padding: 80px 24px;
  border: 2px dashed var(--border);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  line-height: 1.8;
}
.site-footer {
  padding: 22px 4px 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.zip-ready {
  margin-top: 12px;
  border: 1px solid #B8C8D4;
  border-radius: 14px;
  padding: 12px;
  background: #F7FAFC;
}
.zip-ready strong { display:block; margin-bottom:6px; font-size:13px; }
.zip-ready-info { margin-bottom:10px; color:var(--muted); font-size:12px; line-height:1.55; }

.export-root {
  position: fixed;
  top: 0;
  left: -50000px;
  z-index: -1000;
  pointer-events: none;
}
.export-shell { display: inline-block; }
.export-content-shell { display:inline-block; }
.export-content-shell.transparent .block-card {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
}
.export-content-shell.transparent .block-type { display: none; }
.export-content-shell.card .block-type { display: none; }
.export-content-shell.hide-title .title { display: none; }
.export-content-shell.hide-meta .meta { display: none; }
.export-content-shell.transparent .meta { margin-bottom: 4px; }
.export-shell.fixed-ratio .export-canvas {
  display: flex;
  width: var(--canvas-width);
  height: var(--canvas-height);
  background: transparent;
}
.export-shell.fixed-ratio.card .export-canvas { background: transparent; }
.export-holder {
  display:flex;
  width:100%;
  height:100%;
  padding: var(--canvas-pad);
}
.export-holder.align-top-left { justify-content:flex-start; align-items:flex-start; }
.export-holder.align-top-center { justify-content:center; align-items:flex-start; }
.export-holder.align-center-left { justify-content:flex-start; align-items:center; }
.export-holder.align-center { justify-content:center; align-items:center; }
.export-holder.align-bottom-left { justify-content:flex-start; align-items:flex-end; }
.export-holder.align-bottom-center { justify-content:center; align-items:flex-end; }
.export-holder > .export-content-shell { max-width:100%; flex: 0 1 auto; }
.export-holder > .export-content-shell > .block-card { max-width:100%; }
@media (max-width: 1120px) {
  body { padding: 16px; }
  .layout { grid-template-columns: 1fr; }
  .site-header { align-items: flex-start; flex-direction: column; }
  .editor-panel { order: 1; }
  .preview-panel { order: 2; }
}
@media (max-width: 640px) {
  body { padding: 10px; }
  .panel { border-radius: 16px; }
  .preview-grid { grid-template-columns: 1fr; }
  .setting-row { align-items: flex-start; flex-direction: column; }
  .range-wrap { width: 100%; grid-template-columns: 1fr 48px; }
  .block-export-settings { grid-template-columns: 1fr; }
}

/* v3: live aspect-ratio preview */
.preview-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  transition: width .18s ease, height .18s ease, border-color .18s ease, background .18s ease;
}
.preview-stage.auto {
  min-height: 0;
  background: transparent;
  border: 0;
}
.preview-stage.fixed-ratio {
  overflow: hidden;
  border: 1px dashed #A8B6C2;
  border-radius: 14px;
  background-color: #F9FBFC;
  background-image:
    linear-gradient(45deg, #EEF2F5 25%, transparent 25%),
    linear-gradient(-45deg, #EEF2F5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #EEF2F5 75%),
    linear-gradient(-45deg, transparent 75%, #EEF2F5 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.preview-stage-holder {
  width: 100%;
  height: 100%;
  display: flex;
}
.preview-stage.auto .preview-stage-holder {
  display: block;
}
.preview-stage.fixed-ratio .preview-stage-holder.align-top-left { justify-content:flex-start; align-items:flex-start; }
.preview-stage.fixed-ratio .preview-stage-holder.align-top-center { justify-content:center; align-items:flex-start; }
.preview-stage.fixed-ratio .preview-stage-holder.align-center-left { justify-content:flex-start; align-items:center; }
.preview-stage.fixed-ratio .preview-stage-holder.align-center { justify-content:center; align-items:center; }
.preview-stage.fixed-ratio .preview-stage-holder.align-bottom-left { justify-content:flex-start; align-items:flex-end; }
.preview-stage.fixed-ratio .preview-stage-holder.align-bottom-center { justify-content:center; align-items:flex-end; }
.preview-scaled-frame {
  flex: 0 0 auto;
  min-width: 0;
}
.preview-stage.fixed-ratio .block-card {
  box-shadow: 0 2px 8px rgba(22,40,61,.10);
}
