/* App chrome. One fixed look — the reference app's cream-parchment light screen (cream page, golden top bar,
   dark-grey tab bar, grey-beige rows, black text). The chart (wheel / grid) uses THEMES.light in js/ui/wheel.js. */
:root {
  --bg: #ffffe7; --panel: #e6e6d0; --panel2: #d9d9c1; --row: #e6e6d0; --sheet: #ffffe7; --field: #fffff7;
  --line: #b4b49c; --card-line: #cdcdb4; --ink: #000000; --dim: #4d4d42;
  --gold: #7a5200; --accent-fill: #fdd05e; --accent-ink: #000000; --gold-soft: rgba(253, 208, 94, 0.6); --heading: #000000;
  --danger: #c81e1e; --ok: #17753a; --warn-ink: #5c3f00; --warn-bg: #fff0b0; --warn-line: #d8a400;
  --fire: #e60000; --earth: #7a7a00; --air: #009a9a; --water: #0000e6;
  --asp-hard: #e60000; --asp-soft: #0000e6; --asp-adjust: #008000; --asp-creative: #008b8b; --asp-mystic: #a800a8; --asp-minor: #707070;
  --bar-bg: #fdd05e; --bar-ink: #000000; --bar-line: #dcb040;
  --bar-btn-bg: rgba(255, 255, 255, 0.38); --bar-btn-line: rgba(0, 0, 0, 0.32); --bar-btn-on-bg: #515151; --bar-btn-on-ink: #fdd05e; --bar-btn-on-line: #515151;
  --tabs-bg: #515151; --tabs-ink: #c6c6c6; --tabs-on: #fdd05e; --tabs-line: #515151;
  --thead-bg: #e6e6d0; --thead-ink: #000000; --rule: #000000;
  --backdrop: rgba(0, 0, 0, 0.45); --toast-bg: #515151; --toast-ink: #ffffff; --shadow: none; --glyph-bold: 46;
  --radius: 12px; --top: 54px; --tabs: 60px;
  color-scheme: light;
  font-family: 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.dim { color: var(--dim); } .small { font-size: 12.5px; } .pad { padding: 10px 4px; }
[hidden] { display: none !important; }

/* ---- splash ------------------------------------------------------------------------------------------- */
#splash { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; background: var(--bg); color: var(--dim); text-align: center; padding: 24px; }
#splash.error { color: var(--danger); }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
#splash.error .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- shell -------------------------------------------------------------------------------------------- */
#app { height: 100dvh; display: grid; grid-template-rows: auto 1fr var(--tabs); grid-template-areas: 'top' 'content' 'tabs'; }
#topbar { grid-area: top; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 7px 12px; min-height: var(--top); background: var(--bar-bg); color: var(--bar-ink); border-bottom: 1px solid var(--bar-line); min-width: 0; }
#topbar .btn { background: var(--bar-btn-bg); border-color: var(--bar-btn-line); color: var(--bar-ink); }
#topbar .btn.active { background: var(--bar-btn-on-bg); border-color: var(--bar-btn-on-line); color: var(--bar-btn-on-ink); }
#topbar .icon-btn.back { color: var(--bar-ink); }
#topbar h1 { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
#topbar .actions { margin-left: auto; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; justify-content: flex-end; max-width: 100%; }
#topbar .actions:empty { display: none; }
/* Narrow screens: the action buttons get their own row under the title instead of squeezing it. */
@media (max-width: 640px) { #topbar .actions { flex: 1 1 100%; margin-left: 0; justify-content: flex-start; } }
#topbar .actions::-webkit-scrollbar { display: none; }
#content { grid-area: content; overflow: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
#tabbar { grid-area: tabs; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--tabs-bg); border-top: 1px solid var(--tabs-line); padding-bottom: env(safe-area-inset-bottom); }
.tab { background: none; border: 0; color: var(--tabs-ink); display: grid; justify-items: center; align-content: center; gap: 2px; font-size: 11.5px; cursor: pointer; }
.tab .ti { display: grid; }
.tab.on { color: var(--tabs-on); }
.tab:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, .list-row:focus-visible, .chart-card:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
@media (min-width: 960px) {
  #app { grid-template-rows: auto 1fr; grid-template-columns: 92px 1fr; grid-template-areas: 'tabs top' 'tabs content'; }
  #tabbar { grid-template-columns: 1fr; grid-auto-rows: 78px; align-content: start; border-top: 0; border-right: 1px solid var(--tabs-line); padding-top: 8px; }
  .tab { font-size: 12.5px; }
}
.page { max-width: 900px; margin: 0 auto; padding: 14px 14px 28px; }
.page.view { max-width: none; padding: 10px; }

/* ---- controls ----------------------------------------------------------------------------------------- */
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--dim); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.small { padding: 6px 10px; font-size: 13.5px; border-radius: 8px; }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-ink); font-weight: 700; }
.btn.active { border-color: var(--gold); color: var(--gold); }
.icon-btn { background: none; border: 0; cursor: pointer; font-size: 18px; padding: 6px 9px; border-radius: 8px; color: var(--dim); }
.icon-btn:hover { background: var(--panel2); color: var(--ink); }
.icon-btn.back { font-size: 26px; line-height: 1; color: var(--ink); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
input[type=text], input[type=search], input[type=number], select, textarea {
  background: var(--field); border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
select { appearance: auto; }
textarea { resize: vertical; }
.badge { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 99px; background: var(--gold-soft); color: var(--gold); font-size: 12px; }
.banner { border-radius: 10px; padding: 9px 12px; margin: 0 auto 10px; max-width: 900px; font-size: 13.5px; }
.banner.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); }
.banner.error { background: rgba(255, 107, 107, 0.12); border: 1px solid rgba(255, 107, 107, 0.45); color: var(--danger); }
.banner.info { background: var(--panel); border: 1px solid var(--line); color: var(--dim); }
.hint { color: var(--dim); font-size: 13px; margin: 0 0 10px; }
h2.section { font-size: 15px; color: var(--heading); margin: 22px 0 8px; letter-spacing: 0.01em; }
.page h3 { font-size: 13.5px; color: var(--dim); font-weight: 600; margin: 16px 0 6px; }
.empty-state { display: grid; gap: 14px; justify-items: center; padding-top: 18vh; color: var(--dim); text-align: center; }

/* ---- charts tab --------------------------------------------------------------------------------------- */
.chart-card { position: relative; display: block; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow); }
.chart-card:hover { border-color: var(--dim); }
.chart-card.empty { border-style: dashed; }
.chart-card.dragging { opacity: 0.55; border-style: dashed; }
.chart-card.drop-target { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }
.cc-grip { position: absolute; top: 8px; right: 10px; padding: 2px 6px; color: var(--dim); font-size: 16px; line-height: 1; cursor: grab; touch-action: none; border-radius: 6px; }
.cc-grip:hover { color: var(--ink); background: var(--card-line); }
.chart-card.dragging .cc-grip { cursor: grabbing; }
.cc-head { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.chart-card:not(.empty) .cc-head { padding-right: 26px; }
.cc-slot { color: var(--gold); font-weight: 700; }
.cc-name { font-size: 18px; font-weight: 700; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cc-type { font-size: 12px; font-weight: 500; color: var(--dim); }
.cc-line { font-size: 13.5px; color: var(--ink); opacity: 0.92; font-variant-numeric: tabular-nums; }
.cc-status { font-size: 12px; color: var(--dim); margin-top: 4px; }
.cc-status.ok { color: var(--ok); }
.cc-none { font-size: 16px; color: var(--dim); }
.cc-tap { font-size: 13px; color: var(--dim); }
.swap-row { display: flex; justify-content: space-between; gap: 8px; margin: 8px 0; }
.list-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: 'title chev' 'sub chev'; align-items: center; column-gap: 10px; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 11px 14px; margin-bottom: 8px; cursor: pointer; }
.list-row:hover { border-color: var(--dim); }
.list-row.static { cursor: default; grid-template-columns: 1fr minmax(120px, 200px); grid-template-areas: 'title sel'; }
.lr-title { grid-area: title; font-weight: 600; }
.lr-sub { grid-area: sub; font-size: 12.5px; color: var(--dim); }
.chev { grid-area: chev; color: var(--dim); font-size: 20px; }

/* ---- sheets ------------------------------------------------------------------------------------------- */
.sheet-backdrop { position: fixed; inset: 0; background: var(--backdrop); display: grid; place-items: end center; z-index: 50; }
.sheet { background: var(--sheet); border: 1px solid var(--line); overflow: hidden; border-radius: 16px 16px 0 0; width: min(100%, 520px); max-height: 92dvh; display: flex; flex-direction: column; }
.sheet.wide { width: min(100%, 700px); }
@media (min-width: 700px) { .sheet-backdrop { place-items: center; } .sheet { border-radius: 16px; max-height: 88dvh; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 10px 16px; background: var(--bar-bg); color: var(--bar-ink); border-bottom: 1px solid var(--bar-line); }
.sheet-head .icon-btn { color: var(--bar-ink); }
.sheet-head h2 { font-size: 16px; }
.sheet-body { overflow: auto; padding: 12px 16px 18px; }
.menu { display: grid; gap: 6px; }
.menu-heading { font-size: 12px; color: var(--gold); margin: 8px 2px 0; min-height: 4px; }
.menu-item { display: flex; justify-content: space-between; gap: 12px; align-items: center; text-align: left; background: var(--row); border: 1px solid var(--card-line); border-radius: 10px; padding: 11px 13px; cursor: pointer; }
.menu-item:hover:not(:disabled) { border-color: var(--dim); }
.menu-item:disabled { opacity: 0.45; cursor: default; }
.menu-item.danger { color: var(--danger); }
.menu-item .hint { margin: 0; font-size: 12px; }
#toast { position: fixed; left: 50%; bottom: calc(var(--tabs) + 16px); transform: translate(-50%, 20px); background: var(--toast-bg); border: 1px solid var(--line); color: var(--toast-ink); padding: 9px 16px; border-radius: 99px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 80; max-width: 90vw; text-align: center; font-size: 13.5px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- forms -------------------------------------------------------------------------------------------- */
.chart-form, .settings.detail { display: grid; gap: 12px; }
.row { display: grid; gap: 5px; grid-template-columns: minmax(0, 1fr); }
.row > select { min-width: 0; max-width: 100%; }
.row > label, fieldset legend, .row .lab { font-size: 12.5px; color: var(--dim); }
.row.two { grid-template-columns: 1fr 1fr; gap: 10px; }
.row.two > div { display: grid; gap: 5px; }
.inline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inline span { color: var(--dim); font-size: 13px; margin-right: 4px; }
input.n4 { width: 92px; } input.n2 { width: 68px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 12px; margin: 0; display: grid; gap: 9px; min-width: 0; }
fieldset legend { padding: 0 6px; }
details summary { cursor: pointer; color: var(--dim); font-size: 13px; padding: 4px 0; }
details[open] { display: grid; gap: 10px; }
.place-now { font-size: 14.5px; }
.city-results { display: grid; gap: 4px; max-height: 240px; overflow: auto; }
.city-results:empty { display: none; }
.city { display: flex; justify-content: space-between; gap: 12px; text-align: left; background: var(--row); border: 1px solid var(--card-line); border-radius: 9px; padding: 8px 11px; cursor: pointer; }
.city:hover { border-color: var(--gold); }
.city small { color: var(--dim); }
.city .cs { color: var(--dim); font-size: 12.5px; text-align: right; }
.city-results.browsing { max-height: none; overflow: visible; gap: 6px; }
.place-head { display: flex; align-items: center; gap: 10px; }
.place-row { display: flex; gap: 6px; align-items: stretch; }
.place-row .city { flex: 1; }
.place-index { display: flex; flex-wrap: wrap; gap: 3px; }
.place-index button { min-width: 26px; padding: 3px 5px; border-radius: 6px; border: 1px solid var(--card-line); background: var(--row); color: inherit; cursor: pointer; font-size: 12.5px; }
.place-index button:hover { border-color: var(--gold); }
.place-list { position: relative; display: grid; gap: 4px; max-height: 300px; overflow: auto; }
.tz-readout { font-variant-numeric: tabular-nums; }
.tz-readout .warn, .warn { color: var(--warn-ink); font-size: 13px; margin-top: 4px; }
.form-error { color: var(--danger); min-height: 1.3em; font-size: 13.5px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 5px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent-fill); flex: none; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 2px 14px; }
.sym { display: inline-grid; width: 24px; justify-items: center; }
.gl { vertical-align: -0.2em; overflow: visible; }
/* Heavier symbols on the light theme (outline in the glyph's own colour), as in the wheel. */
.gl path { stroke: currentColor; stroke-width: var(--glyph-bold); stroke-linejoin: round; }
.ptlabel { font-weight: 700; letter-spacing: -0.02em; }
.asp-list { display: grid; gap: 4px; }
.asp-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding: 3px 0; }
.orbs { display: grid; grid-template-columns: repeat(4, minmax(40px, 54px)); gap: 5px; }
.asp-row > .check { word-break: keep-all; }
.orbs input { padding: 6px 6px; text-align: right; }
.asp-row .asp-color { grid-column: 1 / -1; justify-self: end; width: auto; padding: 4px 8px; font-size: 12.5px; }
.card { background: var(--panel); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 11px 14px; }
.credits { padding-left: 18px; margin: 4px 0; color: var(--dim); font-size: 13.5px; }
.file-browser { display: grid; gap: 10px; }
.fb-bar { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.file-list { display: grid; gap: 5px; max-height: 60dvh; overflow: auto; }
.file-row { display: grid; grid-template-columns: 1fr auto; align-items: center; background: var(--row); border: 1px solid var(--card-line); border-radius: 10px; }
.fr-main { display: grid; text-align: left; background: none; border: 0; padding: 8px 12px; cursor: pointer; min-width: 0; }
.fr-name { font-weight: 600; } .fr-sub, .fr-sub2 { font-size: 12.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- view tab ----------------------------------------------------------------------------------------- */
/* Fit the whole wheel (aspect about 1 : 1.19 with header and footer) between the bars without scrolling. */
.wheel-scroll { margin: 0 auto; width: 100%; max-width: min(100%, calc((100dvh - 226px) * 0.84)); }
@media (min-width: 960px) { .wheel-scroll { max-width: min(100%, calc((100dvh - 128px) * 0.84)); } }
.wheel-scroll.zoomed { max-width: 100%; overflow: auto; max-height: calc(100dvh - 226px); }
@media (min-width: 960px) { .wheel-scroll.zoomed { max-height: calc(100dvh - 128px); } }
.wheel-holder svg { display: block; height: auto; border-radius: 10px; box-shadow: var(--shadow); }
.zoom-bar { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.grid-caption { text-align: center; color: var(--dim); font-size: 13px; margin: 2px 0 8px; }
.grid-wrap { overflow: auto; background: var(--paper); border-radius: 10px; padding: 10px; max-width: max-content; margin: 0 auto; }
.aspect-grid { border-collapse: collapse; color: var(--ink); }
.aspect-grid .gh { width: 46px; height: 46px; color: var(--ink); font-weight: 600; border: 1px solid var(--faint); text-align: center; }
.aspect-grid .gh.b { color: var(--outer); }
.aspect-grid .gh.corner { border: 0; }
.aspect-grid .gc { width: 46px; height: 46px; border: 1px solid var(--faint); text-align: center; padding: 2px 0; vertical-align: middle; }
.aspect-grid .gc.void { border: 0; }
.aspect-grid .gc .orb { display: block; font-size: 10.5px; line-height: 1.1; font-variant-numeric: tabular-nums; opacity: 0.95; }
.aspect-grid .gc .orb i { font-style: normal; margin-left: 2px; opacity: 0.8; }

/* ---- reports ------------------------------------------------------------------------------------------ */
table.kv { border-collapse: collapse; width: 100%; font-size: 14px; }
table.kv th { text-align: left; color: var(--dim); font-weight: 500; padding: 5px 12px 5px 0; white-space: nowrap; vertical-align: top; width: 1%; }
table.kv td { padding: 5px 0; font-variant-numeric: tabular-nums; }
table.kv tr { border-bottom: 1px solid var(--line); }
.table-scroll { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th { text-align: left; color: var(--thead-ink); background: var(--thead-bg); font-weight: 600; font-size: 12.5px; padding: 7px 10px 7px 6px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.data td { padding: 6px 10px 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td.num { font-variant-numeric: tabular-nums; }
table.data td.c { text-align: center; }
.ptn { display: inline-flex; align-items: center; gap: 7px; }
.ptn .gl, .ptn .ptlabel { width: 20px; text-align: center; flex: none; }
.lon .gl { margin: 0 2px; }
.retro { color: var(--danger); font-style: italic; }
.el-fire { color: var(--fire); } .el-earth { color: var(--earth); } .el-air { color: var(--air); } .el-water { color: var(--water); }
.aspc { display: flex; align-items: center; gap: 7px; }
.ac-ink { color: var(--ink); } .ac-hard { color: var(--asp-hard); } .ac-soft { color: var(--asp-soft); } .ac-adjust { color: var(--asp-adjust); } .ac-creative { color: var(--asp-creative); } .ac-mystic { color: var(--asp-mystic); } .ac-minor { color: var(--asp-minor); }
.as { font-size: 12px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); }
.as.a { color: var(--ok); } .as.s { color: var(--dim); }
.cusps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 14px; font-size: 14px; font-variant-numeric: tabular-nums; }
.cusp .cn { display: inline-block; width: 24px; color: var(--dim); }
.notes { white-space: pre-wrap; color: var(--dim); font-size: 13.5px; }
.interp article { background: var(--panel); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.interp article h3 { color: var(--heading); margin: 0 0 6px; font-size: 14px; }
.interp article p { margin: 0; line-height: 1.7; }
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; }
.lg { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.lg > :first-child { width: 26px; text-align: center; flex: none; }

/* ---- list-style reports and interpretations (layout after the reference app: chart heading, title bar, rows) ---- */
.chart-head { font-size: 14px; line-height: 1.45; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.chart-head .ch-name { font-size: 17px; font-weight: 700; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.title-bar { background: var(--thead-bg, var(--panel)); color: var(--thead-ink); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); text-align: center; font-weight: 700; padding: 7px 10px; margin: 6px 0 0; }
.list-row.plain { border-radius: 0; margin: 0; border-width: 0 0 1px 0; border-color: var(--rule); background: transparent; padding: 13px 10px; grid-template-areas: 'title chev'; }
.list-row.plain:hover { background: var(--panel); }
.list-row.plain .sym { margin-right: 4px; }
.interp article { line-height: 1.75; }
.interp article p { margin: 0 0 12px; font-size: 15.5px; line-height: 1.8; }
.interp article p:last-child { margin-bottom: 0; }
.interp-lead { color: var(--dim); font-size: 14.5px !important; border-left: 3px solid var(--accent-fill); padding-left: 10px; }
.interp-note { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); border-radius: 8px; padding: 7px 10px; font-size: 13.5px !important; line-height: 1.55 !important; }
.interp .interp-h { color: var(--heading); font-size: 16px; font-weight: 700; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.interp .interp-h:first-child { margin-top: 0; }
.interp .interp-sub { color: var(--dim); font-size: 13px; font-weight: 600; margin: 22px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); text-transform: none; }
.interp-asp { margin: 0 0 16px; }
.interp-asp h4 { margin: 0 0 2px; font-size: 15px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.interp-asp .asp-name { display: inline-flex; align-items: center; gap: 4px; color: var(--dim); font-weight: 600; }
.asp-meta { font-size: 12.5px; color: var(--dim); margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.infl { font-weight: 700; }
.infl.strong { color: var(--danger); } .infl.medium { color: var(--gold); } .infl.weak { color: var(--dim); }
.btn-row.between { justify-content: space-between; }

/* essential dignities · lunar events · midpoints · dynamic listing */
.ed-hour { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; justify-content: space-between; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 6px 4px; margin: 4px 0 0; font-size: 13.5px; }
.ed-hour span { display: inline-flex; align-items: center; gap: 6px; }
table.data.ed th, table.data.ed td { padding: 6px 4px; }
table.data th.c, table.data td.c { text-align: center; }
table.data .mk { font-size: 11px; font-weight: 700; margin-left: 1px; color: var(--dim); vertical-align: 2px; }
table.data.ed td.score { font-weight: 700; text-align: right; }
.seg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 10px; }
.dyn-head { display: grid; gap: 8px; margin: 4px 0 10px; }
.dyn-head select, .dyn-head input[type="date"] { width: 100%; }
table.data.dyn td { padding: 6px 5px; }
table.data.dyn tr.sec td { background: var(--thead-bg); color: var(--thead-ink); font-weight: 700; font-size: 12.5px; border-top: 1px solid var(--rule); }
table.data .evt { font-size: 12.5px; font-weight: 700; }
td.tech-tr { color: var(--soft-ink, #2e9d4f); } td.tech-sp { color: var(--gold); } td.tech-sa { color: var(--danger); } td.tech-vd { color: var(--danger); }
td.tech-tp, td.tech-mp { color: var(--gold); } td.tech-aa, td.tech-va, td.tech-pf { color: var(--danger); }
.job-part { margin-top: 10px; }
.job-part .row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 520px) { .job-part .row.two { grid-template-columns: 1fr; } }

/* view: time stepping */
.step-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.step-bar select { width: auto; padding: 6px 8px; }
.step-bar .step-note { flex-basis: 100%; }

/* file browser: sort / select controls, note markers, file descriptions */
.fb-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fb-bar select, .fb-bar input[type=search] { min-width: 0; flex: 1 1 140px; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.icon-btn.faint { opacity: .35; }
.icon-btn.on { opacity: 1; }
.fr-note { font-size: .85em; }
label.fr-main { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; cursor: pointer; }
label.fr-main input[type=checkbox] { margin-bottom: 4px; }
.lr-desc { font-weight: 400; }

/* point display order (settings → displayed points) */
.order-list { display: flex; flex-direction: column; gap: 4px; }
.order-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; background: var(--card, transparent); }
.order-row .grow { flex: 1; }

/* dynamic listing: events with an interpretation open it when tapped */
table.dyn tr.tap { cursor: pointer; }
table.dyn tr.tap:hover td { background: var(--hover, rgba(127,127,127,.12)); }
table.dyn tr.tap td:first-child { box-shadow: inset 3px 0 0 var(--accent, #c9a227); }

/* AI interpretation chat */
.ai-chat { max-width: 900px; margin: 0 auto; }
.ai-intro { margin: 8px 2px 10px; }
.ai-log { display: flex; flex-direction: column; gap: 10px; max-height: 58vh; overflow-y: auto; padding: 4px 2px; }
.ai-empty { text-align: center; }
.ai-bubble { max-width: 85%; border: 1px solid var(--card-line); border-radius: var(--radius); padding: 9px 13px; box-shadow: var(--shadow); }
.ai-bubble .ai-who { font-size: 11.5px; font-weight: 700; color: var(--dim); margin-bottom: 4px; }
.ai-bubble p { margin: 0 0 8px; line-height: 1.7; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble.user { align-self: flex-end; background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-ink); }
.ai-bubble.user .ai-who { color: var(--gold); }
.ai-bubble.assistant { align-self: flex-start; background: var(--panel); }
.ai-dots { color: var(--dim); letter-spacing: 2px; animation: ai-pulse 1.1s ease-in-out infinite; }
@keyframes ai-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.ai-notice:empty { display: none; }
.ai-notice { margin-top: 10px; }
.ai-input-row { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 2px; }
.ai-input-row textarea.ai-input { flex: 1; resize: vertical; min-height: 44px; }
.ai-send { flex: none; align-self: stretch; min-width: 84px; }
.ai-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 8px 2px 10px; }
.ai-head-row .ai-intro { margin: 0; flex: 1; }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.ai-cfg-btn { flex: none; }
.ai-clear-btn { flex: none; }
.ai-with-btn { flex: none; }
.ai-more-row { display: flex; justify-content: flex-end; margin-top: 6px; }
/* the animated astrologer above the input: portrait on the left, speech bubble beside it */
.astro-stage-wrap { margin: 6px 0 8px; }
.astro-stage { position: relative; display: flex; align-items: flex-start; gap: 10px; min-height: 160px; }
.astro-canvas { width: 160px; height: 160px; border-radius: 16px; border: 3px solid var(--gold, #806000); box-shadow: 0 3px 10px rgba(60, 40, 0, 0.28); background: #3b2a12; flex: none; opacity: 0; transition: opacity 0.4s; }
.astro-stage.ready .astro-canvas { opacity: 1; }
.astro-stage.failed { display: none; }
.astro-bubble { position: relative; margin-top: 18px; max-width: 320px; padding: 10px 14px; border-radius: 14px; background: #fffef2; border: 1.5px solid var(--gold, #806000); color: #3a2a00; font-size: 0.98em; line-height: 1.45; box-shadow: 0 2px 6px rgba(60, 40, 0, 0.15); opacity: 0; transform: translateY(6px) scale(0.98); transition: opacity 0.35s, transform 0.35s; pointer-events: none; }
.astro-bubble::before { content: ''; position: absolute; left: -9px; top: 18px; border: 8px solid transparent; border-right-color: var(--gold, #806000); border-left: 0; }
.astro-bubble::after { content: ''; position: absolute; left: -6px; top: 19px; border: 7px solid transparent; border-right-color: #fffef2; border-left: 0; }
.astro-bubble.show { opacity: 1; transform: none; }
.ai-with-btn.active { border-color: var(--gold, #806000); font-weight: 600; }
.ai-with { border: 1px solid var(--line, #c9b678); border-radius: 10px; padding: 8px 12px; margin: 4px 0 10px; background: #fffff4; }
.ai-with-group { margin: 8px 0 2px; font-weight: 600; }
.ai-with-row { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.ai-head-row .ai-period { flex: none; max-width: 30%; }
.ai-head-row { flex-wrap: wrap; align-items: center; }
.ai-head-row .ai-intro { flex: 1 1 100%; }
.ai-head-row .ai-engine, .ai-head-row .ai-effort, .ai-head-row .ai-period { max-width: none; flex: 1 1 160px; }
.ai-wheel { margin: 4px 0 10px; }
.ai-wheel summary { cursor: pointer; font-weight: 600; padding: 4px 2px; }
.ai-wheel-svg { max-width: 560px; margin: 0 auto; }
.ai-wheel-svg svg { width: 100%; height: auto; display: block; }
.ai-who { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.ai-avatar { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 3px solid var(--gold, #806000); box-shadow: 0 2px 6px rgba(60, 40, 0, 0.25); flex: none; }
.ai-zoom { margin: 6px 0 12px; max-width: 300px; border: 1px solid var(--line, #c9b678); border-radius: 10px; overflow: hidden; background: #fffff4; }
.ai-zoom svg { width: 100%; height: auto; display: block; }
.ai-zoom figcaption { padding: 4px 8px; }
.ai-bubble p { white-space: pre-line; }
.ai-bubble .ai-h { margin: 14px 0 6px; font-size: 1.05em; }
.ai-bubble h3.ai-h { font-size: 1.15em; }
.ai-bubble .ai-hr { border: 0; border-top: 1px solid var(--line, #c9b678); margin: 12px 0; }
.ai-empty .ai-start { margin: 0 12px 12px; }
.ai-head-row .ai-engine { flex: none; max-width: 46%; }
.ai-cfg-wrap:empty { display: none; }
.ai-cfg { background: var(--panel); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; display: grid; gap: 9px; max-width: 520px; }
.ai-cfg-title { font-weight: 700; color: var(--heading); }
.ai-cfg-field { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 10px; }
.ai-cfg-field > span { font-size: 12.5px; color: var(--dim); }
.ai-cfg-note { margin: 2px 0 0; line-height: 1.5; }
.ai-cfg-msg:empty { display: none; }
