:root {
  --bg: #0f131a;
  --panel: #161b24;
  --panel2: #1d2430;
  --line: #2a3343;
  --ink: #e8eef7;
  --ink-dim: #93a1b5;
  --accent: #6fa8dc;
  --accent-ink: #0b1622;
  --steam: #1b2838;
  --warn-bg: #3a2a12;
  --warn-line: #6b4f1e;
  --warn-ink: #f0d69a;
  --err-bg: #3a1618;
  --err-line: #7a2d32;
  --err-ink: #f4b4b0;
  --ui: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 14px; line-height: 1.6; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 420px 1fr; min-height: 100vh; }

.side { background: var(--panel); border-right: 1px solid var(--line); height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { padding: 20px 20px 0; }
.brand h1 { font-size: 17px; font-weight: 800; }
.brand p { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }

.step { padding: 18px 20px 6px; }
.step + .step { border-top: 1px solid var(--line); margin-top: 12px; }
.step__head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; font-weight: 700; }
.step__num { width: 22px; height: 22px; flex: none; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.step--more summary { cursor: pointer; list-style: none; }
.step--more summary::-webkit-details-marker { display: none; }
.step--more summary::after { content: "▾"; margin-left: auto; color: var(--ink-dim); }
.step--more:not([open]) summary::after { transform: rotate(-90deg); }
.step--more:not([open]) summary { margin-bottom: 0; }

.hint { font-size: 12px; color: var(--ink-dim); margin: 0 0 10px; }
.label { font-size: 12px; color: var(--ink-dim); margin-bottom: 6px; }

label.f { display: block; margin-bottom: 12px; }
label.f > span:first-child { display: block; font-size: 12px; color: var(--ink-dim); margin-bottom: 4px; }
input[type=color] { width: 100%; height: 38px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; cursor: pointer; }
input[type=range] { width: 100%; height: 38px; accent-color: var(--accent); cursor: pointer; }
.row2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
.row2 label.f { margin-bottom: 4px; }
output { color: var(--ink); margin-left: 4px; }
input[type=text], select { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input[type=text]:focus, select:focus { border-color: var(--accent); outline: none; }
input[type=text][aria-invalid=true] { border-color: var(--err-line); }

.check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; cursor: pointer; }
.check input, .checks input { accent-color: var(--accent); width: 16px; height: 16px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 12px; }
.checks label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 6px; cursor: pointer; font-size: 13px; }
.chip[aria-pressed=true] { border-color: var(--accent); background: #1f2e3e; font-weight: 700; }
.chip i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .25); }

.item { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.item.off { opacity: .55; }
.item__head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.item__head input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.item__head input[type=text] { flex: 1; min-width: 0; padding: 5px 8px; }
.item__head select { width: 112px; flex: none; padding: 5px 8px; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 6px; width: 28px; height: 28px; flex: none; cursor: pointer; color: var(--ink-dim); }
.icon-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.item__texts { display: grid; grid-template-columns: 56px 1fr; gap: 4px 8px; align-items: center; }
.item__texts span { font-size: 11px; color: var(--ink-dim); }
.item__texts input { padding: 5px 8px; }

.btn { display: block; width: 100%; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 9px; padding: 12px; font-weight: 800; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn--ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 600; padding: 9px; }
.btn--ghost:hover { border-color: var(--accent); filter: none; }
.btn--danger:hover { border-color: #d0605a; color: #f1a39e; }
.btnrow { display: flex; gap: 8px; margin: 8px 0 12px; }
.btnrow .btn { flex: 1; }
#addSection { margin-bottom: 10px; }

.savebar { position: sticky; bottom: 0; margin-top: auto; padding: 12px 20px 16px; background: var(--panel); border-top: 1px solid var(--line); display: grid; gap: 8px; }
.messages { list-style: none; display: grid; gap: 4px; max-height: 140px; overflow-y: auto; }
.messages:empty { display: none; }
.messages li { font-size: 12px; border-radius: 6px; padding: 5px 9px; }
.messages .error { background: var(--err-bg); border: 1px solid var(--err-line); color: var(--err-ink); }
.messages .warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); }

.main { padding: 20px 24px 40px; background: #0b0e14; overflow-x: auto; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; margin-bottom: 14px; font-size: 13px; color: var(--ink-dim); }
.toolbar select { width: auto; margin-left: 6px; padding: 5px 8px; }
.toolbar .check { margin: 0; }
.page { background: var(--steam); border-radius: 6px; padding: 24px; margin: 0 auto; width: max-content; max-width: none; }
.page canvas { display: block; height: auto; margin: 18px 0 10px; }
.page canvas:first-child { margin-top: 0; }
.page p { color: #acb2b8; font-size: 14px; line-height: 1.6; margin-bottom: 4px; }
.page .empty { color: #acb2b8; font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10; display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-radius: 10px; background: #e8eef7; color: #10141c; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); font-size: 13px; }
.toast button { background: none; border: 0; color: #1d5d9b; font-weight: 700; cursor: pointer; }

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .side { height: auto; overflow: visible; border-right: 0; }
  .main { order: -1; position: sticky; top: 0; z-index: 5; max-height: 45vh; overflow: auto; border-bottom: 1px solid var(--line); padding: 12px; }
}
