:root {
  color-scheme: light dark;
  --line: color-mix(in srgb, CanvasText 28%, Canvas);
  --soft: color-mix(in srgb, CanvasText 7%, Canvas);
  --muted: color-mix(in srgb, CanvasText 55%, Canvas);
  --danger: color-mix(in srgb, CanvasText 35%, #d33);
}

body {
  margin: 0;
  padding: 1rem;
  background: Canvas;
  color: CanvasText;
  line-height: 1.6;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans JP", "Hiragino Sans", sans-serif;
  font-size: 15px;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
}

p {
  margin: 0.5rem 0;
}

main {
  max-width: 64rem;
  margin-inline: auto;
}

#sheet {
  max-width: 100%;
}

.total {
  font-size: 0.95rem;
}

input,
button,
select,
textarea {
  box-sizing: border-box;
  color: inherit;
  font: inherit;
}

input[type="text"],
input[type="file"],
select,
textarea {
  max-width: 100%;
  padding: 0.1rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: Canvas;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

button {
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--soft);
  cursor: pointer;
}

button:hover {
  background: color-mix(in srgb, CanvasText 14%, Canvas);
}

button.mini {
  padding: 0.05rem 0.4rem;
  font-size: 0.75rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.8rem;
}

.field {
  margin: 0.6rem 0;
}

.caption {
  display: block;
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.models {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.model {
  border: 1px solid var(--line);
  border-radius: 4px;
}

.model-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(5.5rem, 10rem) minmax(5.5rem, 10rem);
  gap: 0.35rem 0.6rem;
  align-items: flex-end;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.head-field {
  min-width: 0;
  margin: 0;
}

.head-field input,
.head-field select {
  width: 100%;
}

.head-name input {
  font-size: 0.95rem;
}

.model-credit {
  margin: 0;
  text-align: right;
  white-space: nowrap;
}

.model-credit strong {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.profile {
  display: grid;
  grid-template-columns: repeat(9, minmax(2rem, 1fr));
  gap: 0.3rem 0.15rem;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--line);
}

.stat {
  text-align: center;
}

.stat .value {
  display: flex;
  align-items: baseline;
  justify-content: center;
}

.stat input {
  width: 100%;
  min-width: 0;
  padding: 0.1rem;
  text-align: center;
}

.lists {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
}

.list {
  margin: 0;
}

.list input[type="text"] {
  width: 100%;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.2rem;
}

.value-row {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.value-row input {
  flex: 1 1 6rem;
  min-width: 0;
}

.equipment-rows {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.2rem auto;
  gap: 0.2rem 0.25rem;
  align-items: center;
  margin-bottom: 0.2rem;
}

.equipment-rows input {
  width: 100%;
  min-width: 0;
}

.model-actions {
  margin: 0;
  padding: 0 0.5rem 0.5rem;
  text-align: right;
}

.model-memo {
  display: block;
  padding: 0 0.5rem 0.5rem;
}

.model-memo textarea {
  display: block;
  width: 100%;
  min-height: 5rem;
  resize: vertical;
}

.model-actions button + button {
  margin-left: 0.25rem;
}

.banner {
  margin: 0 0 0.8rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--danger);
  border-radius: 3px;
  background: color-mix(in srgb, Canvas 88%, #d33);
}

.tools {
  display: block;
  margin: 0.8rem 0;
}

noscript {
  display: block;
  margin-top: 1rem;
}

.snapshot-stage {
  position: fixed;
  top: 0;
  left: -100000px;
}

.snapshot-content {
  box-sizing: border-box;
  width: 64rem;
  padding: 1rem;
  background: #fff;
  color: #111;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans JP", "Hiragino Sans", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  --line: #b9b9b9;
  --soft: #f2f2f2;
  --muted: #666;
  --danger: #a33;
}

#snapshot-sheet {
  width: 100%;
  max-width: 100%;
}

.snapshot-content .models {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.snapshot-value {
  min-height: 1.6em;
  margin: 0;
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.snapshot-content .head-name .snapshot-value {
  font-size: 0.95rem;
}

.snapshot-content .head-dataName {
  grid-column: 1 / 3;
}

.snapshot-content .stat .snapshot-value,
.snapshot-content .model-credit .snapshot-value {
  width: 100%;
  text-align: center;
}

.snapshot-content .value-row .snapshot-value {
  flex: 1 1 6rem;
  min-width: 0;
}

.snapshot-content .equipment-rows .snapshot-value {
  width: 100%;
  min-width: 0;
}

.snapshot-content .equipment-rows {
  grid-template-columns: minmax(0, 1fr);
}

.snapshot-content .list > .snapshot-value {
  width: 100%;
}

.snapshot-content .model-memo .snapshot-value {
  width: 100%;
}

@media (max-width: 402px) {
  body {
    padding: 0.75rem;
  }

  .model-head {
    grid-template-columns: minmax(0, 1fr) minmax(5.5rem, auto) minmax(5.5rem, auto);
    gap: 0.35rem 0.75rem;
  }

  .profile {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 0.3rem 0.25rem;
  }

  .list {
    max-width: none;
  }

  .value-row {
    gap: 0.5rem;
  }

  .equipment-rows {
    column-gap: 0.5rem;
  }
}
