/* ---------- Reset & base ---------- */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
}

:root {
  --cream: #FAF5EC;
  --cream-deep: #F2E9DA;
  --ink: #3B2A20;
  --ink-soft: #6B5A4D;
  --terracotta: #C97B53;
  --terracotta-dark: #A35F3D;
  --sage: #8AA17E;
  --line: #E4D8C5;
  --white: #FFFFFF;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-soft: 0 4px 16px rgba(59, 42, 32, 0.08);
}

body {
  font-family: Calibri, Carlito, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--cream);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.lang-toggle {
  border: 1px solid var(--terracotta);
  color: var(--terracotta-dark);
  background: var(--white);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-toggle:hover { background: var(--terracotta); color: var(--white); }

/* ---------- Progress ---------- */
.progress-wrap {
  padding: 12px 20px 0;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.progress-track {
  height: 6px;
  background: var(--cream-deep);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--terracotta);
  border-radius: 999px;
  transition: width 0.25s ease;
  width: 0%;
}
.progress-label {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 6px;
}

/* ---------- Main layout ---------- */
.app-main {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.screen-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 6px;
}
.screen-body {
  font-size: 0.98rem;
  color: var(--ink-soft);
  margin: 0 0 20px;
  line-height: 1.5;
}

/* ---------- Intro ---------- */
.intro {
  text-align: center;
  padding-top: 24px;
}
.intro-title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 12px;
}
.intro-subtitle {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 0 0 18px;
}
.intro-body {
  font-size: 0.98rem;
  color: var(--ink-soft);
  max-width: 480px;
  margin: 0 auto 32px;
  line-height: 1.6;
}
.intro-citation {
  font-size: 0.78rem;
  color: var(--ink-soft);
  opacity: 0.75;
  margin-top: 36px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-md);
  padding: 13px 26px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 46px;
  transition: transform 0.1s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--terracotta);
  color: var(--white);
}
.btn-primary:hover { background: var(--terracotta-dark); }
.btn-primary:disabled {
  background: var(--cream-deep);
  color: var(--ink-soft);
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-secondary:hover { background: var(--cream-deep); }
.btn-text {
  background: transparent;
  color: var(--ink-soft);
  padding: 10px 14px;
}
.btn-text:hover { color: var(--ink); }
.btn-block { width: 100%; }

/* ---------- Selection counter ---------- */
.counter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  position: sticky;
  top: 78px;
  z-index: 5;
}
.counter-count {
  font-weight: 700;
  font-size: 1rem;
}
.counter-count.complete { color: var(--terracotta-dark); }

/* ---------- Custom value input ---------- */
.custom-add {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
}
.custom-add input[type="text"] {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--white);
  color: var(--ink);
}
.custom-add input[type="text"]:focus {
  outline: 2px solid var(--terracotta);
  outline-offset: 1px;
}
.form-hint {
  font-size: 0.82rem;
  color: var(--terracotta-dark);
  margin: -14px 0 16px;
  min-height: 1.1em;
}

/* ---------- Category groups & value grid ---------- */
.category-group {
  margin-bottom: 22px;
}
.category-name {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--terracotta-dark);
  margin-bottom: 10px;
}
.value-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.value-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1.5px solid var(--line);
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  font-size: 0.92rem;
  cursor: pointer;
  min-height: 46px;
  user-select: none;
  transition: all 0.12s ease;
  line-height: 1.25;
}
.value-chip:hover { border-color: var(--terracotta); }
.value-chip.selected {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: var(--white);
  font-weight: 700;
}
.value-chip.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.value-chip.disabled:hover { border-color: var(--line); }

/* ---------- Step navigation ---------- */
.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  gap: 12px;
}

/* ---------- Finalize options ---------- */
.chosen-five {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.chosen-five .pill {
  background: var(--cream-deep);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
}
.option-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 540px) {
  .option-grid { grid-template-columns: 1fr 1fr; }
}
.option-card {
  border: 1.5px solid var(--line);
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.12s ease;
}
.option-card:hover { border-color: var(--terracotta); box-shadow: var(--shadow-soft); }
.option-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
  color: var(--ink);
}
.option-desc {
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

/* ---------- Ranking list ---------- */
.rank-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.rank-number {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--terracotta);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.rank-text {
  flex: 1;
  font-weight: 600;
  font-size: 0.96rem;
}
.rank-controls {
  display: flex;
  gap: 6px;
}
.rank-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--cream);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rank-btn:hover { background: var(--cream-deep); }
.rank-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ---------- Result screen ---------- */
.result-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
@media (min-width: 720px) {
  .result-layout { flex-direction: row; align-items: flex-start; }
  .preview-col { flex: 1; }
  .controls-col { flex: 1; max-width: 320px; }
}
.preview-col {
  display: flex;
  justify-content: center;
}
.preview-canvas-wrap {
  background: var(--cream-deep);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: inline-flex;
  box-shadow: var(--shadow-soft);
}
#previewCanvas {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  display: block;
}

.controls-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.control-group label.group-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.segmented {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.segmented button {
  border: 1.5px solid var(--line);
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
}
.segmented button.active {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: var(--white);
  font-weight: 700;
}
.theme-swatches {
  display: flex;
  gap: 10px;
}
.theme-swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
}
.theme-swatch.active { border-color: var(--ink); }
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  padding: 18px 20px 28px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  opacity: 0.7;
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 420px) {
  .app-main { padding: 18px 14px 50px; }
  .intro-title { font-size: 1.6rem; }
  .screen-title { font-size: 1.3rem; }
  .counter-bar { top: 70px; }
}
