:root {
  color-scheme: dark;
  --ink: #edf0e9;
  --muted: #a8afa4;
  --night: #101713;
  --deep: #18221c;
  --panel: #202c24;
  --line: rgba(197, 166, 102, .34);
  --gold: #c5a666;
  --gold-bright: #ead092;
  --eucalyptus: #758b73;
  --ember: #b97849;
  --paper: #e9dfcc;
  --shadow: 0 20px 60px rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }
html { background: var(--night); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -10%, rgba(117, 139, 115, .16), transparent 42rem),
    linear-gradient(150deg, #101713 0%, #0b100d 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

button, select, textarea { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 0 4vw;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 23, 19, .88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: .7rem;
  align-items: center;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  letter-spacing: .05em;
}
.brand-mark { color: var(--gold); font-size: 1.45rem; }
nav { display: flex; gap: .35rem; align-items: center; }
.nav-button {
  border: 0;
  border-radius: 999px;
  padding: .6rem .9rem;
  color: var(--muted);
  background: transparent;
  text-decoration: none;
  font-size: .92rem;
}
.nav-button:hover, .nav-button.active { color: var(--ink); background: rgba(197, 166, 102, .12); }
.install-button { color: var(--gold-bright); border: 1px solid var(--line); }

main { width: min(1240px, 92vw); margin: 0 auto; }
.view { padding: clamp(2.2rem, 6vw, 5rem) 0 6rem; }
.view:not(.active) { display: none; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
h1 { margin: .1rem 0 0; font-size: clamp(2rem, 5vw, 4.25rem); line-height: 1; letter-spacing: -.035em; }
h2 { font-size: clamp(1.45rem, 3vw, 2.15rem); margin: 0; }
h3 { margin: 0 0 .45rem; color: var(--gold-bright); font-size: 1.08rem; }
p { margin-top: 0; }
.eyebrow { margin: 0; color: var(--gold); font-size: .77rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }

.reading-toolbar, .deck-header {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  align-items: end;
}
.reading-controls { display: flex; gap: .75rem; align-items: end; }
label span { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
select {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 2.5rem 0 .85rem;
  color: var(--ink);
  background: var(--deep);
}
.primary-button, .secondary-button, .text-button {
  min-height: 46px;
  border-radius: 10px;
  padding: 0 1.15rem;
}
.primary-button { border: 1px solid var(--gold); color: #16130c; background: var(--gold-bright); font-weight: 700; }
.primary-button:hover { background: #f3dba2; }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: var(--deep); }
.text-button { border: 0; color: var(--muted); background: transparent; }
.spread-description { max-width: 58rem; margin: 1.4rem 0 2.2rem; color: var(--muted); font-size: 1rem; }

.cards-stage {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(145px, 42vw), 1fr));
  gap: clamp(.85rem, 2vw, 1.5rem);
  align-items: start;
}
.card-slot { min-width: 0; text-align: center; }
.position-name { min-height: 2.7rem; margin: 0 0 .6rem; color: var(--muted); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.card-button {
  position: relative;
  display: block;
  width: 100%;
  max-width: 205px;
  margin: 0 auto;
  aspect-ratio: 825 / 1425;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  perspective: 1200px;
}
.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .78s cubic-bezier(.2, .75, .22, 1);
  filter: drop-shadow(0 18px 18px rgba(0,0,0,.28));
}
.card-button.revealed .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
  backface-visibility: hidden;
  transition: opacity .22s ease;
}
.card-front { transform: none; opacity: 0; }
.card-button.revealed .card-inner { transform: none; }
.card-button.revealed .card-back { opacity: 0; }
.card-button.revealed .card-front { opacity: 1; }
.card-button:hover .card-inner { filter: drop-shadow(0 22px 24px rgba(0,0,0,.38)); }
.card-button.active .card-face { box-shadow: 0 0 0 2px var(--gold-bright), 0 0 32px rgba(197, 166, 102, .22); }
.card-title-mini { min-height: 1.45rem; margin: .75rem 0 0; color: var(--paper); font-family: Georgia, serif; font-size: .94rem; }

.reading-actions { display: flex; justify-content: center; gap: .5rem; margin: 2rem 0; }
.meaning-panel, .journal {
  margin-top: 2.5rem;
  padding: clamp(1.25rem, 3vw, 2.2rem);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(32,44,36,.92), rgba(21,30,25,.92));
  box-shadow: var(--shadow);
}
.meaning-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.house-label { max-width: 15rem; color: var(--eucalyptus); font-size: .75rem; letter-spacing: .12em; text-align: right; text-transform: uppercase; }
.essence { max-width: 64rem; margin: 1.2rem 0 1.5rem; color: #d6dbd3; font-size: 1.06rem; }
.meaning-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.meaning-columns p { color: var(--muted); }
blockquote { margin: 1.5rem 0 0; padding-left: 1.15rem; border-left: 2px solid var(--gold); color: var(--gold-bright); font-family: Georgia, serif; font-size: 1.15rem; font-style: italic; }
.journal { display: grid; grid-template-columns: .7fr 1.3fr; gap: 1.5rem 2rem; align-items: start; box-shadow: none; }
.journal-actions { grid-column: 2; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: -.8rem; }
textarea { width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; color: var(--ink); background: rgba(7, 12, 9, .52); font-size: 1rem; }
.journal-status { margin: 0; color: var(--muted); font-size: .78rem; }
.journal-entries { display: grid; gap: 1rem; max-width: 860px; margin-top: 2.4rem; }
.journal-entry, .journal-empty { padding: clamp(1.25rem, 3vw, 2rem); border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, rgba(32,44,36,.92), rgba(21,30,25,.92)); }
.journal-entry-date { margin: 0 0 .9rem; color: var(--gold); font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.journal-entry-text { margin: 0; white-space: pre-wrap; color: var(--ink); font-size: 1.04rem; }
.journal-entry-context { margin: 1.15rem 0 0; color: var(--eucalyptus); font-size: .82rem; }
.journal-empty p:last-child { color: var(--muted); }

.house-filter { min-width: 210px; }
.house-filter select { width: 100%; }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; margin-top: 2rem; }
.deck-card { border: 0; padding: 0; color: var(--ink); background: transparent; text-align: left; }
.deck-card img { display: block; width: 100%; aspect-ratio: 825/1425; border-radius: 7px; object-fit: cover; box-shadow: 0 12px 28px rgba(0,0,0,.28); transition: transform .25s ease, box-shadow .25s ease; }
.deck-card:hover img { transform: translateY(-5px); box-shadow: 0 18px 36px rgba(0,0,0,.42); }
.deck-card strong { display: block; margin-top: .65rem; font-family: Georgia, serif; font-size: .95rem; font-weight: 400; }
.deck-card span { color: var(--muted); font-size: .72rem; }

dialog { width: min(900px, 92vw); max-height: 90vh; overflow: auto; border: 1px solid var(--line); border-radius: 18px; padding: 0; color: var(--ink); background: var(--deep); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.76); backdrop-filter: blur(5px); }
.dialog-close { position: sticky; z-index: 2; top: .75rem; float: right; margin: .75rem .75rem 0 0; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: rgba(16,23,19,.9); font-size: 1.6rem; }
.dialog-layout { display: grid; grid-template-columns: minmax(230px, .8fr) 1.2fr; gap: 2rem; padding: 2rem; clear: both; }
.dialog-layout img { width: 100%; border-radius: 8px; }
.dialog-copy p { color: var(--muted); }
.dialog-copy .essence { color: var(--ink); }
.install-dialog { width: min(520px, 92vw); }
.install-dialog-copy { padding: 2.25rem; clear: both; }
.install-dialog-copy h2 { margin: .35rem 0 1rem; }
.install-dialog-copy > p:not(.eyebrow) { color: var(--muted); font-size: 1.04rem; }
.install-dialog-copy .primary-button { margin-top: .4rem; }

.site-footer {
  width: min(1240px, 92vw);
  margin: 0 auto;
  padding: 1.4rem 0 2.2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.65;
  text-align: center;
}
.site-footer p { margin: 0; }
.site-footer span { color: var(--gold-bright); }

@media (max-width: 760px) {
  .app-header { align-items: flex-start; padding: .85rem 4vw; }
  .brand span:last-child { display: none; }
  nav { flex-wrap: wrap; justify-content: end; }
  .nav-button { padding: .48rem .68rem; font-size: .84rem; }
  .reading-toolbar, .deck-header { align-items: stretch; flex-direction: column; }
  .reading-controls { align-items: stretch; flex-direction: column; }
  .primary-button, select { width: 100%; }
  .cards-stage { grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); }
  .position-name { min-height: 3.5rem; }
  .meaning-columns, .journal, .dialog-layout { grid-template-columns: 1fr; }
  .journal-actions { grid-column: 1; align-items: stretch; flex-direction: column; margin-top: -.8rem; }
  .journal-actions .primary-button { width: 100%; }
  .dialog-layout img { width: min(260px, 100%); margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
