/* Saju Pillars - hanji paper, brush ink, a vermilion seal, and the five traditional element colours (obangsaek). */
:root {
  --paper: #f5efe2; --paper2: #fbf7ee; --card: #fffdf7; --ink: #1f1b16; --ink2: #4a4239; --muted: #7b7064; --line: #e2d7c3; --line2: #cdbfa6;
  --seal: #b8321f; --seal-ink: #fff6ee; --focus: #b8321f;
  --wood: #2f7a55; --wood-bg: #e2f0e7; --fire: #c4372b; --fire-bg: #f8e1dc; --earth: #b8860b; --earth-bg: #f6ebcf;
  --metal: #6c7280; --metal-bg: #eceef1; --water: #23324f; --water-bg: #dfe4ee;
  --ok: #2f7a55; --warn: #a86a00; --err: #b8321f; --info: #3d5a80;
  --shadow: 0 1px 0 rgba(60, 40, 10, .05), 0 6px 18px rgba(60, 40, 10, .06);
  --serif: "Noto Serif KR", "Nanum Myeongjo", "AppleMyungjo", "Songti SC", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", Roboto, Helvetica, Arial, sans-serif;
}
[data-theme="dark"] {
  --paper: #16130f; --paper2: #1d1914; --card: #221d17; --ink: #efe6d4; --ink2: #d6cab4; --muted: #a39682; --line: #3a3229; --line2: #4c4236;
  --seal: #e0583f; --seal-ink: #1a0f0b; --focus: #f08a6e;
  --wood: #6cc394; --wood-bg: #1d3328; --fire: #f07a68; --fire-bg: #3d1f1a; --earth: #e2b648; --earth-bg: #3a2f14;
  --metal: #b9bfca; --metal-bg: #2c2f35; --water: #9cb4e3; --water-bg: #1b2438;
  --ok: #6cc394; --warn: #e2b648; --err: #f07a68; --info: #9cb4e3;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--sans); }
a { color: var(--seal); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hidden { display: none !important; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* header */
.bar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--paper2); position: sticky; top: 0; z-index: 20; }
.back { color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font-family: var(--serif); font-size: 17px; }
.brand strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seal { display: inline-grid; place-items: center; width: 34px; height: 34px; background: var(--seal); color: var(--seal-ink); font: 700 12px/1 var(--serif); border-radius: 4px; letter-spacing: 1px; writing-mode: vertical-rl; flex: none; }
.session { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.credits { font-size: 13px; color: var(--ink2); }
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); background: var(--card); color: var(--ink); border-radius: 999px; padding: 6px 14px; cursor: pointer; text-decoration: none; font-size: 14px; line-height: 1.2; }
.pill:hover { border-color: var(--ink2); }
.pill.solid { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pill.solid:hover { background: var(--seal); border-color: var(--seal); color: var(--seal-ink); }
.pill.big { padding: 11px 22px; font-size: 16px; }
.pill:disabled { opacity: .45; cursor: not-allowed; }
.pill.tiny { padding: 3px 10px; font-size: 12px; }

/* hero */
.hero { max-width: 1080px; margin: 0 auto; padding: 40px 20px 18px; }
.kicker { font-family: var(--serif); color: var(--seal); letter-spacing: .08em; margin: 0 0 8px; font-size: 14px; }
.hero h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(30px, 5.2vw, 52px); line-height: 1.12; margin: 0 0 14px; letter-spacing: -.01em; }
.hero h1 em { font-style: normal; color: var(--ink2); }
.sub { max-width: 720px; font-size: 16px; color: var(--ink2); margin: 0 0 18px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ex-label { color: var(--muted); font-size: 14px; }
.chip { border: 1px dashed var(--line2); background: transparent; border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.chip:hover, .chip.on { border-style: solid; border-color: var(--seal); color: var(--seal); }

/* blocks */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 40px; }
.block { padding: 26px 0 8px; border-top: 1px solid var(--line); }
.bhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; margin-bottom: 14px; }
.bhead h2 { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 0; display: flex; align-items: center; gap: 10px; }
.bhead p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; min-width: 240px; }
.num { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 1.5px solid var(--seal); color: var(--seal); border-radius: 50%; font-size: 15px; font-family: var(--serif); }
.paid { font: 600 11px/1 var(--sans); background: var(--seal); color: var(--seal-ink); padding: 4px 7px; border-radius: 4px; letter-spacing: .05em; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.panel h3 { font-family: var(--serif); font-weight: 600; margin: 0 0 10px; font-size: 18px; }
.panel h4, .result h4, .recon h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }

/* forms */
.people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink2); margin-bottom: 10px; min-width: 0; }
.field input, .field select, .field textarea { border: 1px solid var(--line2); background: var(--paper2); border-radius: 8px; padding: 8px 10px; font-size: 15px; width: 100%; min-width: 0; }
.field textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 0 0 10px; color: var(--ink2); }
.adv { border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 4px; }
.adv summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.addbox { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 8px; border-style: dashed; box-shadow: none; background: transparent; }
.addbox p { margin: 0; color: var(--muted); }
.checks { list-style: none; padding: 0; margin: 10px 0 0; }
.checks li, .facts li { padding: 6px 10px; border-left: 3px solid var(--line2); margin-bottom: 6px; font-size: 14px; background: var(--paper2); border-radius: 0 6px 6px 0; }
.checks li.error, .facts li.error, .recon li.error { border-color: var(--err); }
.checks li.warn, .facts li.warn, .recon li.warn { border-color: var(--warn); }
.facts li.info, .recon li.info { border-color: var(--info); }
.facts li.ok, .recon li.ok, .facts li.plus { border-color: var(--ok); }
.facts li.minus, .facts li.clash { border-color: var(--err); }
.facts li.combine, .facts li.trine, .facts li.trine-full { border-color: var(--ok); }
.facts, .claims, .warnlist { list-style: none; padding: 0; margin: 0; }
.facts li.none, .claims li.none, ul li.none { color: var(--muted); border-color: var(--line); background: transparent; font-style: italic; }

/* chart */
.chartgrid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; }
.whohead { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.whohead p { margin: 2px 0 0; }
.dmbadge { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 8px; background: var(--seal); color: var(--seal-ink); font: 600 26px/1 var(--serif); flex: none; }
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.col { display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: center; min-width: 0; }
.col-day .tile:first-of-type { box-shadow: 0 0 0 2px var(--seal); }
.colhead { display: flex; flex-direction: column; font-size: 13px; line-height: 1.2; }
.colhead .ko { color: var(--muted); font-size: 12px; font-family: var(--serif); }
.god { font-size: 11.5px; color: var(--ink2); min-height: 30px; display: flex; align-items: center; justify-content: center; line-height: 1.15; overflow-wrap: anywhere; }
.god.dm { color: var(--seal); font-weight: 600; }
.palace { font-size: 11px; color: var(--muted); line-height: 1.25; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 1px; border: 1px solid var(--line2); border-radius: 10px; padding: 8px 2px 7px; cursor: pointer; background: var(--paper2); min-width: 0; }
.tile .glyph { font: 600 clamp(30px, 4.6vw, 44px)/1.05 var(--serif); }
.tile .reading { font-size: 12px; color: var(--ink2); white-space: nowrap; }
.tile .sub { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tile.sel { outline: 2px solid var(--ink); outline-offset: 1px; }
.tile.lit { outline: 2px dashed var(--seal); outline-offset: 1px; }
.tile.ghost { cursor: default; border-style: dashed; background: transparent; color: var(--muted); }
.el-wood.tile { background: var(--wood-bg); border-color: var(--wood); } .el-wood.tile .glyph { color: var(--wood); }
.el-fire.tile { background: var(--fire-bg); border-color: var(--fire); } .el-fire.tile .glyph { color: var(--fire); }
.el-earth.tile { background: var(--earth-bg); border-color: var(--earth); } .el-earth.tile .glyph { color: var(--earth); }
.el-metal.tile { background: var(--metal-bg); border-color: var(--metal); } .el-metal.tile .glyph { color: var(--metal); }
.el-water.tile { background: var(--water-bg); border-color: var(--water); } .el-water.tile .glyph { color: var(--water); }
.detail { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--paper2); border: 1px solid var(--line); font-size: 14px; }
.detail p { margin: 0 0 4px; }
.detail .dhead { font-family: var(--serif); font-size: 17px; }

.wheel, .compare { width: 100%; height: auto; display: block; }
.wh-control { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 4; fill: none; opacity: .6; }
.wh-gen { stroke: var(--ink2); stroke-width: 1.6; fill: none; }
.wh-arrowhead { fill: var(--ink2); }
.wh-node { cursor: pointer; }
.wh-disc { stroke-width: 2; }
.wh-dm { fill: none; stroke: var(--seal); stroke-width: 2.5; stroke-dasharray: 3 3; }
.wh-glyph { font: 600 20px var(--serif); }
.wh-label { font-size: 12px; fill: var(--ink2); }
.wh-node.zero .wh-disc { stroke-dasharray: 3 3; fill: transparent !important; }
.wh-node.lit .wh-disc { stroke-width: 4; }
.el-wood .wh-disc, .cmp-bar.el-wood { fill: var(--wood-bg); stroke: var(--wood); } .el-wood .wh-glyph { fill: var(--wood); }
.el-fire .wh-disc, .cmp-bar.el-fire { fill: var(--fire-bg); stroke: var(--fire); } .el-fire .wh-glyph { fill: var(--fire); }
.el-earth .wh-disc, .cmp-bar.el-earth { fill: var(--earth-bg); stroke: var(--earth); } .el-earth .wh-glyph { fill: var(--earth); }
.el-metal .wh-disc, .cmp-bar.el-metal { fill: var(--metal-bg); stroke: var(--metal); } .el-metal .wh-glyph { fill: var(--metal); }
.el-water .wh-disc, .cmp-bar.el-water { fill: var(--water-bg); stroke: var(--water); } .el-water .wh-glyph { fill: var(--water); }
.cmp-bar { stroke-width: 1.5; } .cmp-bar.zero { opacity: .4; }
.cmp-el { font: 600 16px var(--serif); fill: var(--ink); } .cmp-n { font-size: 12px; fill: var(--ink2); } .cmp-who { font: 600 13px var(--sans); fill: var(--ink); } .cmp-empty { fill: var(--muted); font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; color: var(--muted); margin: 6px 0; }
.lg { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--ink2); margin-right: 4px; vertical-align: middle; }
.lg.ctl { border-top: 2px dashed var(--muted); } .lg.dm { width: 12px; height: 12px; border: 2px dashed var(--seal); border-radius: 50%; }
.factgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.yearpanel h4 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.yearpanel select { font-size: 13px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line2); background: var(--paper2); text-transform: none; letter-spacing: 0; }
.yearline { font-family: var(--serif); font-size: 17px; margin: 0 0 8px; }
.comparebox { margin-top: 16px; }
.cmpgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.boardmini .board { gap: 4px; } .boardmini .tile .glyph { font-size: 24px; } .boardmini .palace, .boardmini .tile .sub { display: none; } .boardmini { margin-bottom: 12px; }

/* ask */
.lanes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.lane { text-align: left; border: 1px solid var(--line2); background: var(--card); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.lane b { font-family: var(--serif); font-size: 17px; }
.lane span { font-size: 13px; color: var(--muted); }
.lane.on { border-color: var(--seal); box-shadow: inset 4px 0 0 var(--seal); }
.focusrow { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.fchip { border: 1px solid var(--line2); background: var(--paper2); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 14px; }
.fchip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.askform { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.meter { font-size: 14px; color: var(--ink2); margin: 4px 0 8px; }
.note { font-size: 14px; color: var(--ink2); background: var(--paper2); border-left: 3px solid var(--info); padding: 6px 10px; border-radius: 0 6px 6px 0; margin: 6px 0; }
.gate { font-size: 14px; background: var(--fire-bg); color: var(--ink); padding: 8px 12px; border-radius: 8px; margin: 6px 0; }
.runrow { margin-top: 10px; }
.progress { margin-top: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.ptitle { font-family: var(--serif); margin: 0 0 8px; font-size: 17px; }
.steps { list-style: none; padding: 0; margin: 0 0 6px; }
.step { font-size: 14px; color: var(--muted); padding: 2px 0; }
.step.done { color: var(--ok); } .step.active { color: var(--ink); font-weight: 600; }
.step-ic { display: inline-block; width: 14px; font-family: ui-monospace, Menlo, monospace; }
.raw { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--paper2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12px; max-height: 320px; overflow: auto; }

/* results */
.result { margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); }
.rhead { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 14px; }
.rhead h3 { font-family: var(--serif); font-weight: 600; font-size: 21px; margin: 0 0 6px; }
.rhead p { margin: 0 0 4px; }
.stamp { flex: none; display: grid; place-items: center; min-width: 82px; height: 82px; padding: 4px; border: 3px solid var(--seal); color: var(--seal); border-radius: 6px; font: 700 15px/1.1 var(--serif); text-transform: uppercase; letter-spacing: .06em; transform: rotate(-4deg); text-align: center; }
.stamp.v-bright, .stamp.v-natural { border-color: var(--ok); color: var(--ok); }
.stamp.v-mixed, .stamp.v-workable { border-color: var(--warn); color: var(--warn); }
.stamp.v-careful, .stamp.v-stretch { border-color: var(--seal); color: var(--seal); }
.rgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 22px; }
.rgrid section { min-width: 0; }
.span2 { grid-column: 1 / -1; }
.claims li { padding: 6px 0 8px; border-bottom: 1px dashed var(--line); font-size: 15px; }
.claims li:last-child { border-bottom: 0; }
.claimp { margin: 0; font-size: 15px; }
.cites { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 6px; vertical-align: middle; }
.cite { font: 600 11px/1 ui-monospace, Menlo, monospace; border: 1px solid var(--line2); border-radius: 4px; padding: 3px 5px; background: var(--paper2); color: var(--ink2); cursor: pointer; }
.cite.bad { border-color: var(--err); color: var(--err); text-decoration: line-through; cursor: help; }
.result ul:not(.claims) { padding-left: 18px; margin: 0; } .result ul:not(.claims) li { margin-bottom: 4px; }
.warnlist li { color: var(--ink2); font-size: 14px; }
.recon { margin-top: 14px; padding: 14px 16px; background: var(--paper2); border: 1px solid var(--line); border-radius: 12px; }
.recon ul { list-style: none; padding: 0; margin: 0 0 6px; }
.recon li { padding: 5px 10px; border-left: 3px solid var(--line2); margin-bottom: 5px; font-size: 14px; background: var(--card); border-radius: 0 6px 6px 0; }
.exports { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* history */
.history { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.hrow { display: flex; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.hglyph { font: 600 22px/1 var(--serif); color: var(--seal); flex: none; width: 34px; text-align: center; }
.hinfo { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.hinfo span { overflow: hidden; text-overflow: ellipsis; }
.history li.none { color: var(--muted); font-style: italic; }

/* toasts, footer, print */
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow); transition: opacity .5s; }
.toast.err { background: var(--seal); color: var(--seal-ink); } .toast a { color: inherit; font-weight: 600; }
.toast.gone { opacity: 0; }
.foot { max-width: 1080px; margin: 0 auto; padding: 22px 20px 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.printsheet { display: none; }

/* docs pages */
.doc { max-width: 880px; margin: 0 auto; padding: 28px 20px 40px; }
.doc h1 { font-family: var(--serif); font-weight: 600; font-size: 32px; line-height: 1.2; }
.doc h2 { font-family: var(--serif); font-weight: 600; margin-top: 34px; }
.doc pre { background: var(--paper2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 12.5px; }
.doc code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; }
.doc table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-size: 14px; margin: 10px 0; }
.doc th, .doc td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.codegroup { margin: 12px 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tab { border: 1px solid var(--line2); background: var(--card); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.tab.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.statebox { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 14px 0; }
.tokenrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.tokenbox { font-family: ui-monospace, Menlo, monospace; background: var(--paper2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-wrap: anywhere; width: 100%; }
.mono { font-family: ui-monospace, Menlo, monospace; overflow-wrap: anywhere; }

@media (max-width: 860px) {
  .chartgrid, .cmpgrid { grid-template-columns: 1fr; }
  .factgrid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .bar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .back { display: none; }
  .hero { padding: 26px 16px 12px; }
  .wrap { padding: 0 16px 32px; }
  .people, .rgrid, .lanes { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr 1fr; gap: 8px; }
  .panel { padding: 12px; }
  .board { gap: 5px; }
  .tile { padding: 6px 1px 5px; border-radius: 8px; }
  .tile .reading { font-size: 10.5px; }
  .tile .sub { font-size: 9.5px; }
  .god { font-size: 10px; min-height: 26px; }
  .palace { display: none; }
  .rhead { flex-direction: column; gap: 10px; }
  .stamp { min-width: 70px; height: 56px; }
}
@media print {
  body { background: #fff; color: #000; }
  body > *:not(.printsheet) { display: none !important; }
  .printsheet { display: block; font-family: var(--serif); padding: 10mm; }
  .printsheet table { border-collapse: collapse; margin: 8px 0; }
  .printsheet td, .printsheet th { border: 1px solid #999; padding: 6px 10px; text-align: center; }
  .printsheet .pg { font-size: 30px; }
}
