/* =========================================================
   I-Ching Oracle — Stylesheet
   Palette: ink, parchment, bronze, cinnabar
   ========================================================= */

:root {
    --ink:          #0e0b08;
    --ink-2:        #1a1410;
    --ink-3:        #241b15;
    --parchment:    #f2e6cf;
    --parchment-2:  #e8d9b8;
    --bronze:       #c9a35c;
    --bronze-bright:#e5c074;
    --bronze-deep:  #8a6a2e;
    --cinnabar:     #b8412d;
    --cinnabar-2:   #d85a3d;
    --jade:         #5c8a6a;
    --slate:        #9a8a74;
    --rule:         rgba(201, 163, 92, 0.22);
    --rule-strong:  rgba(201, 163, 92, 0.45);
    --shadow-soft:  0 20px 60px rgba(0, 0, 0, 0.45);
    --shadow-lift:  0 6px 18px rgba(0, 0, 0, 0.35);
    --serif:        'Cormorant Garamond', 'Noto Serif SC', Georgia, serif;
    --sans:         'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --cjk:          'Noto Serif SC', 'Cormorant Garamond', serif;
    --maxw:         1100px;
    --r-sm:         4px;
    --r-md:         8px;
    --r-lg:         14px;
}

* { box-sizing: border-box; }

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 20;
    transform: translateY(-140%);
    padding: 10px 14px;
    border: 1px solid var(--bronze);
    border-radius: var(--r-sm);
    background: var(--ink-2);
    color: var(--parchment);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 160ms ease;
}

.skip-link:focus {
    transform: translateY(0);
    outline: none;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: var(--sans);
    font-weight: 300;
    color: var(--parchment);
    background:
        radial-gradient(ellipse at 20% 0%, rgba(184, 65, 45, 0.08), transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(201, 163, 92, 0.08), transparent 55%),
        linear-gradient(180deg, #0e0b08 0%, #1a1410 50%, #0e0b08 100%);
    background-attachment: fixed;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

/* subtle starfield / parchment speckle */
.starfield {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.35;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(201, 163, 92, 0.35), transparent),
        radial-gradient(1px 1px at 80% 70%, rgba(201, 163, 92, 0.25), transparent),
        radial-gradient(1px 1px at 30% 85%, rgba(232, 217, 184, 0.18), transparent),
        radial-gradient(1px 1px at 65% 15%, rgba(184, 65, 45, 0.2), transparent),
        radial-gradient(1.5px 1.5px at 45% 55%, rgba(201, 163, 92, 0.2), transparent);
    background-size: 640px 640px, 720px 720px, 520px 520px, 830px 830px, 610px 610px;
}

/* =========================================================
   Header
   ========================================================= */
.site-header {
    position: relative;
    z-index: 2;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 36px 32px 18px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 20px;
    border-bottom: 1px solid var(--rule);
}

.brand {
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand-glyph {
    font-family: var(--cjk);
    font-size: 56px;
    line-height: 1;
    color: var(--bronze-bright);
    text-shadow: 0 0 30px rgba(201, 163, 92, 0.35);
}

.brand-text h1 {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(28px, 4vw, 40px);
    letter-spacing: 0.02em;
    margin: 0;
    color: var(--parchment);
}

.brand-heading {
    display: block;
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(28px, 4vw, 40px);
    letter-spacing: 0.02em;
    line-height: 1.15;
    color: var(--parchment);
}

.brand-sub {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--slate);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.site-nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    flex-wrap: wrap;
}

.static-brand,
.static-nav a,
.site-footer a {
    color: inherit;
    text-decoration: none;
}

.static-nav a {
    padding: 9px 12px;
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    color: var(--slate);
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.static-nav a:hover,
.static-nav a:focus-visible,
.site-footer a:hover,
.site-footer a:focus-visible {
    color: var(--bronze-bright);
    border-color: var(--bronze);
    outline: none;
}

.nav-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: transparent;
    color: var(--slate);
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 10px 16px;
    cursor: pointer;
    border-radius: var(--r-sm);
    text-decoration: none;
    transition: color 200ms ease, background 200ms ease, border-color 200ms ease;
}

.nav-btn:hover { color: var(--parchment); }
.nav-btn.active {
    color: var(--bronze-bright);
    border-color: var(--rule-strong);
    background: rgba(201, 163, 92, 0.06);
}

.share-site-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-color: rgba(92, 138, 106, 0.34);
    color: var(--parchment-2);
}

.share-site-btn:hover,
.share-site-btn:focus-visible {
    border-color: var(--jade);
    color: var(--parchment);
    outline: none;
}

.share-site-icon {
    font-size: 14px;
    line-height: 1;
}

.social-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 12px;
    color: var(--parchment-2);
    border: 1px solid rgba(92, 138, 106, 0.34);
    border-radius: var(--r-sm);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}

.social-nav-link:hover,
.social-nav-link:focus-visible {
    color: var(--parchment);
    border-color: var(--jade);
    background: rgba(92, 138, 106, 0.1);
    outline: none;
}

.social-nav-mark {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

.static-nav .social-nav-link {
    color: var(--parchment-2);
    border-color: rgba(92, 138, 106, 0.34);
}

.support-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--bronze-bright);
    border-color: rgba(201, 163, 92, 0.34);
    text-decoration: none;
}

.static-nav .support-nav-link {
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--bronze-bright);
}

.support-nav-link:hover,
.support-nav-link:focus-visible {
    color: var(--parchment);
    border-color: var(--bronze);
    background: rgba(201, 163, 92, 0.08);
    outline: none;
}

.kofi-button-link {
    width: 151px;
    height: 40px;
    padding: 2px 4px;
    border-color: transparent;
    background: transparent;
}

.static-nav .kofi-button-link {
    width: 151px;
    height: 40px;
    padding: 2px 4px;
}

.support-nav-image {
    display: block;
    width: 143px;
    height: 36px;
    max-width: 100%;
    object-fit: contain;
    border: 0;
}

.support-nav-link[hidden] {
    display: none;
}

.share-toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 70;
    max-width: min(360px, calc(100vw - 48px));
    padding: 12px 16px;
    border: 1px solid rgba(92, 138, 106, 0.58);
    border-radius: var(--r-sm);
    background: rgba(14, 11, 8, 0.92);
    color: var(--parchment);
    box-shadow: var(--shadow-lift);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: none;
}

.share-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.share-toast[hidden] {
    display: none;
}

/* =========================================================
   Main + Views
   ========================================================= */
main {
    position: relative;
    z-index: 2;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 48px 32px 80px;
}

.view {
    animation: fade-up 480ms ease both;
}

.static-page {
    animation: fade-up 480ms ease both;
}

.static-article {
    max-width: 980px;
    margin: 0 auto;
}

.static-backlink {
    display: inline-flex;
    margin-bottom: 22px;
    color: var(--bronze);
    font-size: 12px;
    letter-spacing: 0.16em;
    text-decoration: none;
    text-transform: uppercase;
}

.static-backlink:hover,
.static-backlink:focus-visible {
    color: var(--bronze-bright);
    outline: none;
}

.static-hero {
    display: grid;
    grid-template-columns: minmax(220px, 300px) 1fr;
    gap: 34px;
    align-items: center;
    margin-bottom: 42px;
    padding-bottom: 34px;
    border-bottom: 1px solid var(--rule);
}

.static-hex-card {
    padding: 28px;
    text-align: center;
    border: 1px solid var(--rule-strong);
    border-radius: var(--r-lg);
    background: linear-gradient(180deg, rgba(36, 27, 21, 0.74), rgba(14, 11, 8, 0.48));
    box-shadow: var(--shadow-soft);
}

.static-hex-card .hex-number {
    color: var(--slate);
    font-family: var(--serif);
    font-size: 14px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.static-hex-card .hex-chinese {
    margin: 4px 0;
    color: var(--bronze-bright);
    font-family: var(--cjk);
    font-size: 38px;
    line-height: 1;
}

.static-hex-card .hex-symbol {
    margin: 10px 0 4px;
    color: var(--bronze-bright);
    font-family: var(--cjk);
    font-size: 58px;
    line-height: 1;
    text-shadow: 0 0 22px rgba(201, 163, 92, 0.16);
}

.static-hex-card .hex-pinyin {
    color: var(--parchment-2);
    font-family: var(--serif);
    font-size: 18px;
    font-style: italic;
}

.static-lines {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 140px;
    margin: 20px auto 0;
}

.static-line {
    display: flex;
    justify-content: space-between;
    height: 10px;
}

.static-line.yang,
.static-line.yin i {
    background: var(--bronze-bright);
    border-radius: 2px;
}

.static-line.yin i {
    width: calc(50% - 5px);
}

.static-kicker,
.static-directory-number {
    color: var(--bronze);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.static-directory-number {
    font-size: 12px;
    letter-spacing: 0.04em;
    line-height: 1.2;
    text-transform: none;
}

.static-hero-copy h1,
.static-article > h1 {
    margin: 0 0 10px;
    color: var(--parchment);
    font-family: var(--serif);
    font-size: clamp(34px, 6vw, 58px);
    font-weight: 500;
    line-height: 1.05;
}

.static-hero-copy h1 span {
    color: var(--bronze-bright);
    font-family: var(--cjk);
}

.static-alt,
.static-keywords {
    color: var(--slate);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.static-panel-grid {
    margin-top: 18px;
}

.static-line-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.static-line-list li {
    padding: 16px 18px;
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    background: rgba(14, 11, 8, 0.36);
}

.static-line-list strong {
    display: block;
    margin-bottom: 6px;
    color: var(--bronze);
    font-size: 11px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.static-line-list span {
    color: var(--parchment-2);
    font-family: var(--serif);
    font-size: 18px;
    line-height: 1.62;
}

.static-prev-next {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 42px;
}

.static-prev-next a {
    padding: 16px;
    color: var(--parchment-2);
    text-decoration: none;
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    background: rgba(36, 27, 21, 0.44);
}

.static-prev-next a:last-child {
    text-align: right;
}

.static-prev-next a:hover,
.static-prev-next a:focus-visible {
    color: var(--bronze-bright);
    border-color: var(--bronze);
    outline: none;
}

.static-share-panel {
    margin-top: 36px;
    padding: 18px;
    border: 1px solid rgba(92, 138, 106, 0.38);
    border-radius: var(--r-md);
    background: rgba(92, 138, 106, 0.1);
}

.static-share-panel p {
    margin: 0 0 14px;
    color: var(--parchment-2);
    font-family: var(--serif);
    font-size: 18px;
    line-height: 1.55;
}

.static-share-panel a {
    color: var(--bronze-bright);
}

.static-share-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.x-share-link,
.x-follow-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.static-directory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
    margin-top: 28px;
}

.static-directory-card {
    display: grid;
    grid-template-rows: auto 16px 30px 30px minmax(52px, auto);
    gap: 7px;
    padding: 14px;
    text-align: center;
    color: var(--parchment);
    text-decoration: none;
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    background: rgba(36, 27, 21, 0.52);
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.static-directory-card:hover,
.static-directory-card:focus-visible {
    transform: translateY(-2px);
    border-color: var(--bronze);
    background: rgba(46, 35, 27, 0.68);
    outline: none;
}

.static-directory-card img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    border-radius: var(--r-sm);
}

.static-directory-language {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin: 0 auto;
    max-width: 100%;
    min-width: 0;
}

.static-directory-chinese {
    color: var(--bronze-bright);
    font-family: var(--cjk);
    font-size: 24px;
    line-height: 1;
    align-self: center;
}

.static-directory-symbol {
    align-self: center;
    justify-self: center;
    color: var(--bronze-bright);
    font-family: var(--cjk);
    font-size: 28px;
    line-height: 1;
    text-shadow: 0 0 22px rgba(201, 163, 92, 0.16);
}

.static-directory-card strong {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 52px;
    font-family: var(--serif);
    font-size: 20px;
    font-weight: 500;
    line-height: 1.25;
    text-wrap: balance;
}

.static-directory-card small {
    color: var(--slate);
    font-family: var(--serif);
    font-size: 14px;
    font-style: italic;
    line-height: 1.2;
    min-width: 0;
    overflow-wrap: anywhere;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

h2 {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(28px, 3.6vw, 38px);
    letter-spacing: 0.01em;
    margin: 0 0 12px;
    color: var(--parchment);
}

h3 {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 22px;
    color: var(--bronze-bright);
    margin: 0 0 10px;
    letter-spacing: 0.01em;
}

.lede {
    font-family: var(--serif);
    font-size: 19px;
    color: var(--parchment-2);
    opacity: 0.85;
    max-width: 70ch;
    margin: 0 0 32px;
    font-style: italic;
}

p { margin: 0 0 12px; }

.nowrap {
    white-space: nowrap;
}

/* =========================================================
   Cast View
   ========================================================= */
.question-form {
    background: linear-gradient(180deg, rgba(36, 27, 21, 0.7), rgba(26, 20, 16, 0.7));
    border: 1px solid var(--rule);
    border-radius: var(--r-lg);
    padding: 28px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(4px);
    margin-bottom: 28px;
}

.question-guide {
    margin: 0 0 16px;
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    background: rgba(36, 27, 21, 0.42);
    overflow: hidden;
}

.daily-hexagram {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 22px;
    align-items: center;
    margin: 0 0 18px;
    padding: 22px;
    border: 1px solid var(--rule);
    border-radius: var(--r-lg);
    background:
        linear-gradient(135deg, rgba(92, 138, 106, 0.14), transparent 42%),
        linear-gradient(180deg, rgba(36, 27, 21, 0.64), rgba(26, 20, 16, 0.58));
    box-shadow: var(--shadow-lift);
}

.daily-kicker {
    margin: 0 0 8px;
    color: var(--bronze);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.daily-copy h3 {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 8px;
    color: var(--parchment);
    font-family: var(--serif);
    font-size: 25px;
    font-weight: 500;
}

.daily-copy h3 span {
    color: var(--bronze-bright);
    font-family: var(--cjk);
    font-size: 34px;
    line-height: 1;
}

.daily-copy p:last-child {
    margin: 0;
    max-width: 68ch;
    color: var(--parchment-2);
    font-family: var(--serif);
    font-size: 18px;
    line-height: 1.55;
}

.daily-actions {
    display: grid;
    gap: 10px;
}

.daily-hex-link,
.daily-reflect-btn {
    appearance: none;
    display: grid;
    justify-items: center;
    gap: 8px;
    min-width: 178px;
    padding: 14px 16px;
    color: var(--parchment);
    background: rgba(14, 11, 8, 0.44);
    border: 1px solid var(--rule-strong);
    border-radius: var(--r-md);
    cursor: pointer;
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-decoration: none;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.daily-hex-link:hover,
.daily-hex-link:focus-visible,
.daily-reflect-btn:hover,
.daily-reflect-btn:focus-visible {
    transform: translateY(-2px);
    border-color: var(--bronze);
    background: rgba(46, 35, 27, 0.72);
    outline: none;
}

.daily-reflect-btn {
    min-width: 178px;
    min-height: 44px;
    background: rgba(92, 138, 106, 0.16);
    border-color: rgba(92, 138, 106, 0.48);
}

.question-guide summary {
    cursor: pointer;
    padding: 14px 18px;
    color: var(--bronze-bright);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.question-guide summary:hover {
    color: var(--parchment);
}

.question-guide-body {
    padding: 0 18px 18px;
    color: var(--parchment-2);
    font-family: var(--serif);
    font-size: 17px;
    line-height: 1.65;
}

.question-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.question-example {
    appearance: none;
    display: inline-flex;
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    padding: 7px 10px;
    background: rgba(14, 11, 8, 0.3);
    color: var(--slate);
    font-family: var(--sans);
    font-size: 12px;
    font-style: normal;
    letter-spacing: 0.04em;
    cursor: pointer;
    text-align: left;
    transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.question-example:hover,
.question-example:focus-visible {
    border-color: var(--bronze);
    color: var(--parchment);
    background: rgba(46, 35, 27, 0.56);
    outline: none;
}

.question-template-picker {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.question-template-picker label {
    color: var(--bronze);
    font-family: var(--sans);
    font-size: 11px;
    font-style: normal;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.question-template-picker select {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    color: var(--parchment);
    background: rgba(14, 11, 8, 0.55);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    font-family: var(--sans);
    font-size: 14px;
}

.question-template-picker select:focus {
    outline: none;
    border-color: var(--bronze);
    box-shadow: 0 0 0 2px rgba(201, 163, 92, 0.14);
}

.question-form label {
    display: block;
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--bronze);
    margin-bottom: 10px;
}

textarea#question {
    width: 100%;
    background: rgba(14, 11, 8, 0.6);
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    color: var(--parchment);
    font-family: var(--serif);
    font-size: 19px;
    padding: 14px 16px;
    resize: vertical;
    min-height: 58px;
    line-height: 1.5;
    transition: border-color 200ms ease, box-shadow 200ms ease;
}

textarea#question:focus {
    outline: none;
    border-color: var(--bronze);
    box-shadow: 0 0 0 2px rgba(201, 163, 92, 0.15);
}

textarea#question::placeholder {
    color: var(--slate);
    font-style: italic;
    opacity: 0.7;
}

.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.cast-control-row {
    align-items: flex-end;
}

.casting-control-panel {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--bronze);
}

.method-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.method-option {
    position: relative;
    cursor: pointer;
}

.method-option input { position: absolute; opacity: 0; pointer-events: none; }

.method-option span {
    display: inline-block;
    padding: 10px 16px;
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--slate);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    transition: all 200ms ease;
}

.method-option input:checked + span {
    color: var(--ink);
    background: var(--bronze);
    border-color: var(--bronze);
    font-weight: 500;
}

.method-option:hover span { color: var(--parchment); }
.method-option input:checked:hover + span { color: var(--ink); }

.method-note {
    margin: 14px 0 0;
    font-size: 13px;
    color: var(--slate);
    font-style: italic;
}

.primary-btn {
    appearance: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink);
    background: linear-gradient(180deg, var(--bronze-bright), var(--bronze));
    border: 1px solid var(--bronze-deep);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-lift);
    transition: transform 150ms ease, box-shadow 200ms ease, filter 200ms ease;
}

.primary-btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.primary-btn:active { transform: translateY(0); filter: brightness(0.96); }
.primary-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-glyph { font-size: 16px; }

.ghost-btn {
    appearance: none;
    cursor: pointer;
    padding: 10px 18px;
    background: transparent;
    border: 1px solid var(--rule-strong);
    color: var(--parchment-2);
    font-family: var(--sans);
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    border-radius: var(--r-sm);
    transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}

.ghost-btn:hover {
    background: rgba(201, 163, 92, 0.08);
    border-color: var(--bronze);
    color: var(--parchment);
}

/* =========================================================
   Casting stage + coins / yarrow
   ========================================================= */
.casting-stage {
    background: rgba(14, 11, 8, 0.4);
    border: 1px solid var(--rule);
    border-radius: var(--r-lg);
    padding: 36px 28px;
    text-align: center;
    margin-bottom: 28px;
}

.coin-row {
    display: flex;
    justify-content: center;
    gap: 28px;
    margin-bottom: 20px;
    perspective: 800px;
}

.coin-row[hidden] {
    display: none;
}

.coin {
    width: 72px;
    height: 72px;
    position: relative;
    transform-style: preserve-3d;
}

.coin-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 600ms cubic-bezier(.3, .8, .4, 1);
}

.coin.flipping .coin-inner {
    animation: coin-flip 700ms cubic-bezier(.3, .8, .4, 1);
}

.coin.heads .coin-inner { transform: rotateY(0deg); }
.coin.tails .coin-inner { transform: rotateY(180deg); }

@keyframes coin-flip {
    0%   { transform: rotateY(0deg)   translateY(0) scale(1); }
    40%  { transform: rotateY(540deg) translateY(-40px) scale(1.08); }
    100% { transform: rotateY(1080deg) translateY(0) scale(1); }
}

.yarrow-stage {
    min-height: 124px;
    margin-bottom: 20px;
}

.yarrow-stage[hidden] {
    display: none;
}

.yarrow-bundle,
.yarrow-pile {
    position: relative;
    height: 78px;
}

.yarrow-bundle {
    width: 230px;
    margin: 0 auto 10px;
}

.yarrow-groups {
    display: grid;
    grid-template-columns: repeat(3, minmax(70px, 1fr));
    align-items: end;
    gap: 18px;
    max-width: 360px;
    margin: 0 auto;
}

.yarrow-pile {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 260ms ease, transform 260ms ease;
}

.yarrow-pile.revealed {
    opacity: 1;
    transform: translateY(0);
}

.yarrow-stick {
    position: absolute;
    left: 50%;
    bottom: 4px;
    width: 4px;
    height: 68px;
    border-radius: 999px;
    background: linear-gradient(180deg, #e2c88c, #9b7638 70%, #6e4d26);
    box-shadow: 0 1px 0 rgba(255, 242, 188, 0.4) inset, 0 5px 10px rgba(0, 0, 0, 0.25);
    transform: translateX(var(--shift, 0)) rotate(var(--lean, 0deg));
    transform-origin: 50% 100%;
}

.yarrow-bundle.sorting .yarrow-stick {
    animation: yarrow-gather 760ms cubic-bezier(.3, .8, .4, 1) both;
}

.yarrow-left .yarrow-stick {
    height: 58px;
}

.yarrow-center .yarrow-stick {
    height: 42px;
    background: linear-gradient(180deg, #f0dca3, #bd8d40 70%, #7a5329);
}

.yarrow-right .yarrow-stick {
    height: 62px;
}

@keyframes yarrow-gather {
    0% {
        opacity: 1;
        transform: translateX(var(--shift, 0)) rotate(var(--lean, 0deg));
    }
    45% {
        opacity: 1;
        transform: translateX(var(--gather-shift, 0)) translateY(-18px) rotate(var(--gather-lean, 0deg));
    }
    100% {
        opacity: 0.18;
        transform: translateX(var(--shift, 0)) translateY(8px) rotate(var(--lean, 0deg));
    }
}

.face {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--cjk);
    font-size: 30px;
    color: var(--ink);
    backface-visibility: hidden;
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35), 0 6px 14px rgba(0, 0, 0, 0.5);
}

.face.heads {
    background: radial-gradient(circle at 30% 30%, #f3d78c, var(--bronze) 55%, var(--bronze-deep));
    transform: rotateY(0deg);
}

.face.tails {
    background: radial-gradient(circle at 30% 30%, #cbb88a, #8a6a2e 60%, #4a3618);
    color: var(--parchment);
    transform: rotateY(180deg);
}

.cast-progress {
    font-family: var(--serif);
    font-size: 17px;
    color: var(--parchment-2);
    font-style: italic;
    margin: 0 0 16px;
}

.manual-cast-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 22px;
}

.manual-cast-actions[hidden] {
    display: none;
}

.building-hexagram {
    display: inline-flex;
    flex-direction: column-reverse;
    gap: 8px;
    padding: 16px 24px;
    min-height: 142px;
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    background: rgba(36, 27, 21, 0.5);
}

.building-hexagram .line {
    width: 140px;
    height: 10px;
    position: relative;
    animation: line-appear 400ms ease both;
}

.building-hexagram .line.yang {
    background: var(--bronze-bright);
    border-radius: 2px;
}

.building-hexagram .line.yin {
    background: transparent;
    display: flex;
    justify-content: space-between;
}

.building-hexagram .line.yin::before,
.building-hexagram .line.yin::after {
    content: '';
    width: 60px;
    height: 10px;
    background: var(--bronze-bright);
    border-radius: 2px;
}

.building-hexagram .line.changing::after {
    content: '';
    position: absolute;
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cinnabar-2);
    box-shadow: 0 0 8px var(--cinnabar);
}

.building-hexagram .line.yin.changing::after {
    content: '×';
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: auto; height: auto;
    background: transparent;
    box-shadow: none;
    color: var(--cinnabar-2);
    font-size: 18px;
    font-weight: 700;
    border-radius: 0;
}

@keyframes line-appear {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* =========================================================
   Reading Output
   ========================================================= */
.reading {
    animation: fade-up 600ms ease both;
}

.reading-header {
    text-align: center;
    margin-bottom: 36px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--rule);
}

.reading-question {
    font-family: var(--serif);
    font-style: italic;
    font-size: 20px;
    color: var(--parchment-2);
    max-width: 60ch;
    margin: 0 auto 14px;
}

.reading-date {
    font-size: 12px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--slate);
}

.hex-pair {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 24px;
    align-items: center;
    margin-bottom: 40px;
}

.hex-pair.single { grid-template-columns: 1fr; justify-items: center; }

.hex-arrow {
    font-size: 28px;
    color: var(--bronze);
    opacity: 0.7;
    text-align: center;
}

.hex-card {
    appearance: none;
    display: block;
    width: 100%;
    background: linear-gradient(180deg, rgba(36, 27, 21, 0.8), rgba(26, 20, 16, 0.8));
    border: 1px solid var(--rule-strong);
    border-radius: var(--r-lg);
    padding: 28px;
    text-align: center;
    box-shadow: var(--shadow-soft);
    color: inherit;
    font: inherit;
    text-decoration: none;
}

.hex-card-link {
    cursor: pointer;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.hex-card-link:hover,
.hex-card-link:focus-visible {
    transform: translateY(-2px);
    border-color: var(--bronze);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
    outline: none;
}

.hex-card.compact {
    max-width: 360px;
    margin: 0 auto 18px;
    padding: 22px;
}

.hex-card .hex-role {
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--bronze);
    margin-bottom: 12px;
}

.hex-card .hex-number {
    font-family: var(--serif);
    font-size: 14px;
    color: var(--slate);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.hex-card .hex-chinese {
    font-family: var(--cjk);
    font-size: 34px;
    line-height: 1;
    color: var(--bronze-bright);
    margin: 4px 0;
    text-shadow: 0 0 24px rgba(201, 163, 92, 0.18);
}

.hex-card .hex-symbol {
    font-family: var(--cjk);
    font-size: 54px;
    line-height: 1;
    color: var(--bronze-bright);
    margin: 8px 0 0;
    text-shadow: 0 0 24px rgba(201, 163, 92, 0.18);
}

.hex-card .hex-pinyin {
    font-family: var(--serif);
    font-style: italic;
    font-size: 16px;
    color: var(--parchment-2);
    margin-bottom: 2px;
}

.hex-card .hex-name {
    font-family: var(--serif);
    font-size: 26px;
    color: var(--parchment);
    margin-bottom: 16px;
}

.hexagram-svg {
    display: block;
    margin: 12px auto 0;
}

.section-block {
    margin-bottom: 36px;
}

.section-block h2,
.section-block h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 8px;
    margin-bottom: 14px;
    font-size: 17px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--bronze);
    font-weight: 500;
}

.inline-hex-link {
    appearance: none;
    display: inline-flex;
    align-items: center;
    color: inherit;
    background: transparent;
    border: 0;
    padding: 0;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    text-decoration: none;
    cursor: pointer;
}

.inline-hex-link:hover,
.inline-hex-link:focus-visible {
    color: var(--bronze-bright);
    outline: none;
}

.relating-section .story-section {
    margin-top: 24px;
}

.relating-card-wrap {
    margin: 18px 0 24px;
}

.judgment, .image-text, .interpretation {
    font-family: var(--serif);
    font-size: 19px;
    line-height: 1.75;
    color: var(--parchment-2);
}

.synthesis-section {
    padding: 22px 24px 6px;
    background: linear-gradient(180deg, rgba(92, 138, 106, 0.12), rgba(14, 11, 8, 0.32));
    border: 1px solid rgba(92, 138, 106, 0.38);
    border-radius: var(--r-md);
}

.synthesis-section h3 {
    color: var(--jade);
}

.synthesis-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 18px;
    padding: 16px 0;
    border-top: 1px solid rgba(201, 163, 92, 0.16);
}

.synthesis-row:first-of-type {
    border-top: none;
}

.synthesis-label {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--bronze);
    font-weight: 500;
}

.synthesis-copy {
    margin: 0;
    font-family: var(--serif);
    font-size: 18px;
    line-height: 1.7;
    color: var(--parchment-2);
}

.synthesis-copy strong {
    color: var(--parchment);
    font-weight: 600;
}

.synthesis-line-list {
    margin: 10px 0 0;
    padding-left: 20px;
    color: var(--parchment-2);
}

.synthesis-line-list li {
    margin-bottom: 8px;
}

.story-section h3 {
    color: var(--jade);
}

.story-text {
    font-family: var(--serif);
    font-size: 20px;
    line-height: 1.75;
    color: var(--parchment);
    background: rgba(14, 11, 8, 0.42);
    border: 1px solid var(--rule);
    border-left: 3px solid var(--jade);
    border-radius: var(--r-md);
    padding: 20px 22px;
}

.story-visuals {
    margin-top: 18px;
}

.story-panel-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.story-panel {
    display: block;
    margin: 0;
    background: rgba(14, 11, 8, 0.42);
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    overflow: hidden;
    transition: border-color 180ms ease, transform 180ms ease;
}

.story-panel-grid .story-panel:hover {
    border-color: var(--bronze);
    transform: translateY(-1px);
}

.story-panel.missing {
    display: none;
}

.story-panel-open {
    appearance: none;
    display: block;
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    overflow: hidden;
}

.story-panel-open:focus-visible {
    outline: 2px solid var(--bronze-bright);
    outline-offset: -3px;
}

.story-panel-open img,
.story-panel > img {
    display: block;
    width: 100%;
    height: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    object-position: center;
}

.story-panel > img {
    height: auto;
}

.story-panel-zoom {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(232, 217, 184, 0.45);
    border-radius: 999px;
    background: rgba(14, 11, 8, 0.68);
    color: var(--parchment);
    font-size: 17px;
    line-height: 1;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.story-panel:hover .story-panel-zoom,
.story-panel-open:focus-visible .story-panel-zoom {
    opacity: 1;
    transform: translateY(0);
    border-color: var(--bronze-bright);
}

.story-panel figcaption {
    padding: 9px 12px 10px;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bronze);
}

body.story-lightbox-open {
    overflow: hidden;
}

.story-lightbox[hidden] {
    display: none;
}

.story-lightbox {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 24px;
}

.story-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(14, 11, 8, 0.82);
    backdrop-filter: blur(8px);
}

.story-lightbox-shell {
    position: relative;
    z-index: 1;
    width: min(1180px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
    overflow: hidden;
    border: 1px solid var(--rule-strong);
    border-radius: var(--r-md);
    background: linear-gradient(180deg, rgba(36, 27, 21, 0.98), rgba(14, 11, 8, 0.98));
    box-shadow: var(--shadow-soft);
}

.story-lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(232, 217, 184, 0.28);
    border-radius: 999px;
    background: rgba(14, 11, 8, 0.72);
    color: var(--parchment);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.story-lightbox-close:hover,
.story-lightbox-close:focus-visible {
    border-color: var(--cinnabar-2);
    color: var(--cinnabar-2);
    outline: none;
}

.story-lightbox-media {
    position: relative;
    min-width: 0;
    min-height: 0;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.42);
}

.story-lightbox-image {
    display: block;
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 48px);
    object-fit: contain;
}

.story-lightbox-nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 46px;
    height: 56px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(232, 217, 184, 0.28);
    background: rgba(14, 11, 8, 0.68);
    color: var(--parchment);
    font-size: 42px;
    line-height: 1;
    transform: translateY(-50%);
    cursor: pointer;
}

.story-lightbox-prev { left: 14px; border-radius: 999px 6px 6px 999px; }
.story-lightbox-next { right: 14px; border-radius: 6px 999px 999px 6px; }

.story-lightbox-nav:hover,
.story-lightbox-nav:focus-visible {
    border-color: var(--bronze-bright);
    color: var(--bronze-bright);
    outline: none;
}

.story-lightbox-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.story-lightbox-details {
    min-width: 0;
    overflow-y: auto;
    padding: 34px 34px 30px;
    border-left: 1px solid var(--rule);
}

.story-lightbox-kicker {
    margin: 0 48px 10px 0;
    color: var(--bronze);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.story-lightbox-details h3 {
    margin-right: 42px;
    color: var(--parchment);
    font-size: 28px;
}

.story-lightbox-copy {
    display: grid;
    gap: 20px;
    margin-top: 22px;
}

.story-lightbox-label {
    margin-bottom: 6px;
    color: var(--jade);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.story-lightbox-summary,
.story-lightbox-part {
    margin: 0;
    color: var(--parchment-2);
    font-family: var(--serif);
    font-size: 19px;
    line-height: 1.65;
}

.relating-story {
    margin: 14px 0 16px;
    font-size: 18px;
    color: var(--parchment-2);
}

.judgment, .image-text {
    font-style: italic;
    padding-left: 20px;
    border-left: 2px solid var(--bronze-deep);
}

.lines-block {
    margin-top: 12px;
}

.line-entry {
    padding: 16px 0 14px;
    border-bottom: 1px dotted var(--rule);
}

.line-entry:last-child { border-bottom: none; }

.line-entry .line-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--bronze);
}

.line-entry .line-glyph {
    display: inline-block;
    width: 42px;
    height: 10px;
    position: relative;
}

.line-entry .line-glyph.yang { background: var(--bronze-bright); border-radius: 2px; }
.line-entry .line-glyph.yin { display: flex; justify-content: space-between; }
.line-entry .line-glyph.yin::before,
.line-entry .line-glyph.yin::after {
    content: '';
    width: 18px;
    height: 10px;
    background: var(--bronze-bright);
    border-radius: 2px;
}

.line-entry.changing .line-header { color: var(--cinnabar-2); }
.line-entry.changing {
    background: linear-gradient(90deg, rgba(184, 65, 45, 0.07), transparent);
    padding-left: 14px;
    border-left: 2px solid var(--cinnabar);
    margin: 4px -14px;
    padding-right: 14px;
}

.line-text {
    font-family: var(--serif);
    font-size: 18px;
    color: var(--parchment-2);
    line-height: 1.65;
}

.changing-marker {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(184, 65, 45, 0.18);
    border: 1px solid var(--cinnabar);
    border-radius: 3px;
    color: var(--cinnabar-2);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 500;
}

.reading-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 32px;
    flex-wrap: wrap;
}

.reflection-section {
    background: linear-gradient(180deg, rgba(36, 27, 21, 0.44), rgba(26, 20, 16, 0.38));
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    padding: 22px;
}

.reflection-intro {
    font-family: var(--serif);
    font-size: 18px;
    color: var(--parchment-2);
    line-height: 1.65;
    margin: 0 0 18px;
}

.reflection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.reflection-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.reflection-field label {
    color: var(--bronze);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.reflection-prompt {
    min-height: 3.4em;
    margin: 0 0 8px;
    color: var(--slate);
    font-family: var(--serif);
    font-size: 16px;
    font-style: italic;
    line-height: 1.45;
}

.reflection-field textarea {
    width: 100%;
    min-height: 116px;
    resize: vertical;
    padding: 12px 13px;
    color: var(--parchment);
    background: rgba(14, 11, 8, 0.52);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    font-family: var(--serif);
    font-size: 17px;
    line-height: 1.5;
    transition: border-color 200ms ease, box-shadow 200ms ease;
}

.reflection-field textarea:focus {
    outline: none;
    border-color: var(--bronze);
    box-shadow: 0 0 0 2px rgba(201, 163, 92, 0.14);
}

.journal-save-status {
    margin-top: 12px;
    color: var(--slate);
    font-size: 12px;
    font-style: italic;
}

.trigram-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-top: 14px;
}

.trigram-card {
    background: rgba(14, 11, 8, 0.5);
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    padding: 18px;
}

.trigram-card .trigram-role {
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--bronze);
    margin-bottom: 8px;
}

.trigram-card .trigram-chinese {
    font-family: var(--cjk);
    font-size: 28px;
    color: var(--bronze-bright);
    margin: 4px 0;
}

.trigram-card .trigram-name {
    font-family: var(--serif);
    font-size: 18px;
    color: var(--parchment);
}

.trigram-card .trigram-meaning {
    font-size: 13px;
    color: var(--slate);
    margin-top: 6px;
    font-style: italic;
}

/* =========================================================
   Hexagram Directory
   ========================================================= */
.hex-search {
    width: 100%;
    max-width: 420px;
    padding: 12px 16px;
    margin-bottom: 28px;
    background: rgba(14, 11, 8, 0.6);
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    color: var(--parchment);
    font-family: var(--sans);
    font-size: 14px;
    transition: border-color 200ms ease;
}

.hex-search:focus { outline: none; border-color: var(--bronze); }

.hex-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}

.hex-tile {
    appearance: none;
    display: grid;
    grid-template-rows: auto 16px 30px 30px minmax(3.75em, auto);
    align-content: start;
    row-gap: 7px;
    background: linear-gradient(180deg, rgba(36, 27, 21, 0.6), rgba(26, 20, 16, 0.6));
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    padding: 18px 14px;
    text-align: center;
    cursor: pointer;
    color: var(--parchment);
    font-family: var(--sans);
    text-decoration: none;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
    overflow: hidden;
}

.hex-tile:hover,
.hex-tile.selected {
    transform: translateY(-2px);
    border-color: var(--bronze);
    background: linear-gradient(180deg, rgba(46, 35, 27, 0.7), rgba(36, 27, 21, 0.7));
}

.hex-tile.selected {
    box-shadow: 0 0 0 1px rgba(229, 192, 116, 0.24), 0 12px 30px rgba(0, 0, 0, 0.28);
}

.hex-tile.selected .tile-num,
.hex-tile.selected .tile-name {
    color: var(--parchment);
}

.hex-tile.selected .tile-visual {
    border-color: rgba(229, 192, 116, 0.5);
}

.hex-tile .tile-num {
    font-family: var(--serif);
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--slate);
    text-transform: none;
    line-height: 1.2;
}

.tile-mark-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 2px 0 4px;
}

.tile-visual {
    display: block;
    width: calc(100% + 12px);
    box-sizing: border-box;
    margin: -6px -6px 8px;
    border-radius: var(--r-sm);
    border: 1px solid rgba(201, 163, 92, 0.18);
    background: transparent;
    line-height: 0;
}

.tile-visual img {
    display: block;
    width: 100%;
    height: auto;
}

.hex-tile .tile-language {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin: 0 auto;
    max-width: 100%;
    min-width: 0;
}

.hex-tile .tile-chinese {
    font-family: var(--cjk);
    font-size: 24px;
    color: var(--bronze-bright);
    margin: 0;
    line-height: 1;
}

.hex-tile .tile-symbol {
    align-self: center;
    justify-self: center;
    font-family: var(--cjk);
    font-size: 28px;
    line-height: 1;
    color: var(--bronze-bright);
    text-shadow: 0 0 20px rgba(201, 163, 92, 0.16);
}

.hex-tile .tile-pinyin {
    color: var(--slate);
    font-family: var(--serif);
    font-size: 14px;
    font-style: italic;
    line-height: 1.2;
    min-width: 0;
    overflow-wrap: anywhere;
}

.hex-tile .tile-name {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 3.75em;
    font-family: var(--serif);
    font-size: 15px;
    line-height: 1.25;
    text-wrap: balance;
    color: var(--parchment);
}

.hex-detail {
    margin-top: 28px;
    padding: 28px;
    background: linear-gradient(180deg, rgba(36, 27, 21, 0.7), rgba(26, 20, 16, 0.7));
    border: 1px solid var(--rule-strong);
    border-radius: var(--r-lg);
}

.hex-detail-close {
    float: right;
    background: transparent;
    border: none;
    color: var(--slate);
    font-size: 22px;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
}
.hex-detail-close:hover { color: var(--cinnabar-2); }

/* =========================================================
   History
   ========================================================= */
.history-actions {
    margin-bottom: 20px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.history-entry {
    background: rgba(36, 27, 21, 0.55);
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    padding: 18px 20px;
    cursor: pointer;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 18px;
    align-items: center;
    transition: border-color 180ms ease, background 180ms ease;
}

.history-entry:hover {
    border-color: var(--bronze);
    background: rgba(46, 35, 27, 0.6);
}

.history-entry .h-chinese {
    font-family: var(--cjk);
    font-size: 32px;
    color: var(--bronze-bright);
    line-height: 1;
}

.history-entry .h-question {
    font-family: var(--serif);
    font-style: italic;
    font-size: 17px;
    color: var(--parchment-2);
}

.history-entry .h-meta {
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--slate);
    margin-top: 4px;
}

.history-entry .h-reflection {
    margin-top: 8px;
    color: var(--parchment-2);
    font-family: var(--serif);
    font-size: 15px;
    line-height: 1.45;
    opacity: 0.86;
}

.history-entry .h-date {
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--slate);
    text-transform: uppercase;
    text-align: right;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--slate);
    font-style: italic;
    font-family: var(--serif);
    font-size: 17px;
}

/* =========================================================
   About
   ========================================================= */
.about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 26px;
}

.about-grid article {
    background: rgba(36, 27, 21, 0.45);
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    padding: 24px;
}

.about-grid p {
    font-family: var(--serif);
    font-size: 17px;
    line-height: 1.7;
    color: var(--parchment-2);
}

/* =========================================================
   Footer
   ========================================================= */
.site-footer {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 24px 20px 36px;
    border-top: 1px solid var(--rule);
    max-width: var(--maxw);
    margin: 0 auto;
}

.site-footer p {
    font-size: 12px;
    letter-spacing: 0.1em;
    color: var(--slate);
    font-style: italic;
}

.social-footer {
    margin-top: 8px;
}

.support-footer {
    margin-top: 8px;
}

.support-widget {
    margin-top: 12px;
    min-height: 40px;
}

.support-widget .btn-container {
    margin-top: 2px;
}

.support-link {
    display: inline-flex;
    margin-top: 4px;
    padding: 8px 12px;
    color: var(--bronze-bright);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    font-size: 11px;
    font-style: normal;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-decoration: none;
    text-transform: uppercase;
    transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.support-link:hover,
.support-link:focus-visible {
    color: var(--parchment);
    border-color: var(--bronze);
    background: rgba(201, 163, 92, 0.08);
    outline: none;
}

.support-link[hidden],
.support-footer[hidden],
.support-widget[hidden] {
    display: none;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 720px) {
    .site-header { padding: 24px 20px 14px; }
    main { padding: 32px 20px 60px; }
    .brand-glyph { font-size: 44px; }
    .site-nav { width: 100%; }
    .social-nav-text { display: none; }
    .social-nav-link { min-width: 40px; padding-inline: 10px; }
    .static-hero { grid-template-columns: 1fr; }
    .static-prev-next { grid-template-columns: 1fr; }
    .static-prev-next a:last-child { text-align: left; }
    .static-share-actions .ghost-btn { width: 100%; }
    .hex-pair { grid-template-columns: 1fr; }
    .hex-arrow { transform: rotate(90deg); margin: 4px 0; }
    .daily-hexagram { grid-template-columns: 1fr; }
    .daily-actions,
    .daily-hex-link,
    .daily-reflect-btn { width: 100%; }
    .synthesis-row { grid-template-columns: 1fr; gap: 6px; }
    .story-panel-grid { grid-template-columns: 1fr; }
    .question-example { width: 100%; }
    textarea#question { min-height: 148px; }
    .form-row { flex-direction: column; align-items: stretch; }
    .casting-control-panel { flex-direction: column; }
    .primary-btn { width: 100%; justify-content: center; }
    .static-directory-grid,
    .hex-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .history-entry { grid-template-columns: auto 1fr; }
    .history-entry .h-date { grid-column: 1 / -1; text-align: left; }
    .story-lightbox { padding: 12px; }
    .story-lightbox-shell {
        width: calc(100vw - 24px);
        max-height: calc(100vh - 24px);
        grid-template-columns: 1fr;
    }
    .story-lightbox-media {
        min-height: 0;
        max-height: 54vh;
    }
    .story-lightbox-image {
        max-height: 54vh;
    }
    .story-lightbox-details {
        max-height: 38vh;
        padding: 22px 20px 24px;
        border-left: 0;
        border-top: 1px solid var(--rule);
    }
    .story-lightbox-kicker,
    .story-lightbox-details h3 {
        margin-right: 46px;
    }
    .story-lightbox-details h3 {
        font-size: 23px;
    }
    .story-lightbox-summary,
    .story-lightbox-part {
        font-size: 17px;
    }
    .story-lightbox-nav {
        width: 40px;
        height: 48px;
        font-size: 34px;
    }
    .story-lightbox-prev { left: 8px; }
    .story-lightbox-next { right: 8px; }
    .share-toast {
        right: 20px;
        bottom: 18px;
        left: 20px;
        max-width: none;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .static-directory-grid,
    .hex-grid { grid-template-columns: 1fr; }
}

/* =========================================================
   Print / Save PDF
   ========================================================= */
@media print {
    @page {
        margin: 14mm;
    }

    * {
        animation: none !important;
        box-shadow: none !important;
        text-shadow: none !important;
        transition: none !important;
    }

    html,
    body {
        width: auto;
        min-height: 0;
        overflow: visible !important;
        color: #18130f !important;
        background: #fffaf0 !important;
        font-size: 11pt;
        line-height: 1.45;
    }

    body {
        background: #fffaf0 !important;
    }

    .starfield,
    .site-header,
    .site-footer,
    .cast-intro,
    .daily-hexagram,
    .question-guide,
    .question-form,
    .casting-stage,
    .reading-actions,
    .static-share-panel,
    .share-toast,
    .story-lightbox,
    .story-panel-zoom {
        display: none !important;
    }

    main {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .view {
        animation: none !important;
    }

    .view[hidden],
    .reading[hidden] {
        display: none !important;
    }

    .reading {
        color: #18130f !important;
        background: transparent !important;
    }

    .reading-header {
        margin-bottom: 16pt;
        padding-bottom: 12pt;
        border-bottom: 1px solid #b7a886;
    }

    .reading-question {
        max-width: none;
        color: #18130f !important;
        font-size: 15pt;
    }

    .reading-date,
    .hex-card .hex-number,
    .hex-card .hex-role,
    .line-entry .line-header,
    .synthesis-label,
    .story-panel figcaption,
    .trigram-card .trigram-role,
    .trigram-card .trigram-meaning {
        color: #66583d !important;
    }

    .hex-pair {
        grid-template-columns: 1fr auto 1fr;
        gap: 12pt;
        align-items: start;
        margin-bottom: 18pt;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .hex-pair.single {
        grid-template-columns: 1fr;
    }

    .hex-arrow {
        color: #66583d !important;
    }

    .hex-card,
    .hex-card.compact,
    .synthesis-section,
    .story-text,
    .reflection-section,
    .trigram-card,
    .hex-detail,
    .story-panel {
        background: transparent !important;
        border-color: #c8b894 !important;
        color: #18130f !important;
    }

    .hex-card {
        padding: 12pt;
    }

    .hex-card .hex-chinese,
    .trigram-card .trigram-chinese {
        color: #7a5329 !important;
    }

    .hex-card .hex-name,
    .hex-card .hex-pinyin,
    .trigram-card .trigram-name,
    .judgment,
    .image-text,
    .interpretation,
    .story-text,
    .line-text,
    .synthesis-copy,
    .synthesis-line-list,
    .story-lightbox-summary,
    .story-lightbox-part,
    .reflection-intro,
    .reflection-prompt,
    .reflection-field textarea {
        color: #18130f !important;
    }

    .section-block {
        margin-bottom: 18pt;
        break-inside: avoid-page;
    }

    .section-block h3 {
        color: #5c6f4b !important;
        border-bottom-color: #c8b894 !important;
        font-size: 12pt;
    }

    .story-text,
    .judgment,
    .image-text {
        border-left-color: #8a6a2e !important;
    }

    .story-panel-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8pt;
    }

    .story-panel {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .story-panel-open {
        cursor: default;
    }

    .story-panel img {
        max-height: 48mm;
        object-fit: cover;
    }

    .line-entry {
        break-inside: avoid;
        page-break-inside: avoid;
        border-bottom-color: #c8b894 !important;
    }

    .line-entry.changing {
        background: transparent !important;
        border-left-color: #9a4a35 !important;
    }

    .line-entry .line-glyph.yang,
    .line-entry .line-glyph.yin::before,
    .line-entry .line-glyph.yin::after {
        background: #7a5329 !important;
    }

    .changing-marker {
        border-color: #9a4a35 !important;
        background: transparent !important;
        color: #9a4a35 !important;
    }

    .trigram-breakdown,
    .synthesis-row,
    .reflection-grid,
    .reflection-field {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .inline-hex-link {
        color: #18130f !important;
        cursor: default;
    }

    .reflection-section {
        padding: 12pt;
    }

    .reflection-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10pt;
    }

    .reflection-field label {
        color: #66583d !important;
    }

    .reflection-field textarea {
        background: transparent !important;
        border-color: #c8b894 !important;
        min-height: 24mm;
        resize: none;
    }

    .journal-save-status {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
