:root {
  --brand-900: #123522;
  --brand-700: #1b5e3c;
  --brand-600: #217449;
  --brand-500: #2e9e4f;
  --brand-400: #45b869;
  --brand-100: #e7f5ec;
  --brand-50: #f3faf5;

  --accent: #c8862f;
  --accent-light: #fbf1e2;

  --bg: #f6f7f5;
  --surface: #ffffff;
  --ink: #1c2420;
  --ink-soft: #5c6a62;
  --ink-faint: #93a099;
  --line: #e4e8e3;
  --danger: #cf4a4a;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 2px 10px rgba(18, 53, 34, 0.06), 0 1px 2px rgba(18, 53, 34, 0.05);
  --shadow-pop: 0 12px 32px rgba(18, 53, 34, 0.16);
  --header-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard Variable",
    Pretendard, "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

img { max-width: 100%; display: block; }
button { font-family: inherit; }

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- top header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: rgba(246, 247, 245, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar.on-home { background: transparent; border-bottom-color: transparent; }

.back-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
  color: var(--brand-700);
}
.back-btn svg { width: 20px; height: 20px; }
.back-btn.hidden { visibility: hidden; }

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 4px 6px;
  border-radius: 999px;
  color: var(--brand-900);
}
.topbar-logo img { width: 26px; height: 26px; border-radius: 7px; object-fit: cover; }
.topbar-logo .mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--brand-700); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
}
.topbar-logo span { font-weight: 700; font-size: 15px; }

.topbar-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--brand-900);
}

.topbar-spacer { flex: 1; }

/* ---------- main ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 0 56px;
}

/* ---------- hero (home) ---------- */
.hero {
  position: relative;
  background: linear-gradient(160deg, var(--brand-700), var(--brand-900));
  color: #fff;
  padding: 40px 20px 40px;
  border-radius: 0 0 32px 32px;
  text-align: center;
  margin-bottom: 22px;
  overflow: hidden;
  min-height: 220px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.hero.has-photo {
  background-image:
    linear-gradient(180deg, rgba(10, 28, 18, 0.35) 0%, rgba(8, 20, 14, 0.55) 55%, rgba(6, 16, 11, 0.82) 100%),
    var(--hero-photo);
  background-size: cover;
  background-position: center 40%;
}
.hero-inner { position: relative; z-index: 1; width: 100%; }
.hero-name {
  position: absolute;
  top: 16px; left: 18px;
  z-index: 2;
  height: 30px;
  display: flex; align-items: center;
  font-size: 24px; font-weight: 800; color: #fff;
  letter-spacing: -0.2px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.hero .hero-logo {
  position: absolute;
  top: 16px; right: 18px;
  z-index: 2;
  height: 30px;
  display: flex; align-items: center; justify-content: flex-end;
}
.hero .hero-logo img {
  height: 100%; width: auto; object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
}
.hero h1 {
  font-size: 22px; line-height: 1.4; font-weight: 800;
  margin: 0; letter-spacing: -0.2px;
  text-shadow: 0 2px 14px rgba(0,0,0,0.28);
}

/* ---------- section heading ---------- */
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 4px 20px 12px;
}

/* ---------- category grid ---------- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 18px;
}
@media (min-width: 640px) { .category-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; padding: 0 24px; } }
@media (min-width: 960px) { .category-grid { grid-template-columns: repeat(6, 1fr); gap: 18px; } }

.category-card {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  text-align: center;
}
.category-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); border-color: var(--brand-100); }
.category-card:active { transform: translateY(0); }

.category-icon {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: var(--brand-100);
  color: var(--brand-700);
  display: flex; align-items: center; justify-content: center;
}
.category-icon svg { width: 28px; height: 28px; stroke: currentColor; stroke-width: 2.4; }
.category-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 16px; }

.category-card .cname { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.category-card .ccount { font-size: 11.5px; color: var(--ink-faint); }

/* ---------- empty state ---------- */
.empty-state {
  margin: 40px 20px;
  padding: 36px 20px;
  text-align: center;
  color: var(--ink-faint);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  font-size: 14px;
}

/* ---------- case list ---------- */
.case-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 0 18px;
}
@media (min-width: 640px) { .case-grid { grid-template-columns: repeat(2, 1fr); padding: 0 24px; gap: 18px; } }
@media (min-width: 960px) { .case-grid { grid-template-columns: repeat(3, 1fr); } }

.case-card {
  font: inherit;
  color: inherit;
  text-align: left;
  padding: 0;
  display: block;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform .15s ease;
}
.case-card:hover { transform: translateY(-2px); }
.case-card .thumb {
  aspect-ratio: 4 / 3;
  background: var(--brand-50);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
}
.case-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.case-card .thumb .noimg { color: var(--brand-400); font-size: 13px; }
.case-card .body { padding: 14px 16px 16px; }
.case-card .ctitle { font-size: 15.5px; font-weight: 700; margin: 0 0 8px; color: var(--ink); }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 12px; font-weight: 600;
  padding: 4px 9px; border-radius: 999px;
  background: var(--brand-100); color: var(--brand-700);
}
.chip.price { background: var(--accent-light); color: var(--accent); }

/* ---------- case detail ---------- */
.detail-header { padding: 18px 18px 4px; }
.detail-title { font-size: 20px; font-weight: 800; margin: 0 0 4px; }
.detail-sub { color: var(--ink-faint); font-size: 13px; margin: 0 0 18px; }

.ba-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 18px;
}
.ba-item { position: relative; border-radius: var(--radius-md); overflow: hidden; background: var(--brand-50); aspect-ratio: 4/5; }
.ba-item img { width: 100%; height: 100%; object-fit: cover; }
.ba-tag {
  position: absolute; top: 10px; left: 10px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .4px;
  padding: 5px 10px; border-radius: 999px; color: #fff;
  background: rgba(18,53,34,0.75);
}
.ba-tag.after { background: var(--brand-700); }

.info-card {
  margin: 20px 18px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 18px 6px;
}
.stat-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.stat {
  flex: 1;
  min-width: 120px;
  background: var(--brand-50);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.stat .label { font-size: 11.5px; color: var(--brand-600); font-weight: 700; margin-bottom: 4px; }
.stat .value { font-size: 15px; font-weight: 700; color: var(--ink); }

.process-block h3 {
  font-size: 13.5px; color: var(--ink-soft); margin: 0 0 8px;
}
.process-block p {
  font-size: 14.5px; line-height: 1.65; color: var(--ink); white-space: pre-wrap;
  margin: 0 0 18px;
}

.gallery-block { margin: 0 0 24px; }
.gallery-block h3 { margin: 0 0 10px; padding: 0 18px; }

.gallery-carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: 10px;
  padding: 0 18px 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.gallery-carousel::-webkit-scrollbar { display: none; }
.gallery-slide { flex: 0 0 78%; scroll-snap-align: center; }
@media (min-width: 640px) { .gallery-slide { flex: 0 0 44%; } .gallery-carousel { padding-left: 24px; padding-right: 24px; } }
@media (min-width: 960px) { .gallery-slide { flex: 0 0 30%; } }
.gallery-slide img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  border-radius: 14px; cursor: pointer;
  background: var(--brand-50);
}

.gallery-wrap { position: relative; }
.gallery-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(20, 30, 24, 0.5);
  backdrop-filter: blur(2px);
  border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.gallery-arrow svg { width: 18px; height: 18px; }
.gallery-arrow.left { left: 8px; }
.gallery-arrow.right { right: 8px; transform: translateY(-50%) rotate(180deg); }
.gallery-arrow:active { background: rgba(20, 30, 24, 0.7); }

.gallery-dots { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.gallery-dots .dot {
  width: 6px; height: 6px; border-radius: 3px;
  background: var(--line);
  cursor: pointer;
  transition: background .15s, width .15s;
}
.gallery-dots .dot.active { background: var(--brand-600); width: 16px; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(10,20,14,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px;
}
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 8px; }
.lightbox.hidden { display: none; }
.lightbox-close {
  position: absolute; top: 18px; right: 18px;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.14); border: none; color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.lightbox-close svg { width: 18px; height: 18px; }
.lightbox-hint {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: rgba(255,255,255,0.14); color: #fff;
  font-size: 12.5px; font-weight: 600;
  padding: 8px 16px; border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- brochure link (home) ---------- */
.brochure-link {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 18px 18px 8px;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.brochure-link svg { width: 17px; height: 17px; color: var(--brand-600); }
@media (min-width: 640px) { .brochure-link { margin-left: 24px; } }

/* ---------- brochure list ---------- */
.brochure-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 18px;
}
.brochure-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  cursor: pointer;
}
.brochure-item .ic {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: var(--brand-100); color: var(--brand-700);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.brochure-item .ic svg { width: 22px; height: 22px; }
.brochure-item .ic img { width: 100%; height: 100%; object-fit: contain; background: #fff; }

/* ---------- admin fab ---------- */
.admin-fab {
  position: fixed; right: 18px; bottom: 18px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint); cursor: pointer; z-index: 30;
}
.admin-fab svg { width: 20px; height: 20px; }

/* ---------- admin ---------- */
.admin-login {
  max-width: 360px; margin: 12vh auto 0; padding: 0 20px;
  text-align: center;
}
.admin-login .mark {
  width: 56px; height: 56px; border-radius: 16px; background: var(--brand-700); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; margin: 0 auto 16px;
}
.admin-login h2 { margin: 0 0 6px; font-size: 18px; }
.admin-login p { margin: 0 0 20px; color: var(--ink-faint); font-size: 13.5px; }

.field { margin-bottom: 14px; text-align: left; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); font-size: 14.5px; color: var(--ink);
  font-family: inherit;
}
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--brand-400); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px; border-radius: 999px; border: none;
  font-size: 14.5px; font-weight: 700; cursor: pointer;
  background: var(--brand-700); color: #fff; width: 100%;
}
.btn:hover { background: var(--brand-600); }
.btn.secondary { background: var(--brand-100); color: var(--brand-700); }
.btn.ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn.danger { background: #fbeaea; color: var(--danger); }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; }
.error-msg { color: var(--danger); font-size: 13px; margin: -6px 0 14px; }

.admin-shell { padding: 18px; max-width: 720px; margin: 0 auto; }
.admin-tabs { display: flex; gap: 8px; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.admin-tabs button {
  flex: 1; border: none; background: transparent; padding: 10px 6px; border-radius: 999px;
  font-weight: 700; font-size: 13.5px; color: var(--ink-faint); cursor: pointer;
}
.admin-tabs button.active { background: var(--brand-700); color: #fff; }

.admin-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 16px; margin-bottom: 14px;
}
.admin-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--line);
}
.admin-list-item:last-child { border-bottom: none; }
.admin-list-item .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-100); color: var(--brand-700); display: flex; align-items: center; justify-content: center; flex: none; }
.admin-list-item .ic svg { width: 20px; height: 20px; }
.admin-list-item .ic img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.admin-list-item .name { flex: 1; font-weight: 600; font-size: 14.5px; }
.admin-list-item .meta { font-size: 12px; color: var(--ink-faint); }
.admin-list-item .thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--brand-50); flex: none; }
.admin-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.danger { color: var(--danger); }

.upload-row { display: flex; gap: 10px; }
.upload-slot {
  flex: 1; aspect-ratio: 4/5; border: 1.5px dashed var(--line); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--ink-faint); font-size: 12.5px; cursor: pointer; position: relative; overflow: hidden;
  background: var(--brand-50);
}
.upload-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.upload-slot span { position: relative; z-index: 1; background: rgba(255,255,255,0.85); padding: 3px 8px; border-radius: 6px; margin-top: 4px; }
.upload-slot input { display: none; }

.icon-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.icon-picker label {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 0; display: flex;
  align-items: center; justify-content: center; cursor: pointer; color: var(--ink-soft);
}
.icon-picker label svg { width: 20px; height: 20px; }
.icon-picker input { display: none; }
.icon-picker input:checked + svg,
.icon-picker label:has(input:checked) { border-color: var(--brand-500); background: var(--brand-100); color: var(--brand-700); }

.toolbar-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.toolbar-row h2 { font-size: 17px; margin: 0; }
.muted-note { font-size: 12.5px; color: var(--ink-faint); margin: 6px 0 0; }

.loading-dot { text-align: center; padding: 60px 0; color: var(--ink-faint); font-size: 14px; }

@media (min-width: 640px) {
  .admin-shell { padding: 28px; }
  .hero { border-radius: 0 0 40px 40px; padding: 44px 20px 52px; }
}
