:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-soft: #f0f3f5;
  --ink: #17181c;
  --muted: #6b7078;
  --line: #dfe3e8;
  --red: #e60012;
  --purple: #32106d;
  --purple-2: #4b2394;
  --green: #0c7a64;
  --amber: #f0b232;
  --shadow: 0 14px 40px rgba(20, 24, 32, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(230, 0, 18, 0.08), transparent 210px),
    var(--bg);
  color: var(--ink);
  font-family:
    Pretendard,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Apple SD Gothic Neo",
    "Noto Sans KR",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

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

img {
  display: block;
  max-width: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  border-bottom: 1px solid rgba(23, 24, 28, 0.08);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: var(--red);
  color: #fff;
  font-size: 13px;
  letter-spacing: 0;
}

.topnav {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.topnav a {
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.topnav a:hover,
.topnav a:focus-visible {
  color: var(--ink);
  background: var(--panel-soft);
  outline: none;
}

.app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 16px 72px;
}

.page-head {
  display: grid;
  gap: 10px;
  margin: 8px 0 16px;
}

.eyebrow {
  color: var(--red);
  font-size: 13px;
  font-weight: 900;
}

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

h1 {
  max-width: 920px;
  font-size: clamp(32px, 9vw, 74px);
  line-height: 0.98;
  font-weight: 1000;
  letter-spacing: 0;
}

.page-head p,
.subcopy {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
}

.searchbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 16px 0 10px;
}

.searchbar input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  outline: none;
}

.searchbar input:focus {
  border-color: rgba(230, 0, 18, 0.55);
  box-shadow: 0 0 0 4px rgba(230, 0, 18, 0.1);
}

.result-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.segmented button,
.text-button,
.primary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.segmented button {
  min-width: 76px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
}

.segmented button.is-active {
  background: var(--ink);
  color: #fff;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--red);
  color: #fff;
  box-shadow: 0 12px 24px rgba(230, 0, 18, 0.22);
}

.primary-button:disabled {
  cursor: not-allowed;
  background: #a8adb5;
  box-shadow: none;
}

.ghost-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.ghost-button:disabled,
.text-button:disabled {
  cursor: not-allowed;
  border-color: #e7e9ed;
  color: #a4a9b1;
  background: #f7f8fa;
}

.text-button {
  min-height: 36px;
  color: var(--muted);
  font-size: 14px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.grid {
  display: grid;
  gap: 14px;
}

.challenge-grid {
  grid-template-columns: 1fr;
}

.challenge-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(23, 24, 28, 0.07);
}

.challenge-card:focus-within,
.challenge-card:hover {
  border-color: rgba(230, 0, 18, 0.42);
  box-shadow: var(--shadow);
}

.challenge-link {
  display: grid;
  grid-template-columns: 112px 1fr;
  min-height: 152px;
}

.challenge-thumb {
  position: relative;
  min-height: 152px;
  background: var(--panel-soft);
}

.challenge-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rank-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(230, 0, 18, 0.94);
  color: #fff;
  font-size: 12px;
  font-weight: 1000;
}

.challenge-body {
  display: grid;
  align-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 14px;
}

.challenge-title {
  font-size: 19px;
  line-height: 1.18;
  font-weight: 1000;
}

.challenge-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
}

.chip strong {
  color: var(--ink);
}

.chip-alert {
  border-color: rgba(230, 0, 18, 0.38);
  background: rgba(230, 0, 18, 0.08);
  color: var(--red);
}

.ad-slot {
  display: grid;
  place-items: center;
  min-height: 76px;
  margin: 16px 0;
  border: 1px dashed #b6bec8;
  border-radius: var(--radius);
  background: repeating-linear-gradient(135deg, #fff, #fff 12px, #f7f8fa 12px, #f7f8fa 24px);
  color: #8b929c;
  font-size: 12px;
  font-weight: 900;
}

.make-layout {
  display: grid;
  gap: 16px;
}

.budget-panel {
  position: sticky;
  top: 70px;
  z-index: 20;
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 30px rgba(23, 24, 28, 0.09);
  backdrop-filter: blur(16px);
}

.budget-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.budget-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.budget-value {
  font-size: 30px;
  font-weight: 1000;
}

.budget-value.is-warning {
  color: var(--red);
}

.budget-helper {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.4;
}

.budget-helper.is-warning {
  color: var(--red);
}

.budget-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.progress-track {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: var(--panel-soft);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--red));
  transition: width 180ms ease;
}

.selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}

.category {
  padding: 16px 0 6px;
  border-top: 2px solid var(--ink);
}

.category:first-child {
  border-top: 0;
  padding-top: 0;
}

.category-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.category h2 {
  font-size: 24px;
  font-weight: 1000;
}

.category-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option-card {
  position: relative;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 18px rgba(23, 24, 28, 0.08);
  padding: 0;
  color: inherit;
  text-align: left;
  display: grid;
  grid-template-rows: auto auto;
}

.option-card:disabled {
  cursor: not-allowed;
  filter: grayscale(0.9);
  opacity: 0.48;
}

.option-card.is-selected {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(230, 0, 18, 0.14);
}

.option-image {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--panel-soft);
}

.option-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.option-copy {
  display: grid;
  align-items: start;
  gap: 7px;
  min-height: 72px;
  padding: 9px 10px 10px;
}

.option-price {
  width: fit-content;
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--purple);
  color: #fff;
  font-size: 14px;
  font-weight: 1000;
  line-height: 1;
}

.option-title {
  display: block;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 1000;
  overflow-wrap: anywhere;
  white-space: normal;
}

.selected-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  display: none;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 1000;
}

.option-card.is-selected .selected-indicator {
  display: inline-flex;
}

.result-hero {
  display: grid;
  gap: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
}

.result-total {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 1000;
}

.result-list {
  display: grid;
  gap: 10px;
}

.result-picked-panel,
.result-full-image {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 20px rgba(23, 24, 28, 0.06);
}

.result-picked-panel {
  display: grid;
  gap: 10px;
  padding: 10px;
  border-top: 5px solid var(--red);
}

.result-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
}

.result-section-heading span {
  color: var(--ink);
  font-size: 15px;
  font-weight: 1000;
}

.result-section-heading strong {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 1000;
}

.result-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  overflow: hidden;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 20px rgba(23, 24, 28, 0.06);
}

.result-card-image {
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  object-fit: cover;
}

.result-card figcaption {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 0;
}

.result-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.result-card strong {
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.result-card em {
  width: fit-content;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(12, 122, 100, 0.1);
  color: var(--green);
  font-size: 12px;
  font-style: normal;
  font-weight: 1000;
}

.result-full-image {
  display: grid;
  margin: 2px 0 0;
  border-top: 5px solid var(--ink);
}

.result-full-image img {
  display: block;
  width: 100%;
  height: auto;
}

.result-full-image figcaption {
  padding: 10px;
  background: #fff;
}

.result-actions {
  display: grid;
  gap: 8px;
}

.stats-layout {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.section-title {
  margin-bottom: 10px;
  font-size: 24px;
  font-weight: 1000;
}

.stat-group,
.comment-list,
.admin-panel {
  display: grid;
  gap: 10px;
}

.stat-row {
  display: grid;
  gap: 7px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.stat-row:last-child {
  border-bottom: 0;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 900;
}

.stat-top span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.bar {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: var(--panel-soft);
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--purple-2);
}

.combo-box {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.combo-highlight {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.combo-number {
  color: var(--red);
  font-size: 40px;
  font-weight: 1000;
}

.combo-rank-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 1000;
  white-space: nowrap;
}

.combo-board {
  margin-top: 14px;
}

.detail-stats {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.detail-stats summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 1000;
  list-style: none;
}

.detail-stats summary::-webkit-details-marker {
  display: none;
}

.detail-stats summary span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-stats summary strong {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
}

.detail-stats[open] summary strong {
  background: var(--red);
}

.detail-stats summary .less-label,
.detail-stats[open] summary .more-label {
  display: none;
}

.detail-stats[open] summary .less-label {
  display: inline;
}

.detail-stats-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
  border-top: 1px solid var(--line);
}

.detail-stats:not([open]) .detail-stats-body {
  display: none;
}

.combo-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.combo-rank {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.combo-rank.is-mine {
  border-color: rgba(230, 0, 18, 0.5);
  box-shadow: 0 0 0 3px rgba(230, 0, 18, 0.1);
}

.combo-rank-number {
  display: grid;
  place-items: center;
  min-height: 32px;
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 1000;
}

.combo-rank.is-mine .combo-rank-number {
  background: var(--red);
  color: #fff;
}

.combo-rank-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.combo-rank-body strong {
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.combo-rank-body span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.comment-form {
  display: grid;
  gap: 8px;
  margin: 18px 0 12px;
}

.comment-form textarea,
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.comment-form textarea {
  min-height: 82px;
  resize: vertical;
  padding: 12px;
}

.comment {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.comment:last-child {
  border-bottom: 0;
}

.comment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.comment-name {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--comment-color);
  color: #fff;
  font-size: 12px;
  font-weight: 1000;
  line-height: 1.1;
}

.comment p {
  color: #30333a;
  line-height: 1.5;
}

.admin-grid {
  display: grid;
  gap: 18px;
}

.admin-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.admin-panel h2 {
  font-size: 22px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.field small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
}

.field label,
.field > span {
  color: #3b3f46;
  font-size: 13px;
  font-weight: 900;
}

.field input,
.field textarea,
.field select {
  min-height: 42px;
  padding: 9px 10px;
}

.field textarea {
  min-height: 74px;
  resize: vertical;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  color: #3b3f46;
  font-size: 14px;
  font-weight: 1000;
}

.check-field input {
  width: 20px;
  height: 20px;
  accent-color: var(--red);
}

.admin-uid {
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fafbfc;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.admin-options {
  display: grid;
  gap: 12px;
}

.admin-option-group {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafbfc;
}

.admin-option-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 1000;
}

.mini-grid {
  display: grid;
  gap: 8px;
}

.custom-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.custom-item:last-child {
  border-bottom: 0;
}

.custom-item img {
  width: 64px;
  height: 64px;
  border-radius: 7px;
  object-fit: cover;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 20px 0 6px;
}

.load-more-wrap .ghost-button {
  width: min(100%, 320px);
}

.end-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 60;
  width: min(calc(100% - 32px), 420px);
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(23, 24, 28, 0.94);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  transform: translate(-50%, 22px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (min-width: 560px) {
  .challenge-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .challenge-link {
    grid-template-columns: 1fr;
  }

  .challenge-thumb {
    aspect-ratio: 4 / 3;
  }

  .option-grid,
  .result-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media (min-width: 860px) {
  .app {
    padding-top: 28px;
  }

  .make-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
  }

  .budget-panel {
    order: 2;
  }

  .make-main {
    order: 1;
  }

  .stats-layout,
  .admin-grid {
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
  }

  .admin-options {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1040px) {
  .challenge-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
