:root {
  --bg: #05080f;
  --panel: #0c111c;
  --line: rgba(143, 215, 232, 0.25);
  --text: #e8f2ff;
  --muted: #8aa0b8;
  --cyan: #14efff;
  --magenta: #ff2ec8;
  --amber: #ffb224;
  --mint: #63ffd4;
  --btn: #1a2840;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
}

.shell {
  max-width: 520px;
  margin: 0 auto;
  padding: 0.75rem 1rem 2rem;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.back {
  color: var(--mint);
  text-decoration: none;
}

.brand strong {
  color: var(--cyan);
  letter-spacing: 0.08em;
  margin-right: 0.35rem;
}

.field-label {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.35rem;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

#word-input {
  flex: 1;
  min-width: 0;
  min-height: 3.2rem;
  resize: vertical;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font-size: 1.05rem;
  font-family: inherit;
}

.counter {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.preview-wrap {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #03060e;
  margin-bottom: 0.9rem;
}

#preview-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 1500;
}

.controls fieldset {
  border: 0;
  margin: 0 0 0.75rem;
  padding: 0;
}

legend {
  font-size: 0.86rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.picker-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.picker-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 0.92rem;
  cursor: pointer;
  text-align: left;
}

.picker-current {
  color: var(--mint);
  font-size: 0.86rem;
}

.combo-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.65rem;
}

.hint-note {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
  width: 100%;
}

body.picker-open .shell {
  pointer-events: none;
}

.picker-sheet {
  border: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  padding: 0;
  margin: auto auto 0;
  max-width: 520px;
  width: 100%;
  max-height: min(85dvh, 640px);
  background: #0a1018;
  color: var(--text);
}

.picker-sheet::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.sheet-inner {
  display: flex;
  flex-direction: column;
  max-height: min(85dvh, 640px);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  margin: 0;
  font-size: 1rem;
}

.sheet-close {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.75rem 1rem 1.25rem;
  overflow-y: auto;
}

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

.gallery-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.gallery-item.is-active {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(20, 239, 255, 0.3);
}

.gallery-thumb {
  width: 100%;
  height: auto;
  border-radius: 8px;
  aspect-ratio: 4 / 5;
  background: #03060e;
}

.gallery-label {
  font-size: 0.82rem;
}

.gallery-code {
  font-size: 0.7rem;
  color: var(--muted);
}

.palette-swatch {
  width: 100%;
  height: 2.5rem;
  border-radius: 8px;
}

.palette-item {
  flex-direction: row;
  justify-content: flex-start;
  gap: 0.65rem;
}

.palette-item .palette-swatch {
  width: 2.8rem;
  flex-shrink: 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.chip .code {
  color: var(--muted);
  font-size: 0.72rem;
  margin-left: 0.25rem;
}

.chip.is-active {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(20, 239, 255, 0.25);
}

.swatch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-cyan {
  background: var(--cyan);
}

.dot-magenta {
  background: var(--magenta);
}

.dot-amber {
  background: var(--amber);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn-primary,
.ghost-button {
  border-radius: 10px;
  padding: 0.65rem 1rem;
  font-size: 0.92rem;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, #18405a, #0f2a3f);
  color: var(--text);
  border-color: rgba(20, 239, 255, 0.35);
}

.ghost-button {
  background: transparent;
  color: var(--mint);
  border-color: var(--line);
}

.save-status {
  min-height: 1.4em;
  font-size: 0.86rem;
  color: var(--mint);
  margin: 0.35rem 0 0;
}

.privacy-note {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.og-promo {
  display: none;
}

html[data-promo-shot="1"] .capture-hide,
html[data-promo-og="1"] .capture-hide,
html[data-capture="1"] .capture-hide {
  display: none !important;
}

html[data-capture="1"] .shell {
  max-width: 430px;
  padding-top: 0.35rem;
}

html[data-capture="1"] .preview-wrap {
  max-height: 52vh;
}

html[data-capture="1"] #preview-canvas {
  max-height: 52vh;
  object-fit: contain;
}

html[data-promo-og="1"] body {
  background: #05080f;
}

html[data-promo-og="1"] .shell {
  display: none;
}

html[data-promo-og="1"] .og-promo {
  display: block;
  width: 1200px;
  height: 630px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}