*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #4A90E2;
  --accent-dark: #2f73c8;
  --accent-light: #EBF3FC;
  --bg: #F2F4F8;
  --white: #FFFFFF;
  --text: #1A1D23;
  --text-sub: #5A6272;
  --text-muted: #9CA3AF;
  --border: #E4E7EE;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.07);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --radius: 14px;
  --radius-sm: 10px;
}

html { -webkit-text-size-adjust: 100%; }

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-sub);
  flex-shrink: 0;
  margin-right: 4px;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.back-btn svg { width: 20px; height: 20px; }
.back-btn:hover { background: var(--bg); color: var(--accent); }

body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════
   HEADER  (sticky, stacked)
══════════════════════════════ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  /* safe area for notch */
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Logo row */
.header-inner {
  display: flex;
  align-items: center;
  padding: 12px 16px 10px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon { width: 32px; height: 32px; object-fit: contain; display: block; flex-shrink: 0; }
.logo-title {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.logo-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

/* Search row */
.search-wrap { padding: 0 16px 10px; }
.search-box {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 40px;
  padding: 0 14px;
  gap: 8px;
  transition: border-color .18s, box-shadow .18s;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,144,226,.14);
  background: var(--white);
}
.search-icon {
  width: 16px; height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color .18s;
}
.search-box:focus-within .search-icon { color: var(--accent); }
.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  padding: 10px 0;
  outline: none;
  min-width: 0;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-clear {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  border-radius: 50%;
  line-height: 0;
  flex-shrink: 0;
  transition: color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.search-clear svg { width: 14px; height: 14px; display: block; }
.search-clear:hover { color: var(--text); background: var(--bg); }
.search-clear.visible { display: block; }

/* Category tabs row */
.tab-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 12px 12px;
}
.tab-wrap::-webkit-scrollbar { display: none; }
.tab-list {
  display: flex;
  gap: 6px;
  width: max-content;
  min-width: 100%;
}
.tab-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 40px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  background: var(--bg);
  border: 1.5px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  transition: all .18s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tab-item:active { transform: scale(.96); }
.tab-item .tab-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--white);
  padding: 1px 6px;
  border-radius: 20px;
  transition: all .18s;
}
.tab-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(74,144,226,.35);
}
.tab-item.active .tab-badge {
  background: rgba(255,255,255,.25);
  color: #fff;
}

/* ══════════════════════════════
   MAIN CONTENT
══════════════════════════════ */
.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

.main-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
}
.main-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.main-count {
  font-size: 13px;
  color: var(--text-muted);
}

/* Search notice */
.search-notice {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--accent-light);
  border: 1px solid #c5ddf7;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--accent-dark);
  margin-bottom: 14px;
}
.search-notice svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ══════════════════════════════
   FAQ ITEMS
══════════════════════════════ */
#faqList { display: flex; flex-direction: column; gap: 8px; }

/* Category section (all-view) */
.cat-section { display: flex; flex-direction: column; gap: 8px; }
.cat-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 6px 2px 2px;
  margin-top: 8px;
}
.cat-section-label::before {
  content: '';
  width: 3px; height: 13px;
  background: var(--accent);
  border-radius: 3px;
}
.cat-section-label:first-child { margin-top: 0; }

/* FAQ card */
.faq-item {
  background: var(--white);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.faq-item.open {
  border-color: #b8d4f5;
  box-shadow: var(--shadow-md);
}

/* Question row — min 48px touch target */
.faq-q {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  cursor: pointer;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background .15s;
}
.faq-q:active { background: var(--bg); }
.faq-item.open .faq-q { background: var(--accent-light); }

.q-mark {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: background .18s, color .18s;
}
.faq-item.open .q-mark {
  background: var(--accent);
  color: #fff;
}
.q-text {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.55;
}
.q-text mark {
  background: #FEF08A;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.q-chevron {
  flex-shrink: 0;
  width: 18px; height: 18px;
  color: var(--text-muted);
  margin-top: 3px;
  transition: transform .25s ease, color .18s;
}
.faq-item.open .q-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

/* Answer — accordion */
.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease;
}
.faq-item.open .faq-a { max-height: 2000px; }

.a-inner {
  display: flex;
  gap: 12px;
  padding: 14px 16px 18px;
  border-top: 1px solid #dbeafe;
}
.a-mark {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 7px;
  background: #FEF9C3;
  color: #B45309;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.a-text {
  flex: 1;
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.8;
  white-space: pre-line;
  word-break: keep-all;
  overflow-wrap: break-word;
}
.a-text mark {
  background: #FEF08A;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ══════════════════════════════
   EMPTY STATE
══════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 64px 20px;
}
.empty-icon { font-size: 44px; margin-bottom: 14px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-sub); }
.empty-sub { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

/* ══════════════════════════════
   LANDSCAPE  (가로 모드)
══════════════════════════════ */
@media (orientation: landscape) and (max-height: 500px) {
  .header-inner { padding: 8px 16px 6px; }
  .logo-icon { width: 26px; height: 26px; }
  .logo-title { font-size: 14px; }
  .logo-sub { display: none; }
  .search-wrap { padding: 0 16px 8px; }
  .search-box input { padding: 8px 0; }
  .tab-wrap { padding: 0 12px 8px; }
  .tab-item { padding: 5px 12px; font-size: 12px; }
  .main { padding-top: 14px; }
  .faq-q { padding: 12px 16px; }
  .a-inner { padding: 12px 16px 14px; }
}

/* ══════════════════════════════
   TABLET / DESKTOP
══════════════════════════════ */
@media (min-width: 600px) {
  .header-inner { padding: 14px 24px 12px; max-width: 800px; margin: 0 auto; }
  .search-wrap { padding: 0 24px 12px; max-width: 800px; margin: 0 auto; }
  .tab-wrap { padding: 0 20px 14px; max-width: 800px; margin: 0 auto; }
  .logo-title { font-size: 17px; }
  .logo-icon { width: 36px; height: 36px; }
  .main { padding: 28px 24px 60px; }
  .main-title { font-size: 20px; }
  .faq-q { padding: 18px 20px; }
  .a-inner { padding: 16px 20px 20px; }
  .q-text { font-size: 15px; }
  .a-text { font-size: 14px; }
}

@media (min-width: 900px) {
  .header-inner,
  .search-wrap,
  .tab-wrap { max-width: 960px; }
  .main { max-width: 800px; }
}
