:root {
  --bg: #08162d;
  --bg-accent: #12335e;
  --panel: rgba(236, 244, 255, 0.86);
  --panel-strong: rgba(246, 250, 255, 0.95);
  --line: rgba(166, 194, 230, 0.18);
  --text: #0d2341;
  --muted: #5b7190;
  --primary: #224e86;
  --primary-strong: #0c2345;
  --secondary: #dceeff;
  --danger: #a6464f;
  --shadow: 0 28px 88px rgba(5, 14, 29, 0.34);
  --surface-white: rgba(255, 255, 255, 0.9);
  --surface-blue: rgba(240, 246, 255, 0.82);
  --surface-blue-strong: rgba(230, 239, 252, 0.92);
  --checker-light: rgba(255, 255, 255, 0.96);
  --checker-dark: rgba(236, 244, 252, 0.94);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  font-family: "Space Grotesk", "Noto Sans JP", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(147, 197, 253, 0.18), transparent 24%),
    radial-gradient(circle at right 10% top 8%, rgba(255, 255, 255, 0.08), transparent 18%),
    radial-gradient(circle at left 18% bottom 12%, rgba(96, 165, 250, 0.1), transparent 24%),
    linear-gradient(148deg, #07111f 0%, var(--bg) 42%, var(--bg-accent) 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 34vw;
  height: 34vw;
  min-width: 240px;
  min-height: 240px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(52px);
  opacity: 0.42;
  z-index: 0;
}

body::before {
  top: -10vw;
  right: -8vw;
  background: radial-gradient(circle, rgba(147, 197, 253, 0.22) 0%, rgba(147, 197, 253, 0) 72%);
}

body::after {
  bottom: -12vw;
  left: -8vw;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.14) 0%, rgba(37, 99, 235, 0) 74%);
}

button,
input,
select,
output {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

.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;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
}

.control-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(248, 251, 255, 0.96), rgba(231, 240, 252, 0.9)),
    linear-gradient(135deg, rgba(96, 165, 250, 0.08), transparent 45%);
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(241, 247, 255, 0.9), rgba(225, 236, 250, 0.8)),
    linear-gradient(145deg, rgba(12, 35, 69, 0.08), transparent 42%);
}

.output-preview-stack {
  display: flex;
  flex: 1;
  min-height: 0;
}

.output-preview-pane {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
}

.panel-header h1,
.preview-header h2,
.section-heading h2,
.live-type-head h3 {
  margin: 0;
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.panel-header h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.preview-header h2 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.section-heading h2,
.live-type-head h3 {
  font-size: 1.2rem;
}

.eyebrow,
.status-label {
  margin: 0 0 10px;
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.page-tabs {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
}

.page-tab,
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(34, 78, 134, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(238, 245, 255, 0.92));
  font-weight: 700;
  color: var(--primary-strong);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

.page-tab:hover,
.ghost-link:hover {
  transform: translateY(-1px);
}

.page-tab.is-current {
  color: #f6fbff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  box-shadow: 0 16px 30px rgba(12, 35, 69, 0.34);
}

.panel-copy,
.preview-copy,
.helper-text,
.status-message,
.dropzone-copy,
.empty-library,
.image-meta,
.live-font-meta {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(166, 194, 230, 0.18);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(240, 246, 255, 0.78));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 10px 24px rgba(12, 35, 69, 0.04);
}

.section-heading,
.live-type-head,
.range-head,
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
}

.count-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary-strong);
  font-size: 0.86rem;
  font-weight: 700;
}

.count-badge.muted {
  background: rgba(240, 246, 255, 0.86);
  color: var(--muted);
}

.upload-dropzone {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 154px;
  padding: 18px;
  text-align: center;
  border: 1.5px dashed rgba(34, 78, 134, 0.3);
  border-radius: 18px;
  cursor: pointer;
  background:
    radial-gradient(circle at top, rgba(147, 197, 253, 0.18), transparent 56%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(238, 245, 255, 0.9));
  transition:
    border-color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.upload-dropzone:hover,
.upload-dropzone:focus-visible,
.upload-dropzone.is-active {
  border-color: rgba(34, 78, 134, 0.56);
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(12, 35, 69, 0.12);
  outline: none;
}

.upload-dropzone.is-disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
  box-shadow: none;
}

.dropzone-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.library-actions,
.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

button {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    opacity 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.action-button,
.ghost-button {
  min-height: 48px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 54px;
  padding: 0 18px;
}

.button-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.primary-button {
  color: var(--primary-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(238, 245, 255, 0.94));
  border: 3px solid rgba(12, 35, 69, 0.42);
  box-shadow:
    0 16px 30px rgba(12, 35, 69, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    inset 0 0 0 1px rgba(255, 255, 255, 0.68);
}

.secondary-button {
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(244, 249, 255, 0.94));
  border: 3px solid rgba(34, 78, 134, 0.38);
  box-shadow:
    0 14px 26px rgba(12, 35, 69, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.ghost-button {
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(239, 246, 255, 0.88));
  border: 3px solid rgba(34, 78, 134, 0.32);
  box-shadow:
    0 10px 20px rgba(12, 35, 69, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.warn-button {
  color: var(--danger);
  border: 3px solid rgba(166, 70, 79, 0.42);
  background: rgba(255, 250, 251, 0.94);
  box-shadow:
    0 10px 20px rgba(81, 21, 29, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled),
.warn-button:hover:not(:disabled) {
  border-color: rgba(12, 35, 69, 0.56);
}

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

.control-group label,
.range-head label {
  font-size: 0.94rem;
  font-weight: 700;
}

.range-head output {
  color: var(--primary-strong);
  font-size: 0.92rem;
  font-weight: 700;
}

.control-group input[type="text"],
.control-group select {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 3px solid rgba(12, 35, 69, 0.34);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(242, 247, 255, 0.92));
  color: var(--text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    inset 0 0 0 1px rgba(255, 255, 255, 0.68);
}

.control-group input[type="text"]:focus,
.control-group select:focus,
#densityRange:focus {
  outline: 3px solid rgba(34, 78, 134, 0.42);
  outline-offset: 2px;
}

#densityRange {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  border: 3px solid rgba(12, 35, 69, 0.36);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.98), rgba(238, 245, 255, 0.96));
  box-shadow:
    inset 0 1px 2px rgba(12, 35, 69, 0.08),
    0 6px 14px rgba(12, 35, 69, 0.04);
}

#densityRange::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.98), rgba(232, 241, 251, 0.96));
  border: 3px solid rgba(12, 35, 69, 0.36);
}

#densityRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -6px;
  border: 4px solid rgba(12, 35, 69, 0.84);
  border-radius: 50%;
  background: #ffffff;
  box-shadow:
    0 8px 18px rgba(12, 35, 69, 0.18),
    0 0 0 3px rgba(255, 255, 255, 0.92);
}

#densityRange::-moz-range-track {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.98), rgba(232, 241, 251, 0.96));
  border: 3px solid rgba(12, 35, 69, 0.36);
}

#densityRange::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 4px solid rgba(12, 35, 69, 0.84);
  border-radius: 50%;
  background: #ffffff;
  box-shadow:
    0 8px 18px rgba(12, 35, 69, 0.18),
    0 0 0 3px rgba(255, 255, 255, 0.92);
}

.range-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.84rem;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
  max-height: 340px;
  overflow: auto;
  padding-right: 4px;
}

.image-card {
  position: relative;
  min-width: 0;
  border: 1px solid rgba(166, 194, 230, 0.18);
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(240, 246, 255, 0.88));
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.image-card.is-selected {
  border-color: rgba(34, 78, 134, 0.38);
  box-shadow: 0 16px 28px rgba(12, 35, 69, 0.12);
  transform: translateY(-1px);
}

.image-select {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  text-align: left;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.image-thumb-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 142px;
  aspect-ratio: 1;
  padding: 10px;
  background:
    linear-gradient(45deg, var(--checker-light) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-light) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-light) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-light) 75%),
    linear-gradient(180deg, rgba(132, 192, 235, 0.14), rgba(21, 61, 114, 0.08));
  background-size: 22px 22px;
  background-position:
    0 0,
    0 11px,
    11px -11px,
    -11px 0,
    0 0;
}

.image-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
  filter: drop-shadow(0 8px 18px rgba(21, 61, 114, 0.16));
}

.image-selected-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.97);
  color: var(--primary-strong);
  font-size: 0.74rem;
  font-weight: 700;
}

.image-remove-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 999px;
  background: rgba(12, 35, 69, 0.9);
  color: #fff;
  box-shadow: none;
}

.image-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(166, 194, 230, 0.16);
  background: linear-gradient(180deg, rgba(251, 253, 255, 0.92), rgba(239, 246, 255, 0.98));
}

.image-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  font-weight: 700;
}

.image-meta {
  font-size: 0.76rem;
}

.empty-library {
  padding: 16px;
  text-align: center;
  border: 1px dashed rgba(166, 194, 230, 0.18);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(239, 246, 255, 0.74));
}

.full-empty {
  margin-bottom: 14px;
}

.live-type-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(166, 194, 230, 0.18);
  border-radius: 18px;
  background:
    radial-gradient(circle at top left, rgba(147, 197, 253, 0.14), transparent 36%),
    radial-gradient(circle at bottom right, rgba(12, 35, 69, 0.06), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(240, 246, 255, 0.88));
}

.live-font-meta {
  font-size: 0.9rem;
  font-weight: 700;
}

.preview-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.preview-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-pane-label {
  margin: 0;
  color: var(--primary-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

#typePreviewCanvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(244, 249, 255, 0.95));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 10px 24px rgba(12, 35, 69, 0.06);
}

#verticalTypePreviewCanvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(244, 249, 255, 0.95));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 10px 24px rgba(12, 35, 69, 0.06);
}

.status-card {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(166, 194, 230, 0.18);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(240, 246, 255, 0.86));
}

.status-message[data-state="error"] {
  color: #b24632;
}

.status-message[data-state="success"] {
  color: var(--primary-strong);
}

.status-message[data-state="warning"] {
  color: #9a5b18;
}

.canvas-frame {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  border: 1px solid rgba(166, 194, 230, 0.2);
  border-radius: calc(var(--radius-lg) - 6px);
  overflow: hidden;
  background:
    linear-gradient(45deg, var(--checker-light) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-light) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-light) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-light) 75%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(237, 245, 255, 0.92));
  background-size: 28px 28px;
  background-position:
    0 0,
    0 14px,
    14px -14px,
    -14px 0,
    0 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 16px 34px rgba(12, 35, 69, 0.06);
}

.canvas-frame[data-orientation="vertical"] {
  align-items: flex-start;
  padding: 20px 0;
}

#previewCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
}

#verticalPreviewCanvas {
  display: block;
  width: min(100%, 840px);
  max-width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
}

#verticalTypePreviewCanvas[data-orientation="vertical"] {
  width: 100%;
  max-width: 100%;
  height: auto;
}

.image-gallery-expanded {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  max-height: none;
  min-height: 240px;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .preview-header,
  .section-heading,
  .range-head,
  .live-type-head,
  .page-tabs {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
    gap: 16px;
  }

  .control-panel,
  .preview-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .library-actions,
  .button-row {
    grid-template-columns: 1fr;
  }

  .preview-pair {
    grid-template-columns: 1fr;
  }

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