/* ── Reset & Variables ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #6C5CE7;
  --brand-dark: #4A3DAF;
  --brand-light: #F0EDFF;
  --bg: #F8F7FF;
  --surface: #FFFFFF;
  --surface2: #F5F3FF;
  --border: #E8E4F8;
  --text: #1A1A2E;
  --text-muted: #888;
  --luck-great: #E17055;
  --luck-good: #22C55E;
  --luck-normal: #F59E0B;
  --luck-bad: #636E72;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(108,92,231,.10);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { background: var(--bg); color: var(--text); min-height: 100dvh; overflow-x: hidden; font-size: 16px; line-height: 1.6; }

button { cursor: pointer; border: none; font-family: inherit; }
a { text-decoration: none; color: inherit; }

/* ── Layout ────────────────────────────────────────────── */
.layout-container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
@media (max-width: 800px) {
  .layout-container { grid-template-columns: 1fr; }
  .app-sidebar { display: none; }
}

/* ── Ad containers ─────────────────────────────────────── */
.ad-container { display: block; width: 100%; margin: 0; text-align: center; }
.top-ad { background: #f9f9f9; padding: 8px 0; border-bottom: 1px solid var(--border); }
.middle-ad { margin: 20px 0; }
.bottom-ad { margin-top: 24px; padding: 16px 0; border-top: 1px solid var(--border); }

/* ── Header ────────────────────────────────────────────── */
.main-header {
  background: linear-gradient(135deg, #6C5CE7 0%, #A29BFE 100%);
  padding: 20px 20px 24px;
  position: relative;
  overflow: hidden;
}
.main-header::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.main-header::after {
  content: '';
  position: absolute;
  bottom: -20px; left: 10px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.header-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.header-logo { display: flex; align-items: center; gap: 12px; }
.header-logo-icon { font-size: 28px; background: rgba(255,255,255,.2); border-radius: 12px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; }
.header-logo h1 { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.header-logo h1 a { color: #fff; }
.header-logo p { font-size: 13px; color: rgba(255,255,255,.8); margin-top: 2px; }
.btn-share { background: rgba(255,255,255,.2); border: 1.5px solid rgba(255,255,255,.4); color: #fff; border-radius: 20px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s; }
.btn-share:hover { background: rgba(255,255,255,.3); }

/* ── Search Bar ───────────────────────────────────────── */
.search-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,.2);
  border: 1.5px solid rgba(255,255,255,.3);
  border-radius: 12px;
  padding: 10px 14px;
  backdrop-filter: blur(4px);
}
.search-icon { font-size: 16px; flex-shrink: 0; }
.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 15px;
  font-family: inherit;
}
.search-bar input::placeholder { color: rgba(255,255,255,.6); }

/* ── App Card ──────────────────────────────────────────── */
.app-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-inner { padding: 24px 20px; }

.section-label { font-size: 13px; font-weight: 700; color: var(--text-muted); letter-spacing: .3px; margin-bottom: 14px; }

/* ── Category Grid ────────────────────────────────────── */
.category-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 600px) { .category-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 380px) { .category-grid { grid-template-columns: repeat(2, 1fr); } }

.cat-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 8px; border-radius: 14px;
  background: var(--surface2); border: 2px solid var(--border);
  cursor: pointer; transition: all .2s;
}
.cat-card:hover { border-color: var(--brand); background: var(--brand-light); transform: translateY(-2px); box-shadow: var(--shadow); }
.cat-card-icon { font-size: 32px; line-height: 1; }
.cat-card-label { font-size: 13px; font-weight: 700; color: var(--text); }
.cat-card-count { font-size: 11px; color: var(--text-muted); }

/* ── Category Detail Header ───────────────────────────── */
.category-header {
  background: linear-gradient(135deg, #6C5CE7 0%, #A29BFE 100%);
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.btn-back {
  background: rgba(255,255,255,.2); border: 1.5px solid rgba(255,255,255,.4);
  color: #fff; border-radius: 20px; padding: 7px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-back:hover { background: rgba(255,255,255,.3); }
.category-title { display: flex; align-items: center; gap: 8px; color: #fff; font-size: 20px; font-weight: 800; }
.cat-badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: rgba(255,255,255,.2); }

/* ── Filter ────────────────────────────────────────────── */
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-btn {
  padding: 6px 14px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--surface2); border: 1.5px solid var(--border); color: var(--text-muted);
  cursor: pointer; transition: all .15s;
}
.filter-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.filter-btn:hover:not(.active) { border-color: var(--brand); color: var(--brand); }

/* ── Dream List ───────────────────────────────────────── */
.dream-list { display: flex; flex-direction: column; gap: 0; }

.dream-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 0; border-bottom: 1px solid var(--border);
  cursor: default;
}
.dream-item:last-child { border-bottom: none; }

.luck-badge {
  flex-shrink: 0; padding: 4px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 700; margin-top: 2px;
}
.luck-badge[data-luck="대길"] { background: #FFEAA7; color: #D35400; }
.luck-badge[data-luck="길몽"] { background: #D5F5E3; color: #1E8449; }
.luck-badge[data-luck="보통"] { background: #F0F0F0; color: #666; }
.luck-badge[data-luck="흉몽"] { background: #FADBD8; color: #922B21; }

.dream-content { flex: 1; min-width: 0; }
.dream-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; line-height: 1.4; }
.dream-meaning { font-size: 13px; color: var(--text-muted); line-height: 1.6; }

/* ── Featured Dream (Random) ──────────────────────────── */
.dream-item-featured {
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 20px; border-left: 4px solid var(--brand);
}
.dream-item-featured .featured-keyword { font-size: 12px; color: var(--brand); font-weight: 600; margin-bottom: 8px; }
.dream-item-featured .featured-title { font-size: 17px; font-weight: 800; margin-bottom: 8px; color: var(--text); }
.dream-item-featured .featured-meaning { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 10px; }
.dream-item-featured .featured-luck { display: inline-block; padding: 4px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; }

/* ── Guide / FAQ ──────────────────────────────────────── */
.guide-section { background: var(--surface); border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow-sm); margin-top: 8px; }
.guide-section h2 { font-size: 18px; font-weight: 800; margin-bottom: 16px; color: var(--text); }
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .guide-grid { grid-template-columns: 1fr; } }
.guide-card { background: var(--surface2); border-radius: var(--radius-sm); padding: 14px; border-left: 4px solid var(--brand); }
.guide-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.guide-card p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.faq-section { background: var(--surface); border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow-sm); margin-top: 8px; }
.faq-section h2 { font-size: 18px; font-weight: 800; margin-bottom: 16px; color: var(--text); }
.faq-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
.faq-item:last-child { border-bottom: none; }
.faq-q { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.faq-a { font-size: 13px; color: var(--text-muted); line-height: 1.6; }

/* ── Sidebar ──────────────────────────────────────────── */
.app-sidebar { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; scrollbar-width: none; }
.app-sidebar::-webkit-scrollbar { display: none; }

.sidebar-card { background: var(--surface); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.sidebar-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; padding-left: 8px; border-left: 3px solid var(--brand); color: var(--text); }
.sidebar-list { list-style: none; padding: 0; margin: 0; }
.sidebar-list li { margin-bottom: 6px; }
.sidebar-list a { display: flex; align-items: flex-start; text-decoration: none; color: var(--text); padding: 7px 8px; border-radius: 8px; transition: background .15s; }
.sidebar-list a:hover { background: var(--brand-light); }
.link-icon { margin-right: 8px; font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.link-content { flex: 1; min-width: 0; }
.link-title { display: block; font-size: 13px; font-weight: 600; color: var(--brand); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-desc { display: block; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Footer ───────────────────────────────────────────── */
.main-footer { text-align: center; padding: 20px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 24px; }

/* ── Toast ────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(40px); background: #1A1A2E; color: #fff; padding: 10px 20px; border-radius: 99px; font-size: 14px; font-weight: 600; opacity: 0; transition: all .3s; z-index: 999; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Empty State ──────────────────────────────────────── */
.empty-state { text-align: center; padding: 32px 16px; color: var(--text-muted); font-size: 14px; }
