:root {
  --bg: #eef1f6;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #5b6477;
  --line: #d5dbe5;
  --blue: #1d4ed8;
  --blue-soft: #e3ebff;
  --warn: #b45309;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }

.bar { display: flex; align-items: baseline; gap: 10px; padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.logo { color: var(--blue); font-size: 22px; line-height: 1; }
.title { font-weight: 600; font-size: 18px; }
.bar-note { color: var(--muted); font-size: 14px; }

.layout { max-width: 1080px; margin: 32px auto; padding: 0 16px; display: grid; grid-template-columns: 1.15fr 1fr; gap: 24px; align-items: start; }
.panel, .preview { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 24px; }

.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 6px; margin-bottom: 20px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 4px; cursor: pointer; font-weight: 500; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--blue); box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }

fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 14px; }
label { display: grid; gap: 4px; font-size: 14px; font-weight: 500; }
input:not([type="checkbox"]):not([type="color"]), select, textarea {
  border: 1px solid var(--line); border-radius: 4px; padding: 9px 10px; background: #fff; width: 100%;
}
textarea { resize: vertical; font-family: var(--mono); font-size: 14px; }
input[type="color"] { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 4px; padding: 2px; background: #fff; }
:focus-visible, input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; align-items: end; }
.check { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; }
.hint { margin: 0; color: var(--muted); font-size: 14px; }

.options { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; }
.options summary { cursor: pointer; font-weight: 500; color: var(--blue); margin-bottom: 12px; }
.options > * + * { margin-top: 12px; }

.preview { position: sticky; top: 16px; }
.canvas-wrap { position: relative; background: repeating-conic-gradient(#f3f5f9 0 25%, #fff 0 50%) 0 0 / 16px 16px; border: 1px solid var(--line); border-radius: 4px; display: grid; place-items: center; aspect-ratio: 1; }
canvas { width: 80%; height: auto; image-rendering: pixelated; }
.canvas-wrap.empty canvas { visibility: hidden; }
.placeholder { position: absolute; inset: 0; display: none; place-items: center; text-align: center; padding: 24px; color: var(--muted); margin: 0; }
.canvas-wrap.empty .placeholder { display: grid; }
.warn { color: var(--warn); font-size: 14px; min-height: 1.5em; margin: 12px 0 0; }
.meta { color: var(--muted); font-size: 13px; margin: 0; font-family: var(--mono); }

.actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; align-items: end; }
.actions button { border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 9px 14px; cursor: pointer; font-weight: 500; }
.actions button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.actions button:disabled { opacity: .45; cursor: not-allowed; }
.size { display: grid; font-size: 12px; color: var(--muted); }
.size select { padding: 8px; }

.raw { margin-top: 16px; font-size: 14px; }
.raw summary { cursor: pointer; color: var(--muted); }
.raw pre { background: var(--bg); padding: 10px; border-radius: 4px; white-space: pre-wrap; word-break: break-all; font-family: var(--mono); font-size: 12px; max-height: 180px; overflow: auto; }

.foot { max-width: 1080px; margin: 0 auto 32px; padding: 0 16px; color: var(--muted); font-size: 13px; }
.foot a { color: var(--blue); }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; margin-top: 16px; }
  .preview { position: static; }
}
