:root {
  --bg: #fff6e4;
  --surface: #ffffff;
  --surface-2: #f7e7c4;
  --nav: #241a10;
  --text: #2b1b0e;
  --text-muted: #7a5b40;
  --border: #e9d3a0;
  --accent: #f0790e;
  --accent-light: #ffb35c;
  --accent-dark: #d9650a;
  --accent-deep: #b8500a;
  --green: #3f7d3a;
  --danger: #b3261e;
  --shadow: 0 2px 0 var(--accent-deep), 0 12px 26px -12px rgba(184, 80, 10, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Nunito Sans', -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

h1,
h2,
h3 {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  margin: 0;
}

p {
  margin: 0;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}

button,
input,
select {
  font-family: inherit;
}

.mono {
  font-family: 'IBM Plex Mono', monospace;
}

.kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 55%, var(--accent-dark) 100%);
  border: 1px solid var(--accent-dark);
  color: #fff;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 11px;
  padding: 0.9em 1.7em;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-weight: 700;
  border-radius: 11px;
  padding: 0.85em 1.4em;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.page-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 56px;
  background: var(--nav);
}

.nav a {
  color: var(--accent-light);
  font-weight: 700;
  font-size: 0.94rem;
  margin-right: 32px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fbf1d9;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  text-shadow: 0 0 14px rgba(240, 121, 14, 0.55);
}

.nav-logo span {
  color: var(--accent-light);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 48px 24px 64px;
}

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

.field label {
  font-weight: 700;
  font-size: 0.9rem;
}

.field input {
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 0.75em 1em;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
}

.error-banner {
  background: #fdecea;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.9rem;
}

.pill-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 0.7em 1.3em;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}

.pill-btn.selected {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.complexity-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  cursor: pointer;
  text-align: left;
}

.complexity-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--surface-2);
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.stat-num {
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--accent-dark);
}

/* ---------------------------------------------------------------------------
   Server-rendered pages (Thymeleaf + htmx)

   Everything below styles the markup in src/main/resources/templates. The rules
   above came from the earlier React app and are shared.
   --------------------------------------------------------------------------- */

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fbf1d9;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  margin-right: 0;
  text-shadow: 0 0 14px rgba(240, 121, 14, 0.55);
}

.nav-brand strong { color: var(--accent-light); }
.nav-brand-mark { font-size: 1.3rem; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-logout { margin: 0; }
.nav-logout .btn-text { color: var(--accent-light); }

.container.narrow { max-width: 520px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 32px;
}

.page-title {
  font-size: 2rem;
  color: var(--accent-dark);
}

.page-subtitle {
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 6px;
}

.form-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px;
  margin-top: 24px;
}

.form-card input {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  background: var(--surface);
}

.form-note {
  color: var(--text-muted);
  font-weight: 600;
}

.code-input {
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  text-align: center;
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

.stencil-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 32px;
}

.pagination-status {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.92rem;
}

.stencil-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Photo and stencil shown side by side, so a card is identifiable at a glance. */
.stencil-thumbs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 170px;
}

.thumb {
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.thumb + .thumb { border-left: 1px solid var(--border); }

.thumb img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 12px;
}

.thumb-label {
  position: absolute;
  left: 8px;
  bottom: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255, 250, 240, 0.82);
  padding: 1px 6px;
  border-radius: 4px;
}

.stencil-card-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stencil-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.stencil-name {
  font-weight: 700;
  word-break: break-word;
}

.btn-secondary.full {
  text-align: center;
  margin-top: 6px;
}

/* Confirmation dialog ------------------------------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 20, 8, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  padding: 28px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-head {
  display: flex;
  gap: 16px;
  align-items: center;
}

.modal-thumb {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: var(--surface-2);
  border-radius: 8px;
}

.modal-title {
  font-size: 1.2rem;
  color: var(--accent-dark);
}

.modal-filename {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  word-break: break-word;
}

.modal-body {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Home ---------------------------------------------------------------------- */

.hero {
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 1280px;
}

.hero-image { width: 100%; height: auto; border-radius: 16px; }

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero-title {
  font-size: clamp(1.4rem, 3.4vw, 2.6rem);
  line-height: 1.1;
  color: var(--accent-dark);
  white-space: nowrap;
}

.hero-text {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 600;
}

@media (max-width: 600px) {
  .hero-title {
    white-space: normal;
    font-size: 1.8rem;
  }
}

.section-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 32px;
}

.section-title { font-size: 1.7rem; color: var(--accent-dark); }

.step-grid,
.example-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.example-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }

.step-card { padding: 28px; display: flex; flex-direction: column; gap: 12px; }

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.step-title { font-size: 1.05rem; }
.step-text { color: var(--text-muted); font-weight: 600; font-size: 0.92rem; line-height: 1.5; }

.band { background: var(--surface-2); padding: 8px 0 48px; }

.example-card { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.example-title { font-weight: 700; }
.example-meta { font-size: 0.82rem; color: var(--text-muted); }

.site-footer {
  background: var(--nav);
  color: #c9b896;
  padding: 28px 56px;
  font-weight: 600;
  font-size: 0.85rem;
}

/* Preview ------------------------------------------------------------------- */

.back-link { font-weight: 700; }

.preview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 32px;
}

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

.panel { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }

.panel-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: var(--surface-2);
  min-height: 160px;
}

.panel-body.large { padding: 40px; min-height: 320px; }
.panel-body img { max-width: 100%; max-height: 200px; }
.panel-body.large img { max-height: 420px; }

.preview-side { display: flex; flex-direction: column; gap: 24px; }
.download-block { display: flex; flex-direction: column; gap: 12px; }

.download-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  font-weight: 600;
}

.btn-primary.full,
.btn-secondary.full { display: block; text-align: center; }

/* Upload -------------------------------------------------------------------- */

.upload-page { max-width: 720px; display: flex; flex-direction: column; gap: 40px; }
.upload-form { display: flex; flex-direction: column; gap: 40px; }
.form-section { display: flex; flex-direction: column; gap: 14px; }

.form-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
@media (max-width: 640px) { .form-columns { grid-template-columns: 1fr; } }

.dropzone {
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  cursor: pointer;
  border: 1px solid var(--border);
}

.dropzone.static { cursor: default; }

.dropzone.is-dragging {
  border: 2px dashed var(--accent);
  background: var(--surface-2);
}

.dropzone-preview,
.dropzone-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}

.dropzone-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.dropzone-name { font-weight: 700; }
.dropzone-hint { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }

.choice-row { display: flex; gap: 18px; flex-wrap: wrap; }

/* Radios are hidden; the label itself is the control, and :has() styles the
   selected one. */
.choice-row input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }

.complexity-card { cursor: pointer; flex: 1 1 180px; }
.complexity-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.complexity-card.is-disabled { opacity: 0.45; cursor: not-allowed; }

.choice-title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  display: block;
}

.complexity-card:has(input:checked) .choice-title { color: var(--accent-dark); }
.choice-text { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; font-weight: 600; }

.pill-btn { cursor: pointer; }
.pill-btn:has(input:checked) { border-color: var(--accent); color: var(--accent-dark); }

.form-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 32px;
}

/* Generating ---------------------------------------------------------------- */

.generating {
  padding: 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.generating-title { color: var(--text-muted); }
.generating-note { color: var(--text-muted); font-size: 0.85rem; }
