/* Client portal prototype: Bench & Ledger tokens copied from app/globals.css so the
   prototype looks like the site without depending on the Next build. */
:root,
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f4ede0;
  --bg-deep: #ece2d0;
  --text: #2b1d14;
  --muted: #5e4e40;
  --rust: #9a3b1e;
  --moss: #3f5a2e;
  --rule: color-mix(in srgb, var(--text) 18%, transparent);
  --grain-opacity: 0.35;
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #1a1410;
  --bg-deep: #120e0b;
  --text: #ede3d1;
  --muted: #b8a994;
  --rust: #e08a63;
  --moss: #9dbf7e;
  --rule: color-mix(in srgb, var(--text) 22%, transparent);
  --grain-opacity: 0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #1a1410;
    --bg-deep: #120e0b;
    --text: #ede3d1;
    --muted: #b8a994;
    --rust: #e08a63;
    --moss: #9dbf7e;
    --rule: color-mix(in srgb, var(--text) 22%, transparent);
    --grain-opacity: 0;
  }
}
@media (prefers-contrast: more) { :root { --grain-opacity: 0; } }

:root {
  --accent: var(--rust);
  --font-display-stack: 'Fraunces', Georgia, serif;
  --font-body-stack: 'Source Serif 4', Georgia, serif;
  --font-ui-stack: 'Work Sans', system-ui, sans-serif;
  --measure: 40rem;
  --header-h: 3.5rem;
  --coach: var(--rust);
  --client: var(--moss);
  --calc: var(--muted);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 1rem); }
body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body-stack);
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.2rem);
  line-height: 1.6;
}
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: url('/textures/paper-grain.webp'); background-size: 256px 256px; opacity: var(--grain-opacity);
}
h1, h2, h3, h4 { font-family: var(--font-display-stack); font-weight: 600; line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.4rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: 0.15em; }
button { font: inherit; color: inherit; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.wrap { width: min(100% - 2rem, 76rem); margin-inline: auto; }
.measure { max-width: var(--measure); }

.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 100; background: var(--text); color: var(--bg); padding: 0.6rem 1rem; font-family: var(--font-ui-stack); }
.skip-link:focus { top: 0.5rem; }

/* ---------- fiction banner ---------- */
.fiction-banner {
  font-family: var(--font-ui-stack); font-size: 0.9rem; background: var(--text); color: var(--bg);
  padding: 0.45rem 1rem; text-align: center;
}
.fiction-banner strong { font-weight: 600; }

/* ---------- header ---------- */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--rule); font-family: var(--font-ui-stack); font-size: 1rem; }
.site-header__inner { display: flex; align-items: center; gap: 0.75rem; min-height: var(--header-h); flex-wrap: wrap; }
.site-name { font-family: var(--font-display-stack); font-size: 1.1rem; color: var(--text); text-decoration: none; margin-right: auto; }
.site-name small { font-family: var(--font-ui-stack); font-size: 0.8rem; color: var(--muted); margin-left: 0.5rem; }
.header-tools { display: flex; gap: 0.5rem; align-items: center; }
.icon-button, .btn {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  background: none; border: 1px solid var(--rule); border-radius: 6px; color: var(--text); cursor: pointer; padding: 0 0.9rem; font-family: var(--font-ui-stack); font-size: 0.95rem; text-decoration: none;
}
.icon-button { min-width: 44px; border-radius: 999px; padding: 0; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 600; }
.btn--primary:hover { filter: brightness(1.08); }
.btn:hover { background: var(--bg-deep); }
.btn--primary:hover { background: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--small { min-height: 36px; padding: 0 0.7rem; font-size: 0.88rem; }
.who { font-size: 0.9rem; color: var(--muted); }

/* ---------- portal nav ---------- */
.portal-nav { border-bottom: 1px solid var(--rule); background: var(--bg); font-family: var(--font-ui-stack); }
.portal-nav .wrap { position: relative; }
.portal-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.portal-nav ul::-webkit-scrollbar { display: none; }
/* On a phone the list scrolls sideways; a fade on the right says there is more. */
@media (max-width: 48rem) {
  .portal-nav .wrap::after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 2.5rem; pointer-events: none; background: linear-gradient(to right, transparent, var(--bg)); }
  .who { display: none; }
}
.portal-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.75rem; color: var(--text); text-decoration: none; white-space: nowrap; border-radius: 4px 4px 0 0; }
.portal-nav a:hover { background: var(--bg-deep); }
.portal-nav a[aria-current='page'] { box-shadow: inset 0 -3px 0 var(--accent); font-weight: 600; }

/* ---------- layout ---------- */
main { padding: 1.5rem 0 3rem; }
.screen > h1 { margin-bottom: 0.25rem; }
.lede { color: var(--muted); font-family: var(--font-ui-stack); font-size: 0.95rem; margin-bottom: 1.5rem; }
.grid { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 56rem) { .grid--2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
.card { border: 1px solid var(--rule); border-radius: 8px; padding: 1rem 1.1rem; background: color-mix(in srgb, var(--bg-deep) 55%, var(--bg)); }
.card h2, .card h3 { margin-top: 0; }
.card--coach { border-left: 4px solid var(--coach); }
.card--client { border-left: 4px solid var(--client); }
.card--calc { border-left: 4px solid var(--calc); }
.card--plain { background: transparent; }
.meta { font-family: var(--font-ui-stack); font-size: 0.85rem; color: var(--muted); margin: 0 0 0.6rem; display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; align-items: center; }

/* ---------- authorship badges ---------- */
.by { display: inline-flex; align-items: center; gap: 0.35rem; font-family: var(--font-ui-stack); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.01em; padding: 0.15rem 0.55rem; border-radius: 999px; border: 1px solid currentColor; line-height: 1.4; }
.by::before { content: ''; width: 0.55em; height: 0.55em; border-radius: 50%; background: currentColor; }
.by--coach { color: var(--coach); }
.by--client { color: var(--client); }
.by--calc { color: var(--calc); }
.by--zephyr { color: var(--text); }
.by--claude { color: var(--muted); }
.by--other { color: var(--muted); border-style: dotted; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.2rem 0.8rem; font-family: var(--font-ui-stack); font-size: 0.85rem; margin: 0.4rem 0 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.g-meta { font-family: var(--font-ui-stack); font-size: 0.85rem; color: var(--muted); }
.g-sources li { font-family: var(--font-ui-stack); font-size: 0.85rem; margin-bottom: 0.4rem; overflow-wrap: anywhere; }
.g-related a { margin-right: 0.6rem; }
.kind-pill { font-family: var(--font-ui-stack); font-size: 0.72rem; padding: 0.05rem 0.45rem; border-radius: 999px; background: var(--bg-deep); color: var(--muted); }
.corr-table td:nth-child(2) { min-width: 14rem; }
.quoted p { font-style: italic; }
.quoted p::before { content: '\201C'; }
.quoted p::after { content: '\201D'; }
.by--sample { color: var(--muted); border-style: dashed; }
.by--sample::before { display: none; }
.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; font-family: var(--font-ui-stack); font-size: 0.85rem; color: var(--muted); margin: 0 0 1.25rem; align-items: center; }

/* ---------- notes and notices ---------- */
.notice { font-family: var(--font-ui-stack); font-size: 0.92rem; padding: 0.8rem 1rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--bg-deep); margin: 0 0 1.25rem; }
.notice--warn { border-color: var(--rust); border-width: 2px; background: transparent; }
.notice strong { font-weight: 600; }
.notice p:last-child { margin-bottom: 0; }
.provenance { font-family: var(--font-ui-stack); font-size: 0.92rem; padding: 0.4rem 0 0.4rem 0.9rem; border-left: 3px solid var(--muted); margin: 1rem 0; }

/* ---------- fold-outs ---------- */
details.fold { margin: 0.75rem 0 1rem; padding: 0.4rem 0.9rem; border: 1px solid var(--rule); border-radius: 4px; }
details.fold > summary { cursor: pointer; font-family: var(--font-ui-stack); font-size: 0.95em; color: var(--accent); min-height: 36px; display: flex; align-items: center; gap: 0.5rem; }
details.fold > summary::marker { content: ''; }
details.fold > summary::before { content: '+'; width: 1ch; color: var(--accent); }
details.fold[open] > summary::before { content: '\2212'; }
details.fold[open] > summary { margin-bottom: 0.5rem; }

/* ---------- tables ---------- */
table { border-collapse: collapse; width: 100%; font-size: 0.95em; }
td, th { border: 1px solid var(--rule); padding: 0.4rem 0.6rem; vertical-align: top; text-align: left; }
th { font-family: var(--font-ui-stack); font-weight: 600; font-size: 0.85rem; }
.table-scroll { overflow-x: auto; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.timeline li { position: relative; padding-left: 1.6rem; }
.timeline li::before { content: ''; position: absolute; left: 0.35rem; top: 0.55rem; width: 0.7rem; height: 0.7rem; border-radius: 50%; border: 2px solid var(--coach); background: var(--bg); }
.timeline li[data-status='current']::before { background: var(--coach); }
.timeline li[data-status='past']::before { border-color: var(--muted); }
.timeline li[data-status='past'] { color: var(--muted); }
.timeline .when { font-family: var(--font-ui-stack); font-size: 0.85rem; color: var(--muted); }
.status-pill { font-family: var(--font-ui-stack); font-size: 0.75rem; text-transform: none; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--bg-deep); color: var(--muted); margin-left: 0.4rem; }
.timeline li[data-status='current'] .status-pill { background: var(--coach); color: var(--bg); }

/* ---------- windows ---------- */
.windows { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.windows li { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 0.75rem; align-items: start; padding: 0.5rem 0; border-top: 1px solid var(--rule); }
.windows li:first-child { border-top: 0; }
.windows .date { font-family: var(--font-ui-stack); font-size: 0.85rem; color: var(--muted); }
.windows .kind { font-family: var(--font-ui-stack); font-size: 0.75rem; color: var(--muted); }

/* ---------- readings ---------- */
.reading-list { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: 0.5rem; }
.reading-list a { font-family: var(--font-display-stack); font-weight: 600; }
.reading-list .meta { margin: 0; }
.reading-list li { padding: 0.6rem 0; border-top: 1px solid var(--rule); }
.reading-list li:first-child { border-top: 0; }
.question { font-size: 1.1em; font-style: italic; border-left: 3px solid var(--coach); padding-left: 0.9rem; margin: 0.5rem 0 1rem; }
.cards { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 1rem; }
@media (min-width: 48rem) { .cards { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); } }
.tarot-card { border: 1px solid var(--rule); border-radius: 8px; padding: 0.9rem; background: var(--bg); display: grid; gap: 0.4rem; align-content: start; }
.tarot-card .position { font-family: var(--font-ui-stack); font-size: 0.8rem; color: var(--muted); }
.tarot-card .name { font-family: var(--font-display-stack); font-weight: 600; font-size: 1.1rem; }
.tarot-card .orientation { font-family: var(--font-ui-stack); font-size: 0.8rem; display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid var(--rule); }
.tarot-card .orientation--reversed { border-color: var(--rust); color: var(--rust); }
.card-art { width: 6rem; aspect-ratio: 5 / 8; border-radius: 6px; border: 1px solid var(--rule); background: var(--bg-deep); display: grid; place-items: center; overflow: hidden; }
.card-art img { width: 100%; height: 100%; object-fit: cover; }
.card-art--reversed img { transform: rotate(180deg); }
.card-art--none { color: var(--muted); font-family: var(--font-ui-stack); font-size: 0.72rem; text-align: center; padding: 0.4rem; }
.tarot-card p { margin: 0.3rem 0 0; font-size: 0.97em; }

/* ---------- journal ---------- */
.journal-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.9rem; }
.entry { border: 1px solid var(--rule); border-left: 4px solid var(--client); border-radius: 8px; padding: 0.9rem 1rem; background: var(--bg); }
.entry p { margin: 0.4rem 0 0.6rem; }
.entry .links { font-family: var(--font-ui-stack); font-size: 0.85rem; color: var(--muted); }
.entry .links a { margin-right: 0.6rem; }
.share-state { font-family: var(--font-ui-stack); font-size: 0.8rem; padding: 0.15rem 0.55rem; border-radius: 999px; border: 1px solid var(--rule); }
.share-state--private { background: var(--bg-deep); }
.share-state--shared { border-color: var(--coach); color: var(--coach); }
.entry-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; font-family: var(--font-ui-stack); }
.filters button[aria-pressed='true'] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- forms ---------- */
form { display: grid; gap: 0.9rem; }
label, legend { font-family: var(--font-ui-stack); font-size: 0.9rem; font-weight: 600; }
.field { display: grid; gap: 0.3rem; }
.hint { font-family: var(--font-ui-stack); font-size: 0.82rem; color: var(--muted); font-weight: 400; }
input[type='text'], input[type='email'], input[type='password'], input[type='date'], textarea, select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--rule); border-radius: 6px; padding: 0.55rem 0.7rem; min-height: 44px; width: 100%;
}
textarea { min-height: 7rem; resize: vertical; }
fieldset { border: 1px solid var(--rule); border-radius: 6px; padding: 0.6rem 0.9rem 0.8rem; margin: 0; display: grid; gap: 0.4rem; }
.choice { display: flex; gap: 0.6rem; align-items: start; font-family: var(--font-body-stack); font-weight: 400; font-size: 0.97em; min-height: 44px; }
.choice input { margin-top: 0.35rem; width: 1.1rem; height: 1.1rem; flex: none; }
.choice .hint { display: block; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---------- sign-in ---------- */
.signin { max-width: 30rem; margin: 2rem auto; }
.signin .card { padding: 1.4rem; }

/* ---------- owner view ---------- */
.client-switch { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.25rem; font-family: var(--font-ui-stack); }
.client-switch button[aria-pressed='true'] { background: var(--text); color: var(--bg); border-color: var(--text); }
.owner-strip { background: var(--bg-deep); border-bottom: 1px solid var(--rule); font-family: var(--font-ui-stack); font-size: 0.9rem; }
.owner-strip .wrap { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; min-height: 2.5rem; padding-block: 0.3rem; }

/* ---------- footer ---------- */
.site-footer { border-top: 3px double var(--rule); margin-top: 2rem; padding: 1.5rem 0 2.5rem; font-family: var(--font-ui-stack); font-size: 0.9rem; color: var(--muted); }
.site-footer p { margin: 0 0 0.4rem; }
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 0.6rem 1rem; border-radius: 6px; font-family: var(--font-ui-stack); font-size: 0.9rem; z-index: 50; max-width: min(90vw, 36rem); }
@media print { .site-header, .portal-nav, .fiction-banner, .skip-link, .toast { display: none !important; } body::before { display: none; } details.fold { display: block; } }

/* Workings */
.steps { margin: 0.4rem 0 1rem; padding-left: 1.4rem; font-size: 0.95rem; }
.steps li { margin: 0.15rem 0; }
.working .goal { font-weight: 500; }
.working-history { list-style: none; padding: 0; margin: 0.6rem 0; display: grid; gap: 0.5rem; }
.working-history li { border-left: 3px solid var(--rule); padding: 0.1rem 0 0.1rem 0.7rem; }
.working-history li.by-sticks { border-left-color: var(--coach); }
.working-history .meta { margin: 0 0 0.2rem; }
.working-history p { margin: 0; white-space: pre-wrap; }
.working-act { display: grid; gap: 0.5rem; margin-top: 0.6rem; }
.working-act textarea, .working-act select, .working-act input { width: 100%; }
.turn--you { border-color: var(--client); color: var(--client); }
.turn--sticks { border-color: var(--coach); color: var(--coach); }
.workings-panel { margin-top: 0.8rem; }

/* Community */
.post .post-title { font-family: var(--font-display-stack, inherit); font-size: 1.15rem; margin: 0.2rem 0 0.4rem; }
.post .post-text { white-space: pre-wrap; }
.post--hidden { opacity: 0.65; border-style: dashed; }
.post-comments { list-style: none; padding: 0; margin: 0.6rem 0; display: grid; gap: 0.5rem; }
.post-comments li { border-left: 3px solid var(--rule); padding: 0.1rem 0 0.1rem 0.7rem; }
.post-comments li.by-sticks { border-left-color: var(--coach); }
.post-comments p { margin: 0; white-space: pre-wrap; }
.comment-form { display: grid; gap: 0.5rem; margin-top: 0.4rem; }
.comment-form textarea { width: 100%; }

/* Setup */
#setup-card summary { cursor: pointer; }
.setup-list { list-style: none; padding: 0; margin: 0.8rem 0; display: grid; gap: 0.35rem; font-family: var(--font-ui-stack); font-size: 0.92rem; }
#setup-card code { word-break: break-all; }

/* Sticks input under astrology sections */
.sticks-input { border-top: 1px dashed var(--rule); margin-top: 0.9rem; padding-top: 0.7rem; display: grid; gap: 0.4rem; }
.sticks-input .note-text { margin: 0; white-space: pre-wrap; border-left: 3px solid var(--coach); padding-left: 0.6rem; }
.sticks-input textarea { width: 100%; }
