:root {
  --accent: #b42332;
  --accent-soft: #fbeaec;
  /* アクセント色の上に載せる文字色 */
  --on-accent: #fff;
  --ink: #2b2320;
  --muted: #7a6e68;
  --paper: #faf6f0;
  --card: #fff;
  --line: #e2d8cc;
  --chip: #f3ede5;
  --nori: #1f2a22;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #e0525f;
    --accent-soft: #3a1d21;
    --ink: #eee6df;
    --muted: #a99d96;
    --paper: #171413;
    --card: #221e1c;
    --line: #3a3330;
    --chip: #2e2825;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}

.site-header,
main,
.site-footer {
  width: min(100%, 520px);
  margin-inline: auto;
}

.site-header {
  padding: 20px 0 12px;
}

.site-header h1 {
  font-size: 1.35rem;
  color: var(--accent);
}

.site-header p {
  font-size: 0.85rem;
  color: var(--muted);
}

.items {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 14px;
}

.item {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  scroll-margin-top: 12px;
}

.item.is-cheapest {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.item-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-no {
  font-weight: 700;
  white-space: nowrap;
}

.item-memo {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  color: inherit;
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--line);
  padding: 4px 2px;
}

.item-remove {
  flex: none;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--chip);
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.field {
  min-width: 0;
  border: none;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.field legend,
.field-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0;
  margin-bottom: 6px;
}

.field-label {
  margin-bottom: 0;
}

.cuts,
.quick-counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.chip {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--chip);
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.chip:has(input:focus-visible),
.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: right;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
}

.input-row input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

.input-row input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.suffix {
  font-weight: 700;
  min-width: 1.5em;
}

.plies {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.result {
  position: relative;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.result-main {
  font-size: 0.9rem;
  color: var(--muted);
}

.is-ready .result-main {
  color: inherit;
  font-size: 1rem;
}

.result-main strong {
  font-size: 2rem;
  color: var(--ink);
}

.is-cheapest .result-main strong {
  color: var(--accent);
}

.result-sub {
  font-size: 0.85rem;
  color: var(--muted);
}

.result-sub:empty {
  display: none;
}

.badge {
  display: none;
  position: absolute;
  top: 12px;
  right: 0;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 999px;
}

.is-cheapest .badge {
  display: inline-block;
}

.site-footer {
  padding: 28px 0 8px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.site-footer a {
  color: var(--accent);
}

.tool-nav {
  margin-bottom: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.tool-nav h2 {
  margin-bottom: 10px;
  font-size: 0.85rem;
}

.tool-nav h2 a {
  color: var(--ink);
  text-decoration: none;
}

.tool-nav ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.tool-nav ul a {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}

.tool-nav ul a[aria-current="page"] {
  border-color: var(--accent);
  color: var(--accent);
}

.action-bar {
  position: fixed;
  inset: auto 0 0;
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.action-bar button {
  min-height: 52px;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn-clear {
  flex: 1;
  max-width: 140px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
}

.btn-add {
  flex: 2;
  max-width: 370px;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.05rem;
}

.page-top {
  padding-bottom: 24px;
}

.tools {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 12px;
}

.tools a {
  display: grid;
  gap: 2px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: inherit;
  text-decoration: none;
}

.tools a:hover {
  border-color: var(--accent);
}

.tool-name {
  font-weight: 700;
  color: var(--accent);
}

.tool-desc {
  font-size: 0.9rem;
  color: var(--muted);
}
