:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #c9d3df;
  --line-strong: #8c99aa;
  --text: #1f2937;
  --muted: #5b6778;
  --accent: #0f766e;
  --accent-strong: #0d9488;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #ecf5f6 0%, var(--bg) 40%, #eef2f8 100%);
}

body {
  min-height: 100vh;
}

.site-header,
.site-footer {
  width: min(1260px, 100% - 2rem);
  margin: 0 auto;
}

.site-header {
  padding: 1.25rem 0 0.75rem;
}

.site-header h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.4rem, 2vw + 1rem, 2.15rem);
  letter-spacing: 0.01em;
}

.site-header p {
  margin: 0;
  color: var(--muted);
}

.layout {
  width: min(1260px, 100% - 2rem);
  margin: 0 auto 1rem;
  display: grid;
  grid-template-columns: 320px minmax(300px, 1fr) 300px;
  gap: 1rem;
}

.panel {
  background: color-mix(in srgb, var(--panel) 92%, #f8fdfc 8%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem;
  box-shadow: 0 6px 20px rgba(25, 37, 58, 0.08);
}

h2,
h3 {
  margin: 0.2rem 0 0.7rem;
  line-height: 1.2;
}

h2 {
  font-size: 1rem;
}

h3 {
  font-size: 0.92rem;
  margin-top: 1rem;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.7rem;
}

.compact-row {
  flex-direction: row;
  flex-wrap: wrap;
}

.control-label {
  font-size: 0.9rem;
}

input[type="file"],
input[type="number"],
select,
button {
  font: inherit;
}

input[type="file"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  background: #fff;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

button.secondary {
  background: #fff;
  color: var(--accent);
}

button.secondary:hover {
  background: #f1f5f9;
}

.status {
  margin: 0.3rem 0 0.8rem;
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.86rem;
}

.hint {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.assignment-list {
  display: grid;
  gap: 0.45rem;
}

.assignment-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 0.55rem;
  align-items: center;
}

.assignment-row label {
  font-size: 0.85rem;
  color: var(--muted);
}

.image-catalog {
  max-height: 240px;
  overflow: auto;
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.82rem;
}

.image-catalog li {
  margin-bottom: 0.25rem;
}

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

.preview-wrap {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fbfdff;
  padding: 0.5rem;
  overflow: auto;
}

.fold-guide-wrap {
  margin-top: 0.85rem;
}

.fold-guide-wrap h3 {
  margin-bottom: 0.5rem;
}

.fold-guide-image {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

#previewCanvas {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
  background: #fff;
  cursor: grab;
  touch-action: none;
}

#previewCanvas.is-dragging {
  cursor: grabbing;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.toggles {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  margin: 0.9rem 0;
}

.toggles legend {
  padding: 0 0.3rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.toggles label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.instructions {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  color: #334155;
}

.instructions li {
  margin-bottom: 0.3rem;
}

.site-footer {
  padding: 0.3rem 0 1.3rem;
  color: var(--muted);
}

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

  .controls-panel,
  .options-panel {
    order: 1;
  }

  .preview-panel {
    order: 0;
  }

  .image-catalog {
    max-height: 140px;
  }
}
