/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #FFFBF5;
  color: #2C1810;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Tailwind utility used by navbar spacer */
.pt-14 { padding-top: 3.5rem; }

/* === Screen Management === */
.screen { display: none; min-height: calc(100dvh - 3.5rem); }
.screen.active { display: flex; flex-direction: column; }
#loading.hidden,
#card-overlay.hidden,
#empty-state.hidden,
.constellation-hint.hidden { display: none !important; }

/* === Entry Screen (메인 사이트 톤) === */
#entry-screen {
  padding: 32px 20px 32px;
  background: #FFFBF5;
}
[data-theme="dark"] #entry-screen { background: #1a1410; }

.entry-header { text-align: center; margin-bottom: 28px; }
.entry-header h1 {
  font-family: 'Noto Serif KR', serif;
  font-size: 22px; font-weight: 700; color: #2C1810; margin-bottom: 6px;
}
[data-theme="dark"] .entry-header h1 { color: #f0e8dc; }
.subtitle { font-size: 13px; color: #8B7355; line-height: 1.5; }
[data-theme="dark"] .subtitle { color: #9a8870; }

/* Tags */
.tags-section { margin-bottom: 18px; }
.tags-label {
  font-size: 11px; font-weight: 600; color: #8B6914;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
}
[data-theme="dark"] .tags-label { color: #D4A855; }
.tags-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  padding: 8px 14px; border-radius: 20px; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
}
.tag:active { transform: scale(0.95); }
.tag-emotion { background: #FDF8EE; color: #8B6914; border: 1px solid rgba(200,163,81,0.35); }
[data-theme="dark"] .tag-emotion { background: #2a2018; color: #e8c87a; border-color: rgba(212,168,85,0.3); }
.tag-situation { background: #FDF8EE; color: #5C4033; border: 1px solid rgba(200,163,81,0.2); }
[data-theme="dark"] .tag-situation { background: #2a2018; color: #c8b8a0; border-color: rgba(212,168,85,0.2); }

/* Divider */
.divider {
  display: flex; align-items: center; gap: 12px; margin: 20px 0;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: rgba(200,163,81,0.25);
}
[data-theme="dark"] .divider::before, [data-theme="dark"] .divider::after {
  background: rgba(212,168,85,0.2);
}
.divider span { font-size: 12px; color: #8B7355; }
[data-theme="dark"] .divider span { color: #9a8870; }

/* Search Input */
.search-input-wrap { position: relative; }
#search-input {
  width: 100%; padding: 14px 52px 14px 16px; border-radius: 16px;
  border: 2px solid rgba(200,163,81,0.35); font-size: 14px; background: #fff;
  color: #2C1810; outline: none; transition: border-color 0.2s;
  font-family: 'Noto Sans KR', sans-serif;
}
[data-theme="dark"] #search-input {
  background: #2a2018; color: #f0e8dc; border-color: rgba(212,168,85,0.3);
}
#search-input:focus { border-color: #C8A351; }
[data-theme="dark"] #search-input:focus { border-color: #D4A855; }
#search-input::placeholder { color: #8B7355; }
[data-theme="dark"] #search-input::placeholder { color: #9a8870; }
#search-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; background: linear-gradient(135deg, #8B6914, #C8A351);
  border-radius: 12px; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* === Constellation Screen (다크 유지) === */
#constellation-screen {
  background: #0f0b1e; position: relative; overflow: hidden;
  min-height: 100dvh;
}
.constellation-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; position: relative; z-index: 10;
}
.constellation-topbar button {
  background: none; border: none; cursor: pointer; padding: 4px;
}
.query-pill {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px; padding: 6px 16px; font-size: 12px; color: rgba(255,255,255,0.7);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Graph container */
.graph-container {
  flex: 1; overflow: hidden; position: relative; touch-action: none;
}
.graph-container svg {
  width: 100%; height: 100%; touch-action: none;
}

.constellation-hint {
  text-align: center; padding: 12px; font-size: 11px; color: rgba(255,255,255,0.35);
  position: relative; z-index: 10;
}

/* Empty state */
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 40px 20px; gap: 20px;
}
.empty-state p { color: rgba(255,255,255,0.5); text-align: center; font-size: 14px; line-height: 1.6; }

/* === Card Overlay (Bottom Sheet) === */
.card-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,11,30,0.7); opacity: 0;
  transition: opacity 0.3s; pointer-events: none;
}
.card-overlay.visible { opacity: 1; pointer-events: auto; }
.card-sheet {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #1e1b2e; border-radius: 24px 24px 0 0;
  padding: 12px 20px 32px; transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  border-top: 1px solid rgba(99,102,241,0.3);
  max-height: 80dvh; overflow-y: auto;
}
.card-overlay.visible .card-sheet { transform: translateY(0); }
.card-handle {
  width: 40px; height: 4px; background: rgba(255,255,255,0.2);
  border-radius: 2px; margin: 0 auto 16px;
}
.card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-icon {
  width: 40px; height: 40px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 14px;
}
.card-ref { font-size: 16px; font-weight: 700; color: #fff; }
.card-title { font-size: 12px; color: rgba(255,255,255,0.5); }
.card-verse {
  border-left: 3px solid; padding: 12px 16px; border-radius: 0 12px 12px 0;
  margin-bottom: 8px; font-size: 14px; color: rgba(255,255,255,0.9); line-height: 1.7;
}
.card-verse-ref { font-size: 11px; color: rgba(255,255,255,0.35); margin-bottom: 16px; }
.card-summary { font-size: 13px; color: rgba(255,255,255,0.6); line-height: 1.6; margin-bottom: 16px; }
.card-themes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.theme-chip {
  padding: 5px 12px; border-radius: 12px; font-size: 11px;
}
.card-actions { display: flex; gap: 10px; }
.btn-primary {
  flex: 1; background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.3);
  color: #818cf8; padding: 12px; border-radius: 14px; font-size: 13px;
  font-weight: 600; cursor: pointer;
}
.btn-explore {
  flex: 1; background: rgba(52,211,153,0.12); border: 1px solid rgba(52,211,153,0.3);
  color: #34d399; padding: 12px; border-radius: 14px; font-size: 13px;
  font-weight: 600; cursor: pointer;
}
.btn-primary:disabled {
  cursor: default; opacity: 0.4;
}

/* Chain loading spinner (inline) */
.chain-loading {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  background: rgba(15,11,30,0.6); z-index: 20;
}
.chain-loading .loading-spinner {
  width: 32px; height: 32px;
}

/* Toast */
.toast-msg {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: rgba(30,27,46,0.95); color: rgba(255,255,255,0.8);
  padding: 10px 20px; border-radius: 20px; font-size: 13px;
  z-index: 300; pointer-events: none;
  animation: toastFade 2s ease-in-out forwards;
}
@keyframes toastFade {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* === Loading === */
.loading {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15,11,30,0.9); display: flex;
  align-items: center; justify-content: center;
}
.loading-spinner {
  width: 40px; height: 40px; border: 3px solid rgba(200,163,81,0.2);
  border-top-color: #C8A351; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === SVG pill node text — prevent selection === */
.graph-container svg text {
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

/* Traveled edge dash animation */
@keyframes dash-flow {
  to { stroke-dashoffset: -20; }
}
