:root {
  --navy: #13284d;
  --navy-deep: #0b1a34;
  --gold: #e3ab45;
  --bg: #f1f4fa;
  --card: #ffffff;
  --ink: #1a2338;
  --muted: #6c7690;
  --line: #e4e8f2;
  --radius: 14px;
  font-family: -apple-system, "Apple SD Gothic Neo", "Pretendard", system-ui, "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 6px 18px rgba(11, 26, 52, 0.25);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), #c98a2c);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #1a1206;
  flex-shrink: 0;
}

.brand-text h1 {
  margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -0.2px;
}
.brand-text p {
  margin: 1px 0 0; font-size: 11.5px; color: #b9c4de; font-weight: 500;
}

.icon-btn {
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,0.18); }

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 10px 10px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: #b9c4de;
  font-size: 14.5px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2.5px solid transparent;
}
.tab-btn.active {
  color: #fff;
  border-bottom-color: var(--gold);
}

/* ---------- Search bar ---------- */
.search-bar {
  position: sticky;
  top: 0;
  z-index: 19;
  background: var(--navy-deep);
  padding: 10px 14px 14px;
}
.search-bar input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  background: #fff;
  outline: none;
}

/* ---------- Main / Grid ---------- */
main { padding: 16px 14px 48px; max-width: 720px; margin: 0 auto; }

.section-count {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  margin: 2px 2px 10px;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.item-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  border-top: 3px solid var(--card-accent, var(--gold));
  padding: 14px 14px 12px;
  cursor: pointer;
  text-align: left;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform .08s ease;
}
.item-card:active { transform: scale(0.98); }

.item-card .title {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}
.item-card .tag {
  align-self: flex-start;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--card-accent, #a17a26);
  background: color-mix(in srgb, var(--card-accent, var(--gold)) 14%, white);
  padding: 3px 8px;
  border-radius: 999px;
}

.empty-note {
  color: var(--muted);
  font-size: 14px;
  padding: 40px 10px;
  text-align: center;
}

/* ---------- Info tab ---------- */
.info-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 20px;
  text-align: center;
  margin-bottom: 14px;
}
.info-card .logo {
  width: 64px; height: 64px; border-radius: 18px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--navy), #274a86);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-weight: 800; font-size: 20px;
}
.info-card h2 { margin: 0 0 4px; font-size: 18px; }
.info-card p.sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.build-tag {
  display: inline-block;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 999px;
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 18px;
  margin-bottom: 14px;
}
.panel h3 {
  margin: 0 0 6px;
  font-size: 15px;
}
.panel p {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
}
.panel .hint { color: #c0392b; font-weight: 600; }

.btn-primary {
  width: 100%;
  padding: 13px;
  border-radius: 11px;
  border: none;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:active { background: var(--navy-deep); }
.btn-primary.updated { background: #2e8b57; }

.toc-list { font-size: 13.5px; color: var(--ink); line-height: 1.9; margin: 0; padding-left: 18px; }

/* ---------- Detail sheet ---------- */
.detail-sheet {
  position: fixed; inset: 0;
  z-index: 30;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.detail-inner { max-width: 720px; margin: 0 auto; padding: 16px 18px 60px; }
.detail-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.detail-tag {
  font-size: 11.5px; font-weight: 700; color: var(--navy);
  background: #dfe6f5; padding: 4px 10px; border-radius: 999px;
}
#detailClose { background: var(--line); color: var(--ink); }
.detail-inner h2 { font-size: 20px; margin: 4px 0 14px; }
.detail-body {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  font-size: 14.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: keep-all;
}
.detail-body strong.hl { color: var(--navy); }

@media (min-width: 480px) {
  .card-grid { grid-template-columns: 1fr 1fr 1fr; }
}
