:root {
  --bg: #f2ecdf;          /* 生成り */
  --surface: #fbf8f1;
  --ink: #26324d;         /* ネイビー */
  --ink-soft: #58627c;
  --line: #e3dccb;
  --accent: #c7a24a;      /* 控えめなきらめき（差し色） */
  --selected-ink: #f7f3ea;
  --radius: 14px;
  --tap: 44px;
  --maxw: 720px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
               "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  background: var(--ink);
  color: var(--surface);
  padding: 1rem 1.1rem calc(1rem + env(safe-area-inset-top, 0px));
  padding-top: calc(1rem + env(safe-area-inset-top, 0px));
}
.topbar .brand { display: flex; align-items: baseline; gap: .5rem; max-width: var(--maxw); margin: 0 auto; }
.topbar h1 { font-size: 1.2rem; margin: 0; letter-spacing: .04em; font-weight: 700; }
.topbar .sub { font-size: .8rem; color: #cfd6e6; margin: 0; }
.topbar .cat { max-width: var(--maxw); margin: .15rem auto 0; font-size: .82rem; color: #aeb8cf; }

main { max-width: var(--maxw); margin: 0 auto; padding: 1rem .9rem 5rem; }

.loading {
  max-width: var(--maxw);
  margin: 2.5rem auto; padding: 0 1.2rem; text-align: center; color: var(--ink-soft);
}
.fatal-title { font-weight: 700; color: var(--ink); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.1rem;
  margin-bottom: 1rem;
}
.card.intro { background: #fdfbf5; border-style: dashed; }
.card-title {
  font-size: 1.02rem; margin: 0 0 .7rem;
  padding-left: .6rem; border-left: 3px solid var(--accent);
}

.field { margin-bottom: 1.05rem; }
.field:last-child { margin-bottom: .2rem; }
.field-label { font-weight: 600; font-size: .96rem; margin-bottom: .15rem; }
.help { font-size: .8rem; color: var(--ink-soft); margin: .1rem 0 .55rem; }
.help.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }

.chip {
  min-height: var(--tap);
  padding: .55rem .95rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.chip:hover { border-color: var(--ink-soft); }
.chip.selected { background: var(--ink); color: var(--selected-ink); border-color: var(--ink); }
.chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.field.scale .chips { gap: .35rem; }
.field.scale .chip { flex: 1 1 auto; text-align: center; }

.free-input {
  margin-top: .55rem;
  width: 100%;
  min-height: var(--tap);
  padding: .5rem .7rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-family: inherit;
}
.free-input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--ink-soft); }

/* 出力 */
.output { position: relative; }
.tabs { display: flex; gap: .3rem; margin-bottom: .7rem; }
.tab {
  min-height: var(--tap);
  padding: .5rem 1rem;
  border: none; border-bottom: 2px solid transparent;
  background: transparent; color: var(--ink-soft);
  font-size: 1rem; font-family: inherit; font-weight: 600; cursor: pointer;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.output-text {
  white-space: pre-wrap;
  word-break: break-word;
  background: #fdfcf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .9rem;
  margin: 0 0 .8rem;
  font-size: .92rem;
  line-height: 1.75;
  font-family: inherit;
  min-height: 6rem;
}

.output-actions { display: flex; gap: .6rem; }
.note { font-size: .78rem; color: var(--ink-soft); margin: .7rem 0 0; }

.btn {
  min-height: var(--tap);
  padding: .55rem 1.1rem;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem; font-family: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--ink); color: var(--selected-ink); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 40px; padding: .4rem .9rem; font-size: .9rem; }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }

/* プリセット */
.presets { margin-top: .3rem; }
.preset-list { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.preset-chip {
  display: inline-flex; align-items: stretch;
  border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden;
}
.preset-load {
  min-height: 40px; padding: .35rem .8rem;
  border: none; background: var(--surface); color: var(--ink);
  font-size: .92rem; font-family: inherit; cursor: pointer;
}
.preset-del {
  min-height: 40px; padding: 0 .7rem;
  border: none; border-left: 1px solid var(--line);
  background: #f5efe2; color: var(--ink-soft);
  font-size: .85rem; cursor: pointer;
}

/* トースト */
.toast {
  position: fixed;
  left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--selected-ink);
  padding: .6rem 1rem; border-radius: 999px;
  font-size: .9rem; box-shadow: 0 6px 20px rgba(38, 50, 77, .25);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 560px) {
  .field.scale .chip { flex: 0 1 auto; min-width: 6.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .btn:active { transform: none; }
}
