:root {
  color-scheme: light;
  --paper: #f6f5ee;
  --ground: #eeefe5;
  --ink: #232b22;
  --muted: #535e50;
  --line: #c7cdbf;
  --leaf: #294538;
  --seal: #9d4638;
  --white: #fffef8;
  --coin: #e8d7af;
  --coin-edge: #80643e;
  --serif: Georgia, serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1rem/1.58 var(--sans); }
a { color: var(--leaf); text-underline-offset: .22em; }
a:hover { color: var(--seal); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .64; }
:focus-visible { outline: 2px solid var(--seal); outline-offset: 4px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.05; }
h2 { font-size: clamp(1.65rem, 3vw, 2.4rem); margin-bottom: 1rem; }
h3 { font-size: 1.48rem; margin-bottom: .7rem; }
h1 { font-size: clamp(2.65rem, 7vw, 5.7rem); letter-spacing: -.065em; margin-bottom: 1rem; }
.site-shell { max-width: 1160px; width: calc(100% - 64px); margin-inline: auto; }
.site-header, .site-footer { border-block-end: 1px solid var(--line); }
.header-inner, .footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: 68px; }
.site-header nav, .site-footer nav { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; }
.site-header a, .site-footer a { text-decoration: none; font-size: .91rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink); font-family: var(--serif); font-size: 1.24rem !important; white-space: nowrap; }
.seal { width: 27px; height: 27px; border: 1px solid var(--seal); color: var(--seal); display: grid; align-content: center; gap: 3px; padding: 4px; border-radius: 3px; }
.seal i { height: 2px; background: currentColor; }
.seal i:nth-child(2) { background: linear-gradient(to right,currentColor 40%,transparent 40% 60%,currentColor 60%); }
.site-footer { margin-top: 4rem; border: 0; border-top: 1px solid var(--line); }
.footer-inner p { margin: 0; color: var(--muted); font-size: .86rem; }
.skip-link { position: absolute; z-index: 1; top: .5rem; left: .5rem; padding: .5rem; background: var(--white); transform: translateY(-200%); }
.skip-link:focus { transform: none; }

.cast-hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(310px, .85fr); align-items: center; gap: clamp(2rem, 7vw, 6.5rem); padding: clamp(2.4rem, 7vw, 6rem) 0 2.8rem; }
.cast-intro h1 { max-width: 10ch; }
.eyebrow { margin: 0 0 .75rem; font-size: .75rem; font-weight: 660; letter-spacing: .105em; text-transform: uppercase; color: var(--muted); }
.intro { max-width: 41ch; color: var(--muted); font-size: 1.07rem; margin-bottom: 1.4rem; }
.modes { display: inline-flex; max-width: 100%; gap: 2px; border: 1px solid var(--line); padding: 3px; background: var(--ground); border-radius: 6px; }
.modes button { background: transparent; color: var(--muted); border: 0; border-radius: 4px; padding: .53rem .77rem; min-height: 42px; font-size: .87rem; }
.modes button[aria-pressed="true"] { background: var(--white); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.coins { display: flex; gap: .55rem; margin: 1.16rem 0 .65rem; }
.coins span { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--coin-edge); border-radius: 50%; color: var(--ink); background: var(--coin); box-shadow: inset 0 0 0 3px var(--paper); font: 700 .72rem/1 var(--serif); }
.coins span[data-tail] { color: var(--ink); border-color: var(--coin-edge); background: var(--ground); box-shadow: inset 0 0 0 3px var(--paper); }
.mode-hint { font-size: .88rem; color: var(--muted); min-height: 1.4em; margin: .65rem 0; }
.cast-actions, .inline-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.button { border: 1px solid transparent; border-radius: 5px; padding: .64rem 1rem; min-height: 44px; font-size: .92rem; font-weight: 610; }
.button.primary { background: var(--leaf); color: var(--white); }
.button.primary:hover:not(:disabled) { background: var(--ink); }
.button.secondary { border-color: var(--leaf); background: transparent; color: var(--leaf); }
.button.quiet { background: transparent; color: var(--leaf); text-decoration: underline; text-underline-offset: .2em; }
.status { min-height: 1.5em; margin: .42rem 0 0; font-size: .84rem; color: var(--muted); }
.cast-board { background: var(--ground); border: 1px solid var(--line); border-radius: 9px; padding: clamp(1.05rem, 4vw, 2rem); }
.board-header { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.board-header h2 { font-size: 1.45rem; }
.board-header > span { font: .85rem/1.2 var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3rem; text-align: right; }
.cast-lines { list-style: none; margin: 0; padding: 0; }
.cast-lines > li { display: grid; grid-template-columns: 1.7rem minmax(44px,1fr) minmax(3rem,auto); align-items: center; gap: .65rem; min-height: 37px; border-bottom: 1px solid var(--line); }
.line-number, .line-value { font-size: .79rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.line-value { text-align: right; min-width: 2rem; }
.glyph-line { display: grid; grid-template-columns: 1fr 14% 1fr; width: 100%; height: 7px; border-radius: 1px; }
.glyph-line::before, .glyph-line::after { content: ""; grid-row: 1; background: var(--leaf); }
.glyph-line::before { grid-column: 1; }
.glyph-line::after { grid-column: 3; }
.glyph-line.yang::before { grid-column: 1 / -1; }
.glyph-line.yang::after { display: none; }
.glyph-line.empty::before { grid-column: 1 / -1; background: transparent; border-block-end: 1px dashed var(--muted); }
.glyph-line.empty::after { display: none; }
.glyph-line.moving::before, .glyph-line.moving::after { background: var(--seal); }
.line-select { width: 7.95rem; max-width: 100%; border: 1px solid var(--muted); border-radius: 4px; padding: .27rem .1rem .27rem .3rem; background: var(--white); color: var(--ink); font-size: .79rem; min-height: 32px; }
.board-caption { margin: .9rem 0 0; color: var(--muted); font-size: .85rem; }
.board-caption span { margin-right: .4rem; color: var(--seal); }
.reading { border-top: 1px solid var(--line); padding: 1.6rem 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.section-heading h2 { margin: 0; }
.reading-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: .85rem; }
.reading-card { background: var(--white); border: 1px solid var(--line); border-radius: 6px; padding: 1.2rem; }
.reading-card .symbol { font-size: 1.7rem; margin-right: .4rem; vertical-align: middle; }
.reading-card:last-child p:last-child { margin-bottom: 0; }
.reading-card ul { padding-inline-start: 1rem; }
.journal { margin-top: .6rem; max-width: 50rem; }
.journal details { padding: .85rem 0; border-block: 1px solid var(--line); }
summary { cursor: pointer; }
.journal summary { color: var(--leaf); font-weight: 610; }
.journal details > p { margin: .55rem 0; }
textarea { display: block; width: 100%; border: 1px solid var(--line); border-radius: 5px; background: var(--white); color: var(--ink); padding: .6rem; }
.saved-list { list-style: none; padding: 0; margin: 0; }
.saved-list li { display: flex; justify-content: space-between; align-items: center; gap: .45rem; border-top: 1px solid var(--line); }
.saved-list li > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.home-notes { margin-top: 2.9rem; max-width: 66ch; }
.muted { color: var(--muted); }
.article { padding-top: clamp(2.5rem, 7vw, 4.7rem); max-width: 74ch; margin-inline: auto; }
.article:has(.index) { max-width: 100%; }
.article h1 { font-size: clamp(2.45rem, 6vw, 4.8rem); }
.article h2 { margin-top: 1.8rem; }
.article p, .article li { max-width: 74ch; }
.article table { width: 100%; border-collapse: collapse; margin-block: 1rem 1.5rem; }
.article :is(td,th) { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; }
.article th { background: var(--ground); }
.lookup { margin-top: 1.6rem; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: 6px; background: var(--ground); }
.lookup h2 { margin-top: 0; }
.lookup-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: .55rem; margin-block: .6rem .9rem; }
.lookup-fields label { display: grid; gap: .25rem; font-size: .83rem; color: var(--muted); }
.lookup-fields select { width: 100%; border: 1px solid var(--muted); background: var(--white); color: var(--ink); border-radius: 4px; padding: .45rem .2rem; min-height: 42px; }
.lookup .reading-card { margin-top: .85rem; }
.index-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%, 240px),1fr)); gap: .55rem; align-items: start; }
.hex-entry { border: 1px solid var(--line); border-radius: 5px; background: var(--white); padding: .55rem .7rem; }
.hex-entry summary { color: var(--leaf); min-height: 36px; padding-top: .25rem; }
.hex-entry p { font-size: .9rem; margin: .3rem 0 .55rem; }
.hex-entry > p { padding: .2rem 0 .1rem; margin: 0; min-height: 36px; }
.hex-entry .symbol, .hex-number { margin-inline-end: .3rem; }
.hex-detail-figure { display: inline-grid; grid-template-columns: 7rem auto; gap: 1.1rem; align-items: center; background: var(--ground); border: 1px solid var(--line); padding: 1.05rem; border-radius: 6px; }
.hex-detail-figure div { display: grid; gap: .4rem; }
.hex-detail-figure figcaption { max-width: 23ch; color: var(--muted); font-size: .88rem; }
.article figure { margin: .2rem 0 1.1rem; }
.hex-detail-lines > li { margin-bottom: .55rem; }

@media (max-width: 720px) {
  .site-shell { width: calc(100% - 36px); }
  .header-inner, .footer-inner { gap: .55rem; min-height: 58px; }
  .site-header nav, .site-footer nav { gap: .3rem .68rem; }
  .site-header a, .site-footer a { font-size: .78rem; }
  .brand { font-size: 1rem !important; gap: .35rem; }
  .seal { width: 23px; height: 23px; }
  .cast-hero { grid-template-columns: 1fr; gap: .8rem; padding-block: 1.8rem 1.5rem; }
  .cast-intro h1 { max-width: none; font-size: clamp(2.35rem, 10vw, 4.7rem); margin-bottom: .6rem; }
  .intro { font-size: .92rem; margin-bottom: 1rem; }
  .coins { margin-block: .72rem .42rem; }
  .coins span { width: 27px; height: 27px; }
  .mode-hint { margin-block: .45rem; }
  .cast-lines > li { min-height: 32px; }
  .cast-board { padding: .9rem 1rem; }
  .footer-inner { flex-wrap: wrap; padding-block: .6rem; }
}
@media (max-width: 360px) {
  .site-shell { width: calc(100% - 24px); }
  .header-inner { flex-wrap: wrap; padding-block: .5rem; }
}
