:root {
  --ink: #14161a;
  --muted: #5b6470;
  --line: #d8dde5;
  --bg: #ffffff;
  --panel: #f7f8fa;
  --accent: #1f6feb;
  --radius: 10px;
  --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

.site-header {
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

/* ---------- tool (first screen) ---------- */

.tool { padding: 28px 0 8px; }

h1 {
  font-size: 34px;
  line-height: 1.15;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 17px;
}

#form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.field { margin-bottom: 18px; }

label, legend {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.opt { font-weight: 400; color: var(--muted); }

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 10px 12px;
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

input[type="range"] {
  width: 100%;
  min-height: var(--tap);
  accent-color: var(--accent);
}

output {
  font-size: 14px;
  color: var(--muted);
}

.hint {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px 6px;
  margin: 0 0 18px;
}

fieldset legend { margin-bottom: 4px; }

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  min-height: var(--tap);
  margin: 0;
}

.checks input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

button {
  font: inherit;
  font-size: 16px;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

button:hover { border-color: #9fb3cc; }
button.primary:hover { background: #1a5fd0; }

a.btn {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  margin-top: 10px;
  padding: 10px 18px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
}

.error {
  margin: 12px 0 0;
  color: #b3261e;
  font-weight: 600;
}

/* ---------- result ---------- */

.result {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.result h2 { margin: 0; font-size: 20px; }

.tabs { display: flex; gap: 8px; }

.tab {
  min-height: 38px;
  padding: 6px 14px;
  font-size: 15px;
}

.tab.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.stage {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 10px;
  overflow: hidden;
}

.canvas-wrap {
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

canvas {
  max-width: 100%;
  height: auto;
  display: block;
  background: #fff;
}

.export {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

/* ---------- body copy ---------- */

.info {
  margin-top: 44px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
  max-width: 760px;
}

.info h2 {
  font-size: 22px;
  margin: 32px 0 10px;
}

.info h3 {
  font-size: 17px;
  margin: 22px 0 6px;
}

.info p, .info li { color: #2b3038; }

.info ul, .info ol { padding-left: 22px; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px 20px 40px;
  color: var(--muted);
  font-size: 14px;
}

.site-footer p { margin: 0 0 6px; }
.site-footer .free-line { color: var(--ink); font-weight: 600; }

/* ---------- mobile ---------- */

@media (max-width: 720px) {
  main { padding: 0 14px 48px; }
  h1 { font-size: 27px; }
  .tagline { font-size: 15px; }
  .grid3 { grid-template-columns: 1fr; gap: 0; }
  .grid3 .field { margin-bottom: 18px; }
  #form { padding: 14px; }
  .actions { flex-direction: column; align-items: stretch; }
  .actions button { width: 100%; }
  .export { flex-direction: column; align-items: stretch; }
  .export button { width: 100%; }
  .result-head { flex-direction: column; align-items: stretch; }
  .tabs { width: 100%; }
  .tab { flex: 1; }
}

/* ---------- print ---------- */

@media print {
  .site-header, .tool, .info, .site-footer,
  .result-head, .export, .hint { display: none !important; }
  main { padding: 0; }
  .result { margin: 0; border: 0; padding: 0; }
  .stage { border: 0; padding: 0; background: #fff; }
  canvas { max-width: 100%; }
}
