:root {
  --bg: #f4f3ef;
  --card: #ffffff;
  --ink: #1d1d1b;
  --muted: #6b6a64;
  --line: #dddbd3;
  --accent: #1f4e5f;
  --accent-ink: #ffffff;
  --ok: #2e6b3a;
  --warn: #8a5a00;
  --err: #a12a1f;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.45; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

.top { background: var(--ink); color: #fff; padding: 22px 0 18px; }
.top h1 { margin: 0; font-size: 1.5rem; font-weight: 650; letter-spacing: -0.01em; }
.top .sub { margin: 4px 0 0; color: #c9c7bf; font-size: .9rem; }

.grid {
  display: grid; gap: 20px; padding-top: 24px; padding-bottom: 24px;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  grid-template-areas: "form preview" "form tips";
  grid-template-rows: auto 1fr;
  align-items: start;
}
#form { grid-area: form; }
.preview { grid-area: preview; }
.tips { grid-area: tips; }
@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; grid-template-areas: "form" "preview" "tips"; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

.lbl { display: flex; justify-content: space-between; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
.lbl:first-child { margin-top: 0; }
output { font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }

input[type="text"] {
  width: 100%; padding: 11px 12px; font-size: 1.15rem; font-variant-numeric: tabular-nums;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em;
}
#addon { font-size: 1rem; max-width: 160px; }
input[type="text"]:focus, select:focus, .btn:focus-visible, input[type="range"]:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }

.hint { color: var(--muted); font-size: .8rem; margin: 6px 0 0; }
.hint.center { text-align: center; }

fieldset { border: 0; border-top: 1px solid var(--line); margin: 18px 0 0; padding: 14px 0 0; }
legend { font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 0 8px 0 0; }

.check { display: flex; gap: 8px; align-items: center; font-size: .9rem; margin: 10px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

details { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 10px; }
summary { cursor: pointer; font-weight: 600; font-size: .9rem; }

.msg { margin: 10px 0 0; padding: 8px 10px; border-radius: 6px; font-size: .85rem; }
.msg.ok { background: #e8f2ea; color: var(--ok); }
.msg.warn { background: #fbf2de; color: var(--warn); }
.msg.err { background: #f8e4e1; color: var(--err); }

.stage {
  display: flex; align-items: center; justify-content: center;
  min-height: 260px; border-radius: 8px; background: #fafaf8; border: 1px solid var(--line); padding: 24px;
}
.stage.checker {
  background-color: #fff;
  background-image: linear-gradient(45deg, #e9e8e3 25%, transparent 25%), linear-gradient(-45deg, #e9e8e3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e9e8e3 75%), linear-gradient(-45deg, transparent 75%, #e9e8e3 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.stage img { width: 100%; max-width: 420px; height: auto; display: block; }
.empty { color: var(--muted); margin: 0; }
.dims { text-align: center; color: var(--muted); font-size: .85rem; margin: 12px 0 0; min-height: 1.2em; font-variant-numeric: tabular-nums; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.actions[hidden] { display: none; }
.png { display: flex; gap: 0; }
.png select {
  border: 1px solid var(--accent); border-right: 0; border-radius: 8px 0 0 8px; padding: 0 8px; background: #fff; color: var(--ink); font-size: .9rem;
}
.png .btn { border-radius: 0 8px 8px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 8px;
  border: 1px solid var(--accent); background: #fff; color: var(--accent); font-weight: 600; font-size: .92rem;
  text-decoration: none; cursor: pointer; font-family: inherit;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: progress; }

.tips h2 { margin: 0 0 8px; font-size: 1rem; }
.tips ul { margin: 0; padding-left: 18px; font-size: .88rem; }
.tips li { margin: 6px 0; }

.foot { color: var(--muted); font-size: .8rem; padding-bottom: 28px; }

.seg { display: flex; border: 1px solid var(--accent); border-radius: 8px; overflow: hidden; }
.seg label { flex: 1; position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 8px 4px; font-size: .88rem; font-weight: 600; color: var(--accent); }
.seg label + label span { border-left: 1px solid var(--accent); }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: -4px; }

.size { display: flex; align-items: flex-end; gap: 8px; }
.size label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); }
.size input[type="text"] { font-size: 1rem; padding: 9px 10px; }
.lock {
  width: 36px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  cursor: pointer; font-size: 1rem; color: var(--muted); flex: none;
}
.lock[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: #e9f0f2; }
.presets { margin-top: 6px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: .85rem; text-decoration: underline; cursor: pointer; }
