:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1c2333;
  --muted: #6b7280;
  --line: #e3e6ee;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --ok: #059669;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(20, 25, 45, .06), 0 8px 24px rgba(20, 25, 45, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c;
    --card: #1b1e29;
    --text: #e8eaf2;
    --muted: #9aa2b5;
    --line: #2b3040;
    --accent: #8b87ff;
    --accent-soft: #232742;
    --ok: #34d399;
    --warn: #fbbf24;
    --warn-soft: #3a2f14;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: 1.75;
  font-size: 15px;
  padding-bottom: 84px;
  -webkit-text-size-adjust: 100%;
}

.hdr {
  position: sticky; top: 0; z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px 8px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.hdr-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.hdr h1 { font-size: 16px; margin: 0; letter-spacing: .04em; }
.save { font-size: 11px; color: var(--ok); opacity: 0; transition: opacity .3s; white-space: nowrap; }
.save.on { opacity: 1; }
.bar { height: 4px; background: var(--line); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
.bar-label { font-size: 11px; color: var(--muted); margin-top: 4px; }

.tabs {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.tab .cnt { font-size: 11px; opacity: .85; }
.tab .dot { width: 6px; height: 6px; border-radius: 99px; background: var(--ok); }

main { max-width: 760px; margin: 0 auto; padding: 18px 16px 32px; }

.step-head { margin-bottom: 18px; }
.step-kicker { font-size: 12px; color: var(--accent); font-weight: 700; letter-spacing: .06em; }
.step-head h2 { font-size: 19px; margin: 2px 0 8px; }
.lead {
  color: var(--muted);
  font-size: 13px;
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 12px;
  margin: 0 0 12px;
}
.outs { display: flex; flex-wrap: wrap; gap: 6px; }
.out-chip {
  font-size: 11.5px; color: var(--accent);
  background: var(--accent-soft);
  border-radius: 99px; padding: 3px 10px;
}

.qcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.qhead { display: flex; gap: 10px; align-items: flex-start; }
.qnum {
  flex: 0 0 auto; width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 3px;
}
.qcard.done .qnum { background: var(--accent); color: #fff; }
.qtext { font-weight: 600; font-size: 15px; }
.hint { white-space: pre-wrap; font-size: 12.5px; color: var(--muted); margin: 10px 0 0 36px; }
textarea {
  display: block; width: 100%; margin-top: 12px;
  min-height: 92px; padding: 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 15px; line-height: 1.7;
  resize: vertical; overflow: hidden;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.ex-btn {
  border: 1px dashed var(--line); background: transparent; color: var(--muted);
  border-radius: 8px; padding: 5px 12px; font-size: 12px; font-family: inherit; cursor: pointer;
}
.ex-btn:hover { color: var(--accent); border-color: var(--accent); }
.example {
  display: none; white-space: pre-wrap; margin-top: 10px; padding: 12px;
  background: var(--accent-soft); border-radius: 10px; font-size: 13px;
}
.example.open { display: block; }
.example .cap { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }

.priv {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--warn);
  background: var(--warn-soft);
  border-radius: 8px; padding: 5px 11px;
  cursor: pointer; user-select: none;
}
.priv input { margin: 0; accent-color: var(--warn); }

.act-area { margin-top: 20px; }
.btn {
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 10px; padding: 11px 18px;
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.wide { width: 100%; }
.note { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.err {
  font-size: 13px; color: var(--danger);
  border: 1px solid var(--danger); border-radius: 10px;
  padding: 10px 12px; margin-top: 12px; background: var(--card);
}

.spin {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 99px; animation: sp .7s linear infinite; vertical-align: -2px; margin-right: 8px;
}
@keyframes sp { to { transform: rotate(360deg); } }

.result {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; margin-top: 16px; box-shadow: var(--shadow);
}
.result h3 { font-size: 13px; color: var(--accent); margin: 0 0 10px; letter-spacing: .04em; }
.result h4 { font-size: 13px; margin: 18px 0 8px; color: var(--muted); }
.result h4.first { margin-top: 0; }
.result ul { margin: 0; padding-left: 18px; }
.result li { margin-bottom: 6px; font-size: 14px; }
.result .ev { display: block; font-size: 12.5px; color: var(--muted); }
.type-name { font-size: 20px; font-weight: 700; margin: 0 0 6px; }
.job {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; margin-bottom: 10px; background: var(--bg);
}
.job-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.job-title { font-weight: 700; font-size: 15px; }
.fit { flex: 0 0 auto; max-width: 45%; font-size: 11px; border-radius: 99px; padding: 2px 9px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job p { margin: 6px 0 0; font-size: 13px; }
.job .lbl { color: var(--muted); font-size: 11.5px; }

.sheet-wrap {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 12, 20, .55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-wrap[hidden] { display: none; }
.sheet {
  background: var(--card); width: 100%; max-width: 640px;
  border-radius: 16px 16px 0 0; padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  max-height: 86vh; display: flex; flex-direction: column;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.x { border: none; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; }
.sheet-note { font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
.sheet-body {
  flex: 1; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 12.5px; line-height: 1.7; margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.sheet-input {
  flex: 1; min-height: 180px; margin: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 12.5px; line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-y: auto; resize: none;
}
.sheet-actions { display: flex; gap: 8px; margin-top: 12px; }
.sheet-actions .btn { flex: 1; }

.footbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; gap: 10px; padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}
.nav {
  flex: 1; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 10px; padding: 11px; font-size: 14px; font-family: inherit; font-weight: 600; cursor: pointer;
}
.nav:disabled { opacity: .35; cursor: default; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(8px);
  background: var(--text); color: var(--bg);
  padding: 9px 18px; border-radius: 99px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 60;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
