:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #1f1f1f;
  --muted: #757575;
  --line: #e8e8e8;
  --accent: #1772d0;
  --error: #bf2f35;
  --success: #1f7a3d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
}

body {
  min-height: 100vh;
}

.material-symbols-rounded {
  font-variation-settings:
    "FILL" 0,
    "wght" 500,
    "GRAD" 0,
    "opsz" 24;
  font-size: 1.15rem;
  line-height: 1;
}

.page {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 24px 20px 32px;
}

.site-title {
  margin: 0 0 20px;
  color: #000000;
  text-align: center;
  font-size: clamp(1.4rem, 2.6vw, 1.8rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.site-title-prefix,
.site-title-main,
.site-title-sub {
  display: block;
}

.site-title-prefix {
  margin-bottom: 4px;
  font-size: 0.46em;
  font-weight: 500;
}

.site-title-sub {
  margin-top: 4px;
  font-size: 0.46em;
  font-weight: 500;
  color: #7d7d7d;
}

.site-credit {
  margin: 28px 0 0;
  text-align: center;
  font-size: 0.72rem;
  color: #9a9a9a;
}

.actions-panel {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  justify-content: center;
}

.preview-actions {
  margin-top: 18px;
  margin-bottom: 0;
}

.preview-actions .action-button {
  min-width: 0;
}

.footer-actions {
  margin-top: 30px;
  margin-bottom: 0;
}

.support-link-section {
  width: 100%;
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.support-link-label {
  margin: 0;
  font-size: 0.76rem;
  color: #8c8c8c;
  text-align: center;
}

.support-link-note {
  margin: -4px 0 0;
  font-size: 0.82rem;
  color: #8c8c8c;
  text-align: center;
}

.ogp-link-card {
  width: min(100%, 420px);
  display: flex;
  align-items: stretch;
  gap: 12px;
  padding: 10px;
  border: 1px solid #ececec;
  border-radius: 18px;
  background: #ffffff;
  color: inherit;
  text-decoration: none;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.ogp-link-card:hover {
  border-color: #dcdcdc;
  background: #fafafa;
}

.ogp-link-image {
  width: 84px;
  height: 84px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f4f4f4;
}

.ogp-link-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  text-align: left;
}

.ogp-link-site {
  font-size: 0.72rem;
  color: #8c8c8c;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ogp-link-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
  color: #242424;
  overflow-wrap: anywhere;
  word-break: break-word;
}

button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.92rem;
  font: inherit;
  cursor: pointer;
  transition:
    border-color 120ms ease,
    background-color 120ms ease,
    transform 120ms ease,
    box-shadow 120ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:focus-visible {
  outline: 2px solid rgba(23, 114, 208, 0.14);
  outline-offset: 2px;
  border-color: var(--accent);
}

button:hover:not(:disabled) {
  border-color: #cfcfcf;
  background: #fafafa;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.action-button {
  min-height: 44px;
  padding: 10px 15px;
}

.action-button .material-symbols-rounded {
  color: #575757;
}

.action-button-primary {
  background: #111111;
  border-color: #111111;
  color: #ffffff;
}

.action-button-primary .material-symbols-rounded {
  color: #ffffff;
}

.action-button-primary:hover:not(:disabled) {
  background: #ffffff;
  border-color: #111111;
  color: #111111;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(17, 17, 17, 0.12);
}

.action-button-primary:hover:not(:disabled) .material-symbols-rounded {
  color: #111111;
}

.action-button-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(17, 17, 17, 0.1);
}

.action-button-download {
  min-width: min(100%, 280px);
  padding-left: 24px;
  padding-right: 24px;
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border-radius: 18px;
  padding: 18px;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-panel > * {
  width: 100%;
}

.panel h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.preview-shape-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.preview-shape-controls button {
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
}

.preview-shape-controls button[data-active="true"] {
  border-color: var(--accent);
  background: #f7fbff;
}

.shape-button .material-symbols-rounded {
  font-size: 1.15rem;
  color: #6f6f6f;
}

.preview-shape-controls button[data-active="true"] .material-symbols-rounded {
  color: var(--accent);
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-section + .control-section {
  padding-top: 18px;
  border-top: 1px solid #f1f1f1;
}

.control-section h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.preview-frame {
  min-height: 460px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.preview-mask {
  width: min(100%, 640px);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #f2f2f2;
}

.preview-mask[data-shape="square"] {
  border-radius: 0;
}

.preview-mask[data-shape="rounded"] {
  border-radius: 28px;
}

.preview-mask[data-shape="circle"] {
  border-radius: 999px;
}

#previewImage {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: auto;
  display: none;
}

#previewImage.visible {
  display: block;
}

#previewPlaceholder {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

.selection-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.quick-edit-section {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.quick-edit-section + .quick-edit-section {
  margin-top: 24px;
}

.quick-edit-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: #666666;
  text-align: center;
}

.selection-chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 8px 12px;
  font-size: 0.8rem;
  color: #5f5f5f;
  background: #ffffff;
}

.selection-chip-button {
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.selection-chip-button:hover:not(:disabled) {
  border-color: #d6d6d6;
  background: #fafafa;
}

.selection-chip-text {
  color: var(--text);
  font-weight: 500;
}

.selection-chip-icon {
  color: #8d8d8d;
  font-size: 1.05rem;
}

.preview-color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.palette-chip {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  padding: 0;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.palette-chip:hover:not(:disabled) {
  border-color: #d6d6d6;
  background: #fafafa;
}

.palette-swatch {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.visually-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.help-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.material-controls,
.skin-tone-controls,
.hair-tone-controls,
.color-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-note {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

.material-row,
.skin-tone-row,
.hair-tone-row,
.color-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #ffffff;
}

.material-row {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 220px);
  align-items: center;
  gap: 12px;
}

.material-info,
.skin-tone-info,
.hair-tone-info,
.color-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.material-label,
.skin-tone-label,
.hair-tone-label,
.color-label {
  font-size: 0.92rem;
  font-weight: 600;
}

.material-meta,
.skin-tone-meta,
.hair-tone-meta,
.color-meta {
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}

.skin-tone-row,
.hair-tone-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.skin-tone-presets,
.hair-tone-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skin-tone-preset,
.hair-tone-preset {
  padding: 8px 12px;
  font-size: 0.82rem;
  border-radius: 999px;
}

.skin-tone-preset[data-active="true"],
.hair-tone-preset[data-active="true"] {
  border-color: var(--accent);
  background: #f7fbff;
}

.material-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--text);
  font-size: 0.92rem;
}

.material-select:focus-visible {
  outline: 2px solid rgba(23, 114, 208, 0.12);
  border-color: var(--accent);
}

.color-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
}

.color-input {
  width: 44px;
  height: 34px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.lock-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: #5a5a5a;
}

.status {
  margin: 12px 0 0;
  padding: 0;
  font-size: 0.9rem;
  min-height: 20px;
}

.status[data-type="error"] {
  color: var(--error);
}

.status[data-type="success"] {
  color: var(--success);
}

.status[data-type="info"] {
  color: var(--muted);
}

.picker-dialog {
  border: none;
  padding: 0;
  background: transparent;
}

.picker-dialog::backdrop {
  background: rgba(20, 20, 20, 0.12);
}

.picker-dialog-inner {
  width: min(92vw, 560px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #ffffff;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
}

.picker-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.picker-dialog-header h2 {
  margin: 0;
  font-size: 1rem;
}

.color-picker-dialog-inner {
  width: min(92vw, 420px);
}

.color-picker-note {
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: #8c8c8c;
  text-align: center;
}

.picker-close {
  width: 42px;
  height: 42px;
  padding: 0;
  flex-shrink: 0;
}

.picker-close .material-symbols-rounded {
  font-size: 1.1rem;
  color: #575757;
}

.picker-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  gap: 12px;
}

.picker-option {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  padding: 10px;
  aspect-ratio: 1 / 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.picker-option[data-active="true"] {
  border-color: var(--accent);
  background: #f7fbff;
}

.picker-option-frame {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  background:
    linear-gradient(0deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.02)),
    #fbfbfb;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.picker-option-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: translate(var(--thumb-shift-x, 0%), var(--thumb-shift-y, 0%))
    scale(var(--thumb-scale, 1.2));
  transform-origin: var(--thumb-origin-x, 50%) var(--thumb-origin-y, 50%);
  pointer-events: none;
}

.picker-option-none {
  font-size: 0.88rem;
  color: #7a7a7a;
  font-weight: 600;
}

.picker-option-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--accent);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.picker-option[data-active="true"] .picker-option-check {
  display: inline-flex;
}

.color-picker-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.color-picker-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 52px;
  border: 1px solid #ececec;
  border-radius: 16px;
  background: #ffffff;
  padding: 0;
  position: relative;
}

.color-picker-swatch::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--swatch-color, #ffffff);
  border: 1px solid rgba(0, 0, 0, 0.12);
  display: block;
}

.color-picker-swatch[data-active="true"] {
  border-color: var(--accent);
  background: #f7fbff;
}

.color-picker-swatch[data-active="true"]::after {
  content: "check";
  font-family: "Material Symbols Rounded";
  font-size: 1rem;
  line-height: 1;
  color: var(--accent);
  position: absolute;
  top: 8px;
  right: 8px;
}

.color-picker-actions {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.color-picker-custom-btn {
  min-height: 40px;
  padding: 10px 16px;
}

@media (max-width: 720px) {
  .page {
    padding-left: 16px;
    padding-right: 16px;
  }

  .preview-actions {
    width: 100%;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .preview-actions .action-button {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 12px;
    gap: 6px;
    font-size: 0.88rem;
  }

  .preview-actions .material-symbols-rounded {
    font-size: 1.05rem;
  }

  .preview-frame {
    min-height: 320px;
  }

  .ogp-link-card {
    width: 100%;
  }

  .ogp-link-image {
    width: 72px;
    height: 72px;
  }

  .color-picker-options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }

  .material-row {
    grid-template-columns: 1fr;
  }

  .color-row {
    grid-template-columns: 1fr auto;
  }

  .lock-toggle {
    grid-column: 1 / -1;
    justify-self: start;
  }
}
