:root {
  --accent: #008080;
  --accent-dark: #0f5e63;
  --accent-soft: #e8f6f6;
  --text: #24323d;
  --muted: #5b6b76;
  --line: #d8e1e5;
  --bg-top: #f8fbfc;
  --bg-bottom: #eef3f5;
  --card: rgba(255, 255, 255, 0.96);
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --shadow: 0 12px 28px rgba(21, 45, 54, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--text);
  line-height: 1.7;
  background:
    radial-gradient(circle at top left, rgba(0, 128, 128, 0.08), transparent 28%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1240px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 16px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible {
  text-decoration: underline;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero,
.control-panel,
.workspace-header,
.editor-card,
.page-list-card {
  padding: 24px;
}

.eyebrow {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 14px;
  font-size: clamp(1.9rem, 4vw, 2.5rem);
  line-height: 1.3;
}

h2 {
  font-size: 1.08rem;
}

.hero-text,
.section-head p,
.field-hint,
.status-box,
.editor-help,
.editor-empty {
  color: var(--muted);
}

.hero-notes {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.note-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbfc;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.control-panel {
  align-self: start;
  position: sticky;
  top: 16px;
}

.workspace {
  display: grid;
  gap: 18px;
}

.panel-section + .panel-section {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.section-head {
  display: grid;
  gap: 6px;
}

.dropzone {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding: 22px 18px;
  border: 1.5px dashed #9ebfc1;
  border-radius: 18px;
  background: linear-gradient(180deg, #fbfdfd 0%, #f3f9f9 100%);
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.dropzone.compact {
  padding: 18px 14px;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: #edf8f8;
  transform: translateY(-1px);
}

.dropzone input {
  display: none;
}

.dropzone-title {
  color: var(--text);
  font-weight: 700;
}

.dropzone-text {
  color: var(--muted);
  font-size: 0.92rem;
}

.field-hint {
  margin-top: 10px;
  font-size: 0.84rem;
}

.file-summary {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f9fbfc;
}

.summary-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.field-grid.single {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-weight: 700;
  font-size: 0.94rem;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  padding: 12px 14px;
  border: 1px solid #c7d4d9;
  border-radius: 14px;
  background: #fff;
  color: var(--text);
}

select:focus,
input:focus {
  outline: 3px solid rgba(0, 128, 128, 0.15);
  border-color: var(--accent);
}

.range-value {
  color: var(--accent-dark);
  font-size: 0.9rem;
}

.button-stack,
.button-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

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

.button-grid .ghost-button {
  grid-column: 1 / -1;
}

.primary-button,
.secondary-button,
.ghost-button,
.thumbnail-button {
  appearance: none;
  border-radius: 14px;
  padding: 12px 16px;
  border: 1px solid transparent;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #0b6770);
  color: #fff;
}

.secondary-button {
  background: #f3f8f8;
  border-color: #d2dfdf;
  color: var(--accent-dark);
}

.ghost-button,
.thumbnail-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.thumbnail-button:hover,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.ghost-button:focus-visible,
.thumbnail-button:focus-visible {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.status-box,
.error-box {
  padding: 14px;
  border-radius: 16px;
  font-size: 0.92rem;
}

.status-box {
  border: 1px solid var(--line);
  background: #f9fbfc;
}

.error-box {
  margin-top: 10px;
  border: 1px solid #f3b3ad;
  background: var(--danger-soft);
  color: var(--danger);
}

.preview-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #f1f6f6;
  color: var(--accent-dark);
  font-size: 0.84rem;
  font-weight: 700;
}

.loading-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #c7dede;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.editor-stage {
  display: grid;
  place-items: center;
  min-height: 540px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(45deg, #f7f9f9 25%, transparent 25%, transparent 75%, #f7f9f9 75%, #f7f9f9),
    linear-gradient(45deg, #f7f9f9 25%, #ffffff 25%, #ffffff 75%, #f7f9f9 75%, #f7f9f9);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  overflow: auto;
  padding: 18px;
}

.editor-empty {
  max-width: 460px;
  text-align: center;
}

#editorCanvas {
  display: block;
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 10px 22px rgba(35, 50, 61, 0.12);
  touch-action: none;
}

.editor-help {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 0.86rem;
}

.page-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.empty-state {
  padding: 24px;
  border: 1px dashed #c7d4d9;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  text-align: center;
}

.thumbnail-button {
  padding: 12px;
  text-align: left;
}

.thumbnail-button.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 128, 128, 0.12);
}

.thumbnail-preview {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbfc;
  overflow: hidden;
}

.thumbnail-preview canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 6px 16px rgba(35, 50, 61, 0.08);
}

.thumbnail-meta {
  display: grid;
  gap: 2px;
  margin-top: 10px;
}

.thumbnail-title {
  font-size: 0.96rem;
  font-weight: 700;
}

.thumbnail-text {
  font-size: 0.82rem;
  color: var(--muted);
}

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

  .control-panel {
    position: static;
  }

  .editor-stage {
    min-height: 420px;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 14px, 1240px);
    padding: 14px 0 32px;
  }

  .hero,
  .control-panel,
  .workspace-header,
  .editor-card,
  .page-list-card {
    padding: 18px;
  }

  .field-grid,
  .button-grid,
  .page-list {
    grid-template-columns: 1fr;
  }

  .editor-stage {
    min-height: 360px;
    padding: 10px;
  }

  .loading-card {
    align-items: flex-start;
    flex-direction: column;
  }

  select,
  button {
    font-size: 16px;
  }
}
