/* Mirror of Changes — still water. Manrope for the interface, Literata for the text, jade as the only accent. */
@font-face { font-family: Manrope; font-style: normal; font-weight: 200 800; font-display: swap; src: url(../fonts/manrope-latin-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Manrope; font-style: normal; font-weight: 200 800; font-display: swap; src: url(../fonts/manrope-latin-ext-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Manrope; font-style: normal; font-weight: 200 800; font-display: swap; src: url(../fonts/manrope-cyrillic-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Manrope; font-style: normal; font-weight: 200 800; font-display: swap; src: url(../fonts/manrope-cyrillic-ext-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: Literata; font-style: normal; font-weight: 200 900; font-display: swap; src: url(../fonts/literata-latin-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Literata; font-style: normal; font-weight: 200 900; font-display: swap; src: url(../fonts/literata-latin-ext-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Literata; font-style: normal; font-weight: 200 900; font-display: swap; src: url(../fonts/literata-cyrillic-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Literata; font-style: normal; font-weight: 200 900; font-display: swap; src: url(../fonts/literata-cyrillic-ext-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: Literata; font-style: italic; font-weight: 200 900; font-display: swap; src: url(../fonts/literata-latin-wght-italic.woff2) format('woff2-variations'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Literata; font-style: italic; font-weight: 200 900; font-display: swap; src: url(../fonts/literata-latin-ext-wght-italic.woff2) format('woff2-variations'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Literata; font-style: italic; font-weight: 200 900; font-display: swap; src: url(../fonts/literata-cyrillic-wght-italic.woff2) format('woff2-variations'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Literata; font-style: italic; font-weight: 200 900; font-display: swap; src: url(../fonts/literata-cyrillic-ext-wght-italic.woff2) format('woff2-variations'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'Mirror Han'; font-display: swap; src: url(../fonts/noto-serif-tc-names.woff2) format('woff2'); }

:root {
  --bg: #F4F6FA;
  --bg2: #E6ECF5;
  --surface: #FFFFFF;
  --ink: #172033;
  --muted: #5D6880;
  --line: #DCE2EC;
  --accent: #0E6E60;   /* ≥4.5:1 on white, accent-soft and bg2 */
  --accent-ink: #FFFFFF;
  --accent-soft: #E0F2EE;
  --coin-hi: #E7CF9C; --coin: #B8925A; --coin-lo: #8C6A35;
  --shadow: 0 1px 2px rgba(23, 32, 51, .05), 0 8px 24px -12px rgba(23, 32, 51, .18);
  --focus: #2B6CB0;
  --sans: Manrope, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: Literata, Georgia, serif;
  --han: 'Mirror Han', 'Noto Serif TC', 'Noto Serif CJK TC', 'Songti TC', serif;
  --radius: 20px;
  --tabbar: 4.25rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1220; --bg2: #141B2D; --surface: #182136; --ink: #EAF0FA; --muted: #9AA6BE; --line: #263149;
    --accent: #4CC9B0; --accent-ink: #06221C; --accent-soft: #12302C; --focus: #8CC4F0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1220; --bg2: #141B2D; --surface: #182136; --ink: #EAF0FA; --muted: #9AA6BE; --line: #263149;
  --accent: #4CC9B0; --accent-ink: #06221C; --accent-soft: #12302C; --focus: #8CC4F0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; color: var(--ink); font: 400 1rem/1.55 var(--sans);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%) fixed; min-height: 100vh; min-height: 100dvh;
}
main {
  max-width: 34rem; margin: 0 auto; outline: none;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) calc(var(--tabbar) + 2rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
main.flow { padding-bottom: max(2rem, env(safe-area-inset-bottom)); }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; margin: 2rem 0 .15rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-underline-offset: .2em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 8px; }
.han { font-family: var(--han); font-weight: 400; }
.muted, .small { color: var(--muted); }
.small { font-size: .9rem; }
.hint { color: var(--muted); font-size: .9rem; margin: 0 0 .6rem; }
.text { font-family: var(--serif); font-size: 1.1rem; line-height: 1.7; white-space: pre-line; overflow-wrap: break-word; hyphens: auto; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.preview-banner { position: sticky; top: 0; z-index: 30; background: #B4471F; color: #fff; text-align: center; font-size: .85rem; font-weight: 600; padding: .35rem 1rem; }

/* buttons */
button, .btn { font: inherit; color: inherit; cursor: pointer; }
.primary {
  display: block; width: 100%; margin: 1.75rem 0 0; padding: .95rem 1rem; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1.05rem; text-align: center; text-decoration: none;
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 70%, transparent);
}
.primary:disabled { opacity: .4; cursor: default; box-shadow: none; }
.quiet { background: none; border: 0; padding: .6rem 0; color: var(--accent); font-weight: 600; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* top bar inside the flow, and the bottom tab bar on main screens */
.topbar { display: flex; align-items: center; gap: .5rem; min-height: 2.75rem; margin-bottom: .75rem; }
.topbar .title { font-weight: 700; font-size: 1rem; }
.icon-btn { display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); }
.icon-btn svg, .tabbar svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: max(.75rem, env(safe-area-inset-bottom)); z-index: 20;
  width: min(30rem, calc(100% - 1.5rem)); height: var(--tabbar); display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: 22px; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600; border-radius: 18px; }
.tabbar a[aria-current="page"] { color: var(--accent); }

/* home: still water */
.home { min-height: calc(100dvh - var(--tabbar) - 4rem); display: flex; flex-direction: column; }
.home header { display: flex; justify-content: space-between; align-items: center; }
.wordmark { font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.wordmark span { display: block; color: var(--muted); font-weight: 500; font-size: .85rem; }
.pond-wrap { flex: 1; display: grid; place-items: center; padding: 2rem 0 1rem; }
.pond {
  --size: min(76vw, 19rem);
  position: relative; width: var(--size); height: var(--size); border-radius: 50%; border: 0; padding: 0;
  background: radial-gradient(circle at 50% 45%, var(--surface) 0%, var(--surface) 45%, color-mix(in srgb, var(--accent-soft) 70%, var(--surface)) 100%);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--line);
  display: grid; place-items: center;
}
.pond::before, .pond::after { content: ''; position: absolute; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.pond::before { inset: 14%; }
.pond::after { inset: 30%; border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.pond .ripple { position: absolute; inset: 30%; border-radius: 50%; border: 1.5px solid var(--accent); opacity: 0; animation: ripple 6s ease-out infinite; }
@keyframes ripple { 0% { transform: scale(.6); opacity: .6; } 100% { transform: scale(2.1); opacity: 0; } }
.pond .label { position: relative; font-size: 1.6rem; font-weight: 700; color: var(--ink); }
.pond:active { transform: scale(.985); }
.home .hint { text-align: center; max-width: 18rem; margin: 1.25rem auto 0; }
.first-time { display: flex; align-items: center; gap: .9rem; text-decoration: none; color: var(--ink); margin-top: 1.25rem; }
.first-time .dot { width: 2.25rem; height: 2.25rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; flex: none; }
.first-time b { display: block; }

/* settle */
.settle { text-align: center; padding-top: 14vh; }
.breath { width: 8rem; height: 8rem; margin: 0 auto 2.5rem; border-radius: 50%; background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); animation: breathe 6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(.72); } 50% { transform: scale(1); } }
.settle p { font-family: var(--serif); font-size: 1.25rem; }
.check { display: flex; gap: .6rem; align-items: center; justify-content: center; color: var(--muted); font-size: .95rem; margin-top: 1.25rem; }
.check input, .choice input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); flex: none; }

/* forms */
textarea {
  width: 100%; min-height: 7.5rem; margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink); font: 1.05rem/1.55 var(--serif); resize: vertical; box-shadow: var(--shadow);
}
textarea::placeholder { color: var(--muted); opacity: 1; }

/* the hexagram */
.hex { display: block; width: 8.5rem; height: auto; margin: 0 auto; }
.hex.small { width: 3.4rem; margin: 0; }
.hex.tiny { width: 2.2rem; margin: 0; }
.hex .bar { fill: var(--ink); }
.hex .bar.changing { fill: var(--accent); }
.hex .empty { fill: var(--line); }
.hex .mark { fill: var(--accent); stroke: none; }
.hex .new { animation: ink .45s ease-out; }
@keyframes ink { from { opacity: 0; } to { opacity: 1; } }

/* cast */
.cast { text-align: center; }
.cast h1 { margin-bottom: 1.5rem; }
.cast .stage { padding: 1.75rem 1rem 1.25rem; }
.coins { display: flex; justify-content: center; gap: 1.1rem; margin: 1.75rem 0 1.4rem; }
.coin {
  width: 4.1rem; height: 4.1rem; border-radius: 50%; position: relative; border: 0; padding: 0; display: block;
  background: radial-gradient(circle at 35% 30%, var(--coin-hi), var(--coin) 60%, var(--coin-lo));
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .1), 0 6px 14px -8px rgba(0, 0, 0, .5);
}
.coin::after { content: ''; position: absolute; left: 50%; top: 50%; width: 1.05rem; height: 1.05rem; transform: translate(-50%, -50%); background: var(--surface); border-radius: 3px; }
.coin.tails { background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--coin-hi) 40%, var(--surface)), color-mix(in srgb, var(--coin) 40%, var(--surface)) 70%); }
.coin .face { position: absolute; inset: auto -1rem -1.55rem -1rem; font-size: .78rem; color: var(--muted); font-weight: 600; }
.coin.flip { animation: flip .5s ease-in-out; }
@keyframes flip { 0% { transform: rotateY(0) translateY(0); } 50% { transform: rotateY(540deg) translateY(-1.1rem); } 100% { transform: rotateY(1080deg) translateY(0); } }
.dots { display: flex; justify-content: center; gap: .45rem; margin-top: 1.4rem; }
.dots span { width: .5rem; height: .5rem; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--accent); }
.progress { color: var(--muted); font-size: .9rem; font-weight: 600; margin: .6rem 0 0; min-height: 1.4em; }
.manual-hint { color: var(--muted); font-size: .95rem; margin: 1rem 0 0; }
.cast .alt { margin-top: .5rem; justify-content: center; }

/* reveal + reading */
.hero { text-align: center; padding: 1.75rem 1.25rem 1.5rem; }
.hero .num { color: var(--muted); font-weight: 600; font-size: .9rem; margin-top: 1rem; }
.hero .zh { font-family: var(--han); font-size: 2.6rem; line-height: 1.2; margin: .3rem 0 0; }
.hero .py { color: var(--muted); font-style: italic; font-family: var(--serif); }
.hero .name { font-size: 1.35rem; font-weight: 700; margin-top: .25rem; }
.turn { text-align: center; color: var(--accent); font-weight: 700; margin: 1.25rem 0; }
.reveal .relating { opacity: 0; animation: ink 1s .9s ease-out forwards; }
.summary { background: var(--accent-soft); border-radius: 16px; padding: 1rem 1.15rem; font-family: var(--serif); font-size: 1.15rem; line-height: 1.6; margin: 1.25rem 0 .5rem; }
.summary-label { display: block; font-family: var(--sans); font-size: .8rem; font-weight: 700; color: var(--accent); margin-bottom: .2rem; }
.head { display: flex; gap: 1rem; align-items: center; }
.head .zh { font-family: var(--han); font-size: 1.5rem; }
.head .name { font-size: 1.15rem; font-weight: 700; }
.head .num { color: var(--muted); font-size: .85rem; font-weight: 600; }
.reading-head { padding: 1rem 1.15rem; }
.line-text { background: var(--surface); box-shadow: var(--shadow); border-radius: 16px; padding: .9rem 1.1rem; margin: 0 0 .75rem; border-left: 3px solid var(--accent); }
.line-text .label { display: flex; gap: .5rem; align-items: center; font-family: var(--sans); font-weight: 700; font-size: .85rem; margin-bottom: .25rem; }
.chip { display: inline-block; padding: .05rem .5rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .72rem; font-weight: 700; }
.line-text.still { border-left-color: var(--line); }
.note { color: var(--muted); font-size: .9rem; text-align: center; margin-top: 1.75rem; }
.meta { color: var(--muted); font-size: .92rem; margin: 0 0 .4rem; }
.reaction { font-family: var(--serif); font-style: italic; color: var(--ink); }

/* lists */
.list { list-style: none; margin: 1.25rem 0 0; padding: .25rem 1rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: flex; gap: 1rem; align-items: center; padding: .9rem 0; text-decoration: none; color: var(--ink); }
.list .what { flex: 1; min-width: 0; }
.list .q { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.list .when { display: block; color: var(--muted); font-size: .85rem; }
.empty-state { color: var(--muted); margin-top: 3rem; text-align: center; }
.grid { list-style: none; padding: 0; margin: 1.25rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(4.6rem, 1fr)); gap: .6rem; }
.grid a { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-decoration: none; color: var(--ink); padding: .75rem 0 .6rem; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.grid .n { font-size: .78rem; color: var(--muted); font-weight: 700; }
.grid .zh { font-family: var(--han); font-size: 1.05rem; }
.pager { margin-top: 1.5rem; font-weight: 600; }

/* guide */
.steps { list-style: none; counter-reset: step; padding: 0; margin: 1rem 0 0; }
.steps li { counter-increment: step; display: flex; gap: .9rem; margin-bottom: .9rem; }
.steps li::before { content: counter(step); flex: none; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: grid; place-items: center; font-size: .9rem; }
.parts { display: grid; gap: .75rem; margin-top: 1rem; }
.parts .panel h3 { font-size: 1rem; margin-bottom: .25rem; }
.parts .panel p { margin: 0; color: var(--muted); }
.phrases { margin: 1rem 0 0; padding: .25rem 1.1rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.phrases div { padding: .75rem 0; }
.phrases div + div { border-top: 1px solid var(--line); }
.phrases dt { font-weight: 700; }
.phrases dd { margin: .1rem 0 0; color: var(--muted); }

/* settings */
.group { margin-top: 1.25rem; padding: .5rem 1.1rem; }
.group legend, .group .legend { font-weight: 700; font-size: .85rem; color: var(--muted); padding: .6rem 0 .2rem; }
fieldset.group { border: 0; }
fieldset.group legend { float: left; width: 100%; }
fieldset.group legend + * { clear: both; }
.choice { display: flex; gap: .75rem; align-items: center; padding: .6rem 0; }
.choice + .choice { border-top: 1px solid var(--line); }
.file { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 1.5rem + env(safe-area-inset-bottom)); transform: translate(-50%, 1rem); opacity: 0; z-index: 40;
  background: var(--ink); color: var(--bg); padding: .7rem 1.15rem; border-radius: 14px; font-size: .95rem; font-weight: 600; pointer-events: none;
  transition: opacity .25s, transform .25s; max-width: calc(100vw - 2rem); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 2rem 1rem; }

/* public library pages: no tab bar there, so no room reserved for it */
main.page { padding-bottom: max(2.5rem, env(safe-area-inset-bottom)); }
.page-back { display: inline-block; margin-bottom: 1rem; font-weight: 600; text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .reveal .relating { opacity: 1; }
  .pond .ripple { display: none; }
}
