:root {
  color-scheme: light;
  --ink: #142033;
  --muted: #657084;
  --paper: #fffdf8;
  --surface: #ffffff;
  --line: #dfe4ea;
  --accent: #ec3b2d;
  --accent-dark: #bd2018;
  --blue: #0c3b69;
  --yellow: #ffd640;
  --shadow: 0 22px 60px rgba(20, 32, 51, 0.12);
  font-family: "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 4%, rgba(255, 214, 64, 0.35), transparent 24rem),
    linear-gradient(135deg, #f7f9fc, var(--paper));
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1320px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px clamp(16px, 3vw, 44px) 48px;
}

.app-header,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.app-header {
  margin-bottom: 18px;
}

.eyebrow,
.step-label {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

h2 {
  margin-bottom: 14px;
  font-size: 1.05rem;
}

.mode-badge {
  border: 2px solid #7a3ee6;
  border-radius: 999px;
  padding: 8px 12px;
  color: #5b23bf;
  background: #f2ebff;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.global-message {
  border: 1px solid #f1c16f;
  border-radius: 12px;
  padding: 13px 16px;
  color: #684600;
  background: #fff6db;
}

.global-message[data-kind="error"] {
  border-color: #efa9a3;
  color: #7b1e18;
  background: #fff0ef;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(330px, 0.8fr);
  gap: clamp(18px, 3vw, 34px);
  align-items: start;
}

.preview-panel,
.controls-panel {
  border: 1px solid rgba(20, 32, 51, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.preview-panel {
  padding: clamp(16px, 3vw, 26px);
}

.panel-heading h2 {
  margin: 0;
}

.output-spec {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.canvas-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 360px;
  margin-top: 20px;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(45deg, #e8ebef 25%, transparent 25%),
    linear-gradient(-45deg, #e8ebef 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8ebef 75%),
    linear-gradient(-45deg, transparent 75%, #e8ebef 75%),
    #f7f8fa;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  touch-action: none;
}

[data-preview-canvas] {
  display: block;
  width: min(100%, 740px);
  height: auto;
  cursor: default;
}

.canvas-stage.is-draggable [data-preview-canvas] {
  cursor: grab;
}

.canvas-stage.is-dragging [data-preview-canvas] {
  cursor: grabbing;
}

.drag-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  border-radius: 999px;
  padding: 7px 10px;
  color: #fff;
  background: rgba(12, 59, 105, 0.88);
  font-size: 0.72rem;
  pointer-events: none;
}

.privacy-card {
  display: grid;
  gap: 4px;
  margin-top: 16px;
  border-left: 4px solid #28a46b;
  border-radius: 8px;
  padding: 12px 14px;
  color: #345148;
  background: #eefaf4;
  font-size: 0.82rem;
  line-height: 1.65;
}

.controls-panel {
  overflow: hidden;
}

.control-section {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.section-number {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-weight: 800;
}

.character-count,
.field-help {
  color: var(--muted);
  font-size: 0.76rem;
}

.text-field {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 11px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fff;
}

.text-field:focus,
input[type="range"]:focus-visible,
button:focus-visible,
.upload-button:focus-within {
  outline: 3px solid rgba(236, 59, 45, 0.22);
  outline-offset: 2px;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 2px dashed #9aa5b4;
  border-radius: 11px;
  padding: 10px 16px;
  color: var(--blue);
  background: #f8fafc;
  font-weight: 900;
  cursor: pointer;
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.field-help {
  margin: 8px 0 0;
  line-height: 1.5;
}

.face-sliders {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.consent-check {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fffaf4;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.consent-check input {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

.consent-check a {
  color: inherit;
  font-weight: 700;
}

.turnstile-panel {
  display: grid;
  gap: 6px;
  margin-block: 12px;
  min-height: 74px;
}

.turnstile-panel[hidden] {
  display: none;
}

.upload-button:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.5;
}

.face-sliders label {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  font-weight: 800;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.part-options {
  display: grid;
  gap: 10px;
}

.part-option {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  background: #fafbfc;
  cursor: pointer;
}

.part-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.text-button,
.primary-button,
.secondary-button {
  border: 0;
  cursor: pointer;
}

.text-button {
  justify-self: start;
  padding: 6px 0;
  color: var(--muted);
  background: transparent;
  text-decoration: underline;
}

.text-button.danger {
  color: #a12b23;
}

.finalize-card {
  padding: 24px;
  background: #f6f8fb;
}

.finalize-note {
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 50px;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 900;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 10px 24px rgba(236, 59, 45, 0.25);
}

.secondary-button {
  margin-top: 10px;
  border: 1px solid #cfd6df;
  color: var(--blue);
  background: #fff;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.finalize-status {
  min-height: 1.5em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.finalize-status[data-kind="success"] {
  color: #187348;
  font-weight: 800;
}

.finalize-status[data-kind="error"] {
  color: #a12b23;
  font-weight: 800;
}

@media (max-width: 880px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .canvas-stage {
    min-height: 280px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .primary-button {
    transition: transform 140ms ease, box-shadow 140ms ease;
  }

  .primary-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 13px 28px rgba(236, 59, 45, 0.32);
  }
}
