:root {
  --bg: #f7f4ee;
  --surface: #fffdf9;
  --text: #2b2723;
  --muted: #6e665d;
  --line: #e2dbcf;
  --accent: #8c3b2a;
  --accent-text: #fff;
  --error: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a18;
    --surface: #26231f;
    --text: #efe9df;
    --muted: #a39a8e;
    --line: #3a3530;
    --accent: #d98366;
    --accent-text: #1c1a18;
    --error: #f2928b;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  line-height: 1.8;
}
main { max-width: 720px; margin: 0 auto; padding: 32px 16px 64px; }
h1 { margin: 0 0 8px; font-size: 1.8rem; letter-spacing: .08em; }
h2 { margin: 0 0 8px; font-size: 1rem; color: var(--muted); font-weight: normal; }
.lead { margin: 0 0 24px; color: var(--muted); }

label { display: block; margin-bottom: 4px; font-size: .9rem; color: var(--muted); }
textarea, input, select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
textarea { resize: vertical; }
textarea:focus-visible, input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.counter { text-align: right; font-size: .8rem; color: var(--muted); }
.row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; margin: 12px 0 20px; }
@media (max-width: 600px) { .row { grid-template-columns: 1fr; } }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
}
#submit {
  width: 100%;
  padding: 12px;
  font-size: 1.05rem;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
}
#submit:disabled { opacity: .6; cursor: progress; }

.error { margin: 16px 0 0; color: var(--error); }
#result { margin-top: 28px; display: grid; gap: 16px; }
.card {
  position: relative;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.card.main { border-color: var(--accent); }
.body { margin: 0 0 12px; white-space: pre-wrap; font-size: 1.05rem; }
.copy {
  padding: 4px 14px;
  font-size: .85rem;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
}
summary { cursor: pointer; color: var(--muted); }
#changes { margin: 8px 0 0; padding-left: 1.2em; }
.note { margin: 0; padding: 10px 14px; background: var(--surface); border-left: 3px solid var(--accent); border-radius: 4px; }
#alts { display: grid; gap: 16px; }

#turnstile { margin-bottom: 12px; }

#history { margin-top: 40px; }
.history-head { display: flex; justify-content: space-between; align-items: baseline; }
.link {
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  text-decoration: underline;
  font-size: .85rem;
}
#history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#history-list li {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.history-open {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  text-align: left;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 0;
}
.history-open:hover { background: var(--bg); }
.history-date { font-size: .75rem; color: var(--muted); }
.history-title, .history-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-preview { font-size: .9rem; color: var(--muted); }
.history-delete {
  padding: 0 14px;
  font-size: .8rem;
  color: var(--muted);
  background: none;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
}
.history-delete:hover { color: var(--error); }
.hint { font-size: .8rem; color: var(--muted); }
footer { margin-top: 40px; font-size: .8rem; color: var(--muted); }
footer p { margin: 4px 0; }

.crumb { margin: 0 0 12px; font-size: .85rem; }
.crumb a, footer a { color: var(--muted); }

.hero { margin-bottom: 40px; text-align: center; }
.hero h1 { font-size: 2.2rem; }
.cta {
  display: inline-block;
  min-width: 220px;
  padding: 12px 32px;
  font-size: 1.1rem;
  text-align: center;
  text-decoration: none;
  color: var(--accent-text);
  background: var(--accent);
  border-radius: 8px;
}
.cta:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hero .hint { margin: 8px 0 0; }

.intro { margin-bottom: 36px; }
.intro h2 { margin-bottom: 12px; font-size: 1.1rem; color: var(--text); }
.cta-row { margin: 24px 0 0; text-align: center; }
.uses { margin: 0; padding-left: 1.2em; }
.uses li { margin-bottom: 4px; }
.sample { display: grid; gap: 12px; }
.card h3 { margin: 0 0 4px; font-size: .9rem; font-weight: normal; color: var(--muted); }

.steps { margin: 0; padding-left: 1.4em; }
.steps li { margin-bottom: 8px; }
.intro details { margin-bottom: 8px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.intro summary { cursor: pointer; }
.intro details p { margin: 8px 0 0; color: var(--muted); font-size: .95rem; }

.prose section { margin-bottom: 28px; }
.prose h2 { margin-bottom: 8px; font-size: 1.05rem; color: var(--text); }
.prose table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 8px 0; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 8px 10px; border: 1px solid var(--line); }
.prose th { color: var(--muted); font-weight: normal; white-space: nowrap; }
.prose .note { font-size: .85rem; color: var(--muted); }
footer a { color: var(--muted); }
.prose a { color: var(--accent); }
