@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@300;400;500;600&family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

:root {
  --background: #f9f6f1;
  --foreground: #2a231d;
  --primary: #c17148;
  --primary-dark: #a45a35;
  --primary-foreground: #ffffff;
  --secondary: #f1e8dc;
  --muted: #f2ede4;
  --muted-foreground: #8c8072;
  --accent: #e4ded0;
  --accent-foreground: #6b5a3f;
  --border: #e6dccb;
  --card: #ffffff;
  --card-border: #ded0b8;
  --danger: #b5453a;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 999px;
}

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

body {
  background: var(--background);
  color: var(--foreground);
  font-family: 'Noto Sans KR', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 84px;
}

h1, h2, h3, .serif {
  font-family: 'Noto Serif KR', Georgia, serif;
  font-weight: 300;
}

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

/* ---------- layout shells ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 0.8px solid var(--border);
  background: var(--background);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .brand {
  font-family: 'Noto Serif KR', serif;
  font-weight: 400;
  font-size: 18px;
  letter-spacing: 0.5px;
}

.topbar .brand span { color: var(--primary); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12px;
  border-radius: var(--radius-pill);
  border: 0.8px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  transition: all .2s;
}
.icon-btn:hover { border-color: rgba(193,113,72,.4); background: rgba(193,113,72,.05); color: var(--foreground); }

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

/* ---------- bottom nav ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-around;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(6px);
  border-top: 0.8px solid var(--border);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted-foreground);
  padding: 6px 2px;
  border-radius: 10px;
}
.bottom-nav a .ic { font-size: 18px; }
.bottom-nav a.active { color: var(--primary); font-weight: 500; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 22px;
  border-radius: var(--radius-pill);
  border: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .2s;
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: var(--muted); color: var(--muted-foreground); cursor: not-allowed; }
.btn-outline { background: var(--card); color: var(--foreground); border: 0.8px solid var(--border); }
.btn-outline:hover { border-color: rgba(193,113,72,.4); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 12.5px; }
.btn-ghost { background: transparent; color: var(--muted-foreground); }
.btn-danger { background: transparent; color: var(--danger); border: 0.8px solid rgba(181,69,58,.3); }

/* ---------- cards / sections ---------- */

.card {
  background: var(--card);
  border: 0.8px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(40,30,20,.04);
  padding: 20px;
}

.section-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted-foreground);
  font-weight: 600;
  margin-bottom: 8px;
}

.hr { height: 0.8px; background: var(--border); border: none; margin: 20px 0; }

/* ---------- form fields ---------- */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--muted-foreground); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 0.8px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 14px;
  font-family: inherit;
  color: var(--foreground);
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: rgba(193,113,72,.5);
  box-shadow: 0 0 0 3px rgba(193,113,72,.1);
}

/* ---------- emotion chips ---------- */

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
  justify-content: center;
}
.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  border: 0.8px solid var(--border);
  background: var(--card);
  font-size: 13px;
  color: var(--foreground);
  transition: all .15s;
}
.chip:hover { border-color: rgba(193,113,72,.35); background: rgba(193,113,72,.05); }
.chip.selected { border-color: var(--primary); background: rgba(193,113,72,.08); color: var(--primary-dark); }

/* ---------- misc ---------- */

.center { text-align: center; }
.muted { color: var(--muted-foreground); }
.small { font-size: 12.5px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }

.spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: 90px; left: 50%;
  transform: translateX(-50%);
  background: var(--foreground);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
.toast.show { opacity: .92; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted-foreground); }
.empty-state .ic { font-size: 32px; margin-bottom: 10px; }

/* ---------- tarot card 3D flip ---------- */

.tarot-card {
  position: relative;
  width: 176px;
  height: 272px;
  margin: 0 auto;
  perspective: 1000px;
}
.tarot-card.lg { width: 208px; height: 320px; }
.tarot-card.sm { width: 64px; height: 96px; }

.tarot-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(.34,1.4,.64,1);
}
.tarot-card.flipped .tarot-card-inner { transform: rotateY(180deg); }

.tarot-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tarot-card-back {
  background: linear-gradient(135deg, #f8f3ec 0%, #f0e8dc 50%, #f8f3ec 100%);
  border: 1.5px solid var(--card-border);
  align-items: center;
  justify-content: center;
}
.tarot-card-back .medallion {
  width: 44%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(184,160,128,.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tarot-card-back .medallion::after {
  content: '';
  width: 40%;
  height: 40%;
  border-radius: 50%;
  background: rgba(200,168,112,.2);
}

.tarot-card-front {
  background: #faf5ee;
  border: 1.5px solid var(--card-border);
  transform: rotateY(180deg);
}
.tarot-card-front .tc-top {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px 4px;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted-foreground);
  flex-shrink: 0;
}
.tarot-card-front .tc-art {
  flex: 1;
  margin: 0 10px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tarot-card-front .tc-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tarot-card-front .tc-name {
  text-align: center;
  padding: 8px 12px 12px;
  flex-shrink: 0;
}
.tarot-card-front .tc-name .ko {
  font-family: 'Noto Serif KR', serif;
  font-size: 14px;
  color: var(--foreground);
}
.tarot-card-front .tc-name .en {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-top: 2px;
}

.tarot-card.sm .tc-top, .tarot-card.sm .tc-name .en { display: none; }
.tarot-card.sm .tc-art { margin: 4px; border-radius: 6px; }
.tarot-card.sm .tc-name { padding: 4px 6px 6px; }
.tarot-card.sm .tc-name .ko { font-size: 10px; }

/* ---------- reading page ---------- */

.reading-emotion {
  background: var(--muted);
  border: 0.8px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  margin: 24px 0;
}
.reading-emotion p {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted-foreground);
  margin-bottom: 6px;
}
.reading-emotion .txt {
  font-size: 14px;
  font-style: italic;
  color: rgba(42,35,29,.9);
}

.reading-summary {
  text-align: center;
  font-family: 'Noto Serif KR', serif;
  font-size: 16px;
  line-height: 1.9;
  padding: 4px 8px 8px;
}

.reading-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 18px;
  color: var(--muted-foreground);
  font-size: 11px;
  letter-spacing: 1px;
}
.reading-divider::before, .reading-divider::after {
  content: '';
  flex: 1;
  height: 0.8px;
  background: var(--border);
}

.reading-section { margin-bottom: 22px; }
.reading-section .rs-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(140,128,114,.8);
  font-weight: 500;
  margin-bottom: 6px;
}
.reading-section .rs-body {
  font-size: 14px;
  line-height: 1.95;
  color: rgba(42,35,29,.88);
  white-space: pre-wrap;
}

.hist-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 0.8px solid var(--border); }
.hist-item .thumb { width: 44px; height: 62px; object-fit: cover; border-radius: 6px; background: var(--muted); flex-shrink: 0; }
.hist-item .hi-body { flex: 1; min-width: 0; }
.hist-item .hi-date { font-size: 11px; color: var(--muted-foreground); }
.hist-item .hi-name { font-size: 14px; font-weight: 600; margin-top: 2px; }
.hist-item .hi-mood { font-size: 12.5px; color: var(--foreground); margin-top: 3px; font-style: italic; }
.hist-item .hi-actions { display: flex; align-items: flex-start; }
.hist-item .hi-actions button { background: none; border: none; color: var(--muted-foreground); font-size: 15px; padding: 4px; }
