:root {
  color-scheme: light;
  --bg: #fbf7f8;
  --surface: #ffffff;
  --surface-soft: #f6eef4;
  --ink: #27241f;
  --muted: #6d675f;
  --line: #ddd3dc;
  --accent: #4f6fcf;
  --accent-strong: #304f9e;
  --accent-soft: #edf0ff;
  --warn: #a33b36;
  --warn-soft: #f5e2dd;
  --bar-bg: #eee6eb;
  --bar-fill: linear-gradient(90deg, #e85d75 0%, #f0a34a 22%, #f0d95a 42%, #54b97f 62%, #4b8fdc 82%, #8e64d8 100%);
  --focus: #c77829;
  --rainbow: linear-gradient(90deg, #e85d75 0%, #f0a34a 18%, #f0d95a 34%, #54b97f 52%, #4b8fdc 70%, #8e64d8 88%, #c95cb4 100%);
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.36)),
    linear-gradient(135deg, rgba(232, 93, 117, 0.12), rgba(240, 217, 90, 0.14) 28%, rgba(84, 185, 127, 0.12) 52%, rgba(75, 143, 220, 0.13) 74%, rgba(142, 100, 216, 0.12)),
    var(--bg);
  color: var(--ink);
  line-height: 1.7;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  padding: 44px 0 28px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(251, 247, 248, 0.78) 100%),
    var(--rainbow);
  position: relative;
}

.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 5px;
  background: var(--rainbow);
}

.site-header h1 {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 4.5rem);
  line-height: 1;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: #4b463f;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.lead {
  margin: 18px 0 6px;
  font-size: 1.15rem;
  font-weight: 700;
}

.site-header p:not(.eyebrow) {
  max-width: 760px;
}

.privacy-note {
  display: inline-block;
  margin: 16px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-weight: 700;
}

.app-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  padding: 32px 0 56px;
  align-items: start;
}

.input-panel,
.preview-panel {
  min-width: 0;
}

.preview-panel {
  align-self: start;
}

.form-section {
  --section-color: var(--accent);
  --section-soft: rgba(79, 111, 207, 0.1);
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.section-physical {
  --section-color: #d94e5f;
  --section-soft: rgba(217, 78, 95, 0.12);
}

.section-identity {
  --section-color: #c69b14;
  --section-soft: rgba(240, 217, 90, 0.2);
}

.section-expression {
  --section-color: #409461;
  --section-soft: rgba(84, 185, 127, 0.15);
}

.section-romantic {
  --section-color: #3f7fc9;
  --section-soft: rgba(75, 143, 220, 0.15);
}

.section-sexual {
  --section-color: #7b5bc7;
  --section-soft: rgba(142, 100, 216, 0.15);
}

.form-section:first-child {
  padding-top: 0;
}

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.3;
}

.compact-heading h2 {
  font-size: 1.05rem;
}

.section-description {
  margin: 0 0 18px;
  padding-left: 16px;
  border-left: 3px solid var(--section-color, var(--line));
  color: var(--muted);
  font-size: 0.95rem;
}

.section-number {
  color: var(--section-color, var(--accent-strong));
  font-size: 0.8rem;
  font-weight: 900;
}

.compact-heading .section-number {
  color: #4b463f;
}

.radio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 0;
  margin: 0;
  border: 0;
}

.radio-grid label {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
}

.field,
.label-control,
.target-name {
  margin-top: 16px;
}

label {
  font-weight: 700;
}

input[type="text"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}

.slider-list {
  display: grid;
  gap: 18px;
}

.slider-row {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(90deg, var(--section-color), rgba(255, 255, 255, 0.35)) border-box;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.value-badge {
  min-width: 3ch;
  color: var(--accent-strong);
  font-weight: 900;
  text-align: right;
}

.range-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

input[type="range"] {
  --range-value: 0%;
  width: 100%;
  accent-color: var(--section-color, #8e64d8);
  appearance: none;
  height: 28px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--section-color, #8e64d8) 0%,
    var(--section-color, #8e64d8) var(--range-value),
    #ffffff var(--range-value),
    #ffffff 100%
  );
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -6px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--section-color, #8e64d8);
  box-shadow: 0 1px 4px rgba(39, 36, 31, 0.24);
}

input[type="range"]::-moz-range-track {
  height: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
}

input[type="range"]::-moz-range-progress {
  height: 12px;
  border-radius: 999px;
  background: var(--section-color, #8e64d8);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--section-color, #8e64d8);
  box-shadow: 0 1px 4px rgba(39, 36, 31, 0.24);
}

.target-actions {
  display: flex;
  justify-content: flex-end;
}

.label-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.label-control label {
  grid-column: 1 / -1;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 8px 5px 11px;
  border: 1px solid var(--section-color, var(--line));
  border-radius: 999px;
  background: var(--section-soft, var(--accent-soft));
  color: var(--ink);
  font-weight: 700;
}

.tag button {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--section-color, var(--accent-strong));
}

.primary-button {
  padding: 9px 14px;
  background: var(--ink);
  color: #fff;
  text-shadow: none;
}

.secondary-button {
  padding: 9px 14px;
  background: var(--section-color, var(--accent));
  color: #fff;
  text-shadow: 0 1px 2px rgba(39, 36, 31, 0.25);
}

.secondary-button {
  margin-top: 10px;
}

.secondary-button:hover {
  filter: saturate(1.08) brightness(0.96);
}

.primary-button:hover {
  background: #4b463f;
}

.danger-button {
  padding: 9px 14px;
  border: 1px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
}

.danger-button:hover {
  background: #f4f1ec;
}

.remove-button {
  padding: 9px 14px;
  background: var(--section-soft, var(--accent-soft));
  color: var(--section-color, var(--accent-strong));
}

.ghost-button {
  margin-top: 12px;
  padding: 9px 14px;
  border: 1px solid var(--section-color, var(--line));
  background: var(--section-soft, rgba(255, 255, 255, 0.76));
  color: var(--section-color, var(--muted));
}

.preview-sticky {
  position: static;
}

.map-card {
  border: 2px solid transparent;
  border-radius: 8px;
  background:
    linear-gradient(#fffdfd, #fffdfd) padding-box,
    linear-gradient(180deg, #e85d75 0%, #f0a34a 18%, #f0d95a 34%, #54b97f 52%, #4b8fdc 70%, #8e64d8 88%, #c95cb4 100%) border-box;
  box-shadow: 0 18px 38px rgba(39, 36, 31, 0.12);
  overflow: hidden;
}

.card-inner {
  padding: 24px;
}

.card-title {
  margin: 0 0 22px;
  text-align: center;
  font-size: 1.35rem;
  letter-spacing: 0;
  color: var(--ink);
}

.preview-section {
  --preview-color: var(--accent);
  --preview-soft: var(--accent-soft);
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.preview-section[data-preview-section="physicalSex"] {
  --preview-color: #d94e5f;
  --preview-soft: rgba(217, 78, 95, 0.12);
}

.preview-section[data-preview-section="genderIdentity"] {
  --preview-color: #c69b14;
  --preview-soft: rgba(240, 217, 90, 0.2);
}

.preview-section[data-preview-section="genderExpression"] {
  --preview-color: #409461;
  --preview-soft: rgba(84, 185, 127, 0.15);
}

.preview-section[data-preview-section="romanticAttraction"] {
  --preview-color: #3f7fc9;
  --preview-soft: rgba(75, 143, 220, 0.15);
}

.preview-section[data-preview-section="sexualAttraction"] {
  --preview-color: #7b5bc7;
  --preview-soft: rgba(142, 100, 216, 0.15);
}

.preview-section:first-of-type {
  border-top: 0;
}

.preview-section h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--preview-color);
}

.preview-empty {
  color: var(--muted);
}

.preview-metric {
  display: grid;
  grid-template-columns: minmax(76px, 1fr) minmax(96px, 1.3fr) 3ch;
  align-items: center;
  gap: 10px;
  margin: 7px 0;
}

.mini-bar {
  height: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bar-bg);
  overflow: hidden;
}

.mini-bar span {
  display: block;
  height: 100%;
  background: var(--preview-color);
}

.preview-labels {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
}

.preview-label-title {
  color: #4b463f;
  font-size: 0.9rem;
  font-weight: 700;
}

.preview-label {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--preview-color);
  background: var(--preview-soft);
  font-weight: 700;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.save-fallback {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.save-fallback p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.save-fallback img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.hidden {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .container {
    width: min(100% - 22px, 1120px);
  }

  .site-header {
    padding-top: 30px;
  }

  .radio-grid,
  .label-control,
  .action-row {
    grid-template-columns: 1fr;
  }

  .preview-metric {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
