/* Page styles for qimen-grid.html (free qimen chart, member dashboard dialog, A4 report).
   Loaded before the shared layers (tokens.css … responsive.css), where the
   inline <style> used to be, so the cascade order is unchanged. */

* { box-sizing: border-box; }

html { color-scheme: light; overflow-y: scroll; scrollbar-gutter: stable; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--qice-ink);
  background:
    radial-gradient(circle at 15% 5%, rgba(162, 123, 53, .10), transparent 28rem),
    linear-gradient(180deg, #faf8f2 0, var(--qice-bg) 42%, #eee8dc 100%);
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

button, input, select, textarea { font: inherit; }

button, select { min-height: 42px; }

button { touch-action: manipulation; }

.app-shell {
  width: min(var(--qice-shell-max), calc(100% - (var(--qice-page-gutter) * 2)));
  margin: 0 auto;
  padding: var(--qice-header-top) 0 54px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 0 4px;
}

.brand { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }

.brand-mark {
  display: block;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(31, 107, 91, .16);
  border-radius: 15px;
  background: #f7f4ea;
  box-shadow: 0 7px 18px rgba(31, 107, 91, .16);
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.18);
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 3px;
  font-family: "Songti TC", "Noto Serif TC", serif;
  font-size: clamp(22px, 3vw, 31px);
  font-weight: 700;
  letter-spacing: .12em;
}

.brand p { margin: 0; color: var(--qice-muted); font-size: 13px; }

.surface {
  border: 1px solid rgba(170, 154, 130, .55);
  border-radius: var(--qice-radius-md);
  background: var(--qice-surface);
  box-shadow: var(--qice-shadow-md);
}

.control-panel { padding: 20px; }

.control-row {
  display: grid;
  grid-template-columns: minmax(158px, 1.25fr) repeat(5, minmax(76px, .7fr)) minmax(116px, .9fr) auto;
  gap: 12px;
  align-items: end;
}

.field { min-width: 0; }

.field label {
  display: block;
  margin: 0 0 6px 2px;
  color: var(--qice-muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .06em;
}

select, input, textarea {
  width: 100%;
  border: 1px solid var(--qice-line);
  border-radius: 10px;
  color: var(--qice-ink);
  background: #fffefa;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}

select, input { padding: 9px 11px; }
textarea { min-height: 90px; padding: 11px 12px; line-height: 1.55; resize: vertical; }
.fixed-system-label {
  display: block;
  min-height: 38px;
  padding: 9px 11px;
  border: 1px solid var(--qice-line);
  border-radius: 10px;
  color: var(--qice-brand-dark);
  background: #f7faf8;
  font-size: 13px;
  line-height: 18px;
}
.fixed-system-label[hidden] { display: none; }

select:focus, input:focus, textarea:focus, button:focus-visible, [tabindex="0"]:focus-visible {
  border-color: var(--qice-premium);
  box-shadow: 0 0 0 3px rgba(162, 123, 53, .15);
}

.gender-field[hidden] { display: none; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--qice-line);
  border-radius: 10px;
  color: var(--qice-ink);
  background: #fffefa;
  cursor: pointer;
  font-weight: 650;
  white-space: nowrap;
  transition: background .16s, border-color .16s, color .16s, transform .1s;
}

.button:hover { border-color: var(--qice-line-strong); background: #f8f2e7; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .48; transform: none; }

.button.primary { border-color: var(--qice-brand); color: #fff; background: var(--qice-brand); }
.button.primary:hover { border-color: var(--qice-brand-dark); background: var(--qice-brand-dark); }
.button.subtle { background: transparent; }
.button.danger { color: var(--qice-danger); }



.notice {
  display: none;
  margin-top: 14px;
  padding: 11px 13px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.notice.show { display: block; }
.notice.error { color: #762721; border-color: #e0aaa5; background: #fff0ee; }
.notice.success { color: #215242; border-color: #a9cec0; background: #edf8f3; }
.notice.info { color: #6a5225; border-color: #d9c38e; background: #fff9e9; }

.report-status {
  margin: 12px 0 0;
  padding: 11px 13px;
  border: 1px solid var(--qice-line);
  border-radius: 10px;
  color: var(--qice-muted);
  background: #f7faf8;
  font-size: 13px;
  line-height: 1.55;
}
.report-status[hidden] { display: none; }
.report-status.error { color: #762721; border-color: #e0aaa5; background: #fff0ee; }
.report-status.success { color: #215242; border-color: #a9cec0; background: #edf8f3; }
.report-status.loading { color: #6a5225; border-color: #d9c38e; background: #fff9e9; }
.report-retry-button { width: 100%; margin-top: 9px; }
.report-retry-button[hidden] { display: none; }
.report-progress { margin-top: 12px; padding: 12px; border: 1px solid #d9e6e0; border-radius: 12px; background: #f8fbfa; }
.report-progress[hidden] { display: none; }
.report-progress p { margin: 0 0 9px; color: var(--qice-brand-dark); font-size: 12px; font-weight: 800; }
.report-progress ol { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; padding: 0; list-style: none; }
.report-progress li { display: flex; align-items: center; gap: 6px; color: var(--qice-muted); font-size: 11px; }
.report-progress li span { color: #8aa49a; font-weight: 900; }
.report-progress li[data-state="done"] { color: var(--qice-brand-dark); }
.report-progress li[data-state="done"] span { color: var(--qice-brand); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 20px;
  margin-top: 20px;
  align-items: stretch;
}

.chart-panel { min-width: 0; padding: 20px; }

.chart-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--qice-brand);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.chart-heading h2 { margin-bottom: 4px; font-size: 22px; }
.chart-heading p { margin-bottom: 0; color: var(--qice-muted); font-size: 13px; }

.chart-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.chart-actions .button { min-height: 36px; padding: 7px 11px; font-size: 12px; }

.chart-reading-layout { display: block; }
.chart-reading-canvas { min-width: 0; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--qice-line);
  border-radius: 12px;
  background: var(--qice-line);
}

.summary-item { min-width: 0; padding: 10px 11px; background: #fffefa; }
.summary-item.wide { grid-column: span 2; }
.summary-label { display: block; margin-bottom: 4px; color: var(--qice-muted); font-size: 10px; letter-spacing: .06em; }
.summary-value { display: block; overflow-wrap: anywhere; font-size: 13px; font-weight: 700; }

.chart-annotations { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; margin: -5px 0 13px; }

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border: 1px solid rgba(127, 53, 42, .20);
  border-radius: 999px;
  color: var(--qice-brand);
  background: rgba(127, 53, 42, .06);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}

.tag.neutral { color: var(--qice-muted); border-color: var(--qice-line); background: var(--qice-bg); }
.tag.green { color: var(--qice-success); border-color: rgba(47, 102, 85, .25); background: rgba(47, 102, 85, .07); }

.grid-wrap {
  overflow: hidden;
  border: 1px solid #8d7b62;
  border-radius: 12px;
  background: #8d7b62;
}

.qimen-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: #8d7b62;
}

.palace {
  position: relative;
  min-width: 0;
  min-height: 194px;
  padding: 12px;
  color: var(--qice-ink);
  background:
    linear-gradient(rgba(255, 254, 250, .95), rgba(250, 247, 239, .95)),
    repeating-linear-gradient(0deg, transparent 0 12px, rgba(127, 53, 42, .025) 12px 13px);
}

.palace.is-red { box-shadow: inset 4px 0 0 #a84238; }
.palace.is-green { box-shadow: inset 4px 0 0 #3d765e; }
.palace.is-gold { box-shadow: inset 4px 0 0 var(--qice-premium); }
.palace.empty-state { cursor: default; background: rgba(255, 254, 250, .86); }

.palace-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.palace-name { font-family: "Songti TC", "Noto Serif TC", serif; font-size: 18px; font-weight: 750; letter-spacing: .04em; }
.palace-meta { margin-top: 2px; color: var(--qice-muted); font-size: 10px; }

.score {
  display: grid;
  min-width: 36px;
  height: 36px;
  padding: 2px;
  place-items: center;
  border: 1px solid var(--qice-line);
  border-radius: 50%;
  color: var(--qice-brand);
  background: #fffefa;
  font-size: 12px;
  font-weight: 800;
}

.palace-main {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.symbol {
  min-width: 0;
  padding: 7px 3px;
  border: 1px solid var(--qice-brand-soft);
  border-radius: 8px;
  text-align: center;
  background: rgba(255, 255, 255, .65);
}

.symbol-label, .stem-label { display: block; margin-bottom: 2px; color: var(--qice-muted); font-size: 9px; }
.symbol-value { display: block; overflow-wrap: anywhere; font-size: 13px; font-weight: 750; }

.stem-lines { display: grid; gap: 4px; }
.stem-line { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: baseline; gap: 5px; font-size: 11px; }
.stem-label { margin: 0; }
.stem-value { min-width: 0; overflow-wrap: anywhere; font-weight: 650; }

.palace-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

.missing-palace {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--qice-muted);
  text-align: center;
  font-size: 12px;
}

.side-stack { display: grid; gap: 16px; }
.side-card { padding: 17px; }
.side-card h3 { margin-bottom: 5px; font-size: 16px; }
.side-card > p { margin-bottom: 13px; color: var(--qice-muted); font-size: 12px; line-height: 1.6; }
.side-card .field + .field { margin-top: 12px; }

.side-buttons { display: grid; gap: 8px; margin-top: 12px; }

dialog {
  width: min(720px, calc(100% - 28px));
  max-height: min(780px, calc(100vh - 40px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--qice-line-strong);
  border-radius: 16px;
  color: var(--qice-ink);
  background: #fffdf7;
  box-shadow: 0 30px 80px rgba(43, 33, 20, .24);
}

dialog::backdrop { background: rgba(35, 31, 24, .42); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 20px; border-bottom: 1px solid var(--qice-brand-soft); }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-head [tabindex="-1"]:focus { outline: none; }
.dialog-body { max-height: calc(100vh - 145px); padding: 16px 20px 22px; overflow: auto; }

.history-list { display: grid; gap: 10px; }
.history-empty { padding: 30px; color: var(--qice-muted); text-align: center; }
.history-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 13px; border: 1px solid var(--qice-line); border-radius: 11px; background: #fffefa; }
.history-title { margin: 0 0 4px; font-size: 14px; }
.history-meta { color: var(--qice-muted); font-size: 11px; line-height: 1.55; }
.history-actions { display: flex; align-items: center; gap: 6px; }
.history-actions .button { min-height: 34px; padding: 6px 9px; font-size: 11px; }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, .42);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1180px) {
  .control-row { grid-template-columns: repeat(6, minmax(90px, 1fr)); }
  .field.system-field { grid-column: span 2; }
  .gender-field { grid-column: span 2; }
  #calculateButton { grid-column: span 2; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .side-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side-card:last-child { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .app-shell { width: min(100% - 20px, 1480px); padding-top: 15px; }
  .topbar { align-items: flex-start; }
  .control-panel, .chart-panel { padding: 14px; }
  .control-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .field.system-field, .gender-field, #calculateButton { grid-column: span 2; }
  .chart-heading { display: block; }
  .chart-actions { justify-content: flex-start; margin-top: 12px; }
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .summary-item.wide { grid-column: span 3; }
  .palace { min-height: 164px; padding: 9px; }
  .palace-name { font-size: 15px; }
  .palace-main { gap: 3px; }
  .symbol { padding: 6px 1px; }
  .symbol-value { font-size: 11px; }
  .stem-line { grid-template-columns: 28px minmax(0, 1fr); gap: 2px; font-size: 10px; }
  .tag { min-height: 19px; padding: 2px 5px; font-size: 8px; }
  .side-stack { grid-template-columns: 1fr; }
  .side-card:last-child { grid-column: auto; }
}

@media (max-width: 480px) {
  .brand-mark { width: 42px; height: 42px; }
  .brand p { display: none; }
  .chart-panel { padding: 10px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-item.wide { grid-column: span 2; }
  .palace { min-height: 151px; padding: 7px 5px; }
  .palace-meta { display: none; }
  .score { min-width: 28px; width: 28px; height: 28px; font-size: 10px; }
  .palace-main { display: block; margin-bottom: 5px; }
  .symbol { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 2px; padding: 2px 1px; border: 0; background: transparent; text-align: left; }
  .symbol-label { margin: 0; }
  .symbol-value { font-size: 10px; }
  .stem-line { font-size: 9px; }
  .stem-lines .stem-line:nth-child(3) { display: none; }
  .palace-tags { margin-top: 5px; }
  .history-item { grid-template-columns: 1fr; }
  .history-actions { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Jade strategy workspace. Domain data and chart geometry stay untouched;
   this layer only establishes the commercial product visual language. */
body {
  color: var(--qice-ink);
  background:
    radial-gradient(circle at 8% 0, rgba(31, 107, 91, .07), transparent 30rem),
    linear-gradient(180deg, #fbfaf7 0, var(--qice-bg) 34rem, #f2f2ed 100%);
}

.app-shell { width: min(var(--qice-shell-max), calc(100% - (var(--qice-page-gutter) * 2))); }
.topbar {
  position: relative;
  display: grid;
  min-height: 95px;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  padding: 14px 18px;
  border: 1px solid rgba(217, 221, 216, .88);
  border-radius: var(--qice-radius-md);
  background: rgba(255, 255, 255, .91);
  box-shadow: var(--qice-shadow-sm);
  backdrop-filter: blur(12px);
}
.brand-mark {
  border-color: rgba(31, 107, 91, .16);
  border-radius: 15px;
  background: #f7f4ea;
  box-shadow: 0 7px 18px rgba(31, 107, 91, .16);
}
.brand { min-width: max-content; grid-column: 1; justify-self: start; }
h1 { color: #173a32; letter-spacing: .08em; }
.brand p { color: var(--qice-muted); }
.product-nav {
  display: flex;
  grid-column: 2;
  align-items: center;
  justify-self: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid #d7e2dd;
  border-radius: 999px;
  background: #f7faf8;
}
.product-nav a {
  display: inline-flex;
  min-width: 142px;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 11px 18px;
  border-radius: 999px;
  color: #5c6d67;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}
.product-nav a:hover { color: var(--qice-brand-dark); background: var(--qice-brand-soft); }
.product-nav a[aria-current="page"] { color: #fff; background: var(--qice-brand); }
.product-nav a:focus-visible { outline: 3px solid rgba(11, 107, 92, .18); outline-offset: 2px; }
.surface {
  border: 1px solid rgba(217, 221, 216, .92);
  border-radius: var(--qice-radius-md);
  background: var(--qice-surface);
  box-shadow: var(--qice-shadow-md);
}

select, input, textarea {
  border-color: #ccd7d1;
  border-radius: 10px;
  color: var(--qice-ink);
  background: #fbfdfb;
}
select { font-weight: 650; }
select:hover, input:hover, textarea:hover { border-color: #9eb8ad; }
select:focus, input:focus, textarea:focus, button:focus-visible, [tabindex="0"]:focus-visible {
  border-color: var(--qice-brand);
  box-shadow: 0 0 0 3px rgba(31, 107, 91, .13);
}

.button {
  border-color: #cfdbd5;
  border-radius: 10px;
  color: var(--qice-brand-dark);
  background: #fff;
  box-shadow: 0 1px 2px rgba(24, 33, 31, .03);
}
.button:hover { border-color: #93b2a6; background: var(--qice-surface-muted); }
.button.primary {
  border-color: var(--qice-brand);
  color: #fff;
  background: var(--qice-brand);
  box-shadow: 0 7px 16px rgba(31, 107, 91, .16);
}
.button.primary:hover { border-color: var(--qice-brand-dark); background: var(--qice-brand-dark); }
.button.danger { color: var(--qice-danger); }
.now-control { align-self: end; border-color: #a9c1b7; }

.control-panel { padding: 20px; }
.control-intro { margin-bottom: 18px; padding-bottom: 15px; border-bottom: 1px solid var(--qice-brand-soft); }
.control-kicker { display: block; margin-bottom: 5px; color: var(--qice-brand); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.control-intro h2 { margin-bottom: 4px; color: #173a32; font: 700 20px/1.35 "Songti TC", "Noto Serif TC", serif; }
.control-row { gap: 10px; }
.field label { color: #66766f; }

.chart-panel { padding: 20px 22px 25px; }
.chart-heading { max-width: 700px; margin-right: auto; margin-left: auto; padding-bottom: 13px; border-bottom: 1px solid #dce5e0; }
.eyebrow { color: var(--qice-brand); }
.chart-heading h2 { color: #173a32; font-family: "Songti TC", "Noto Serif TC", serif; }
.chart-heading p { color: var(--qice-muted); }

.summary-board {
  position: relative;
  display: grid;
  width: min(100%, 700px);
  grid-template-columns: minmax(0, 1fr) 178px;
  gap: 18px;
  margin: 14px auto 13px;
  padding: 13px 15px;
  border: 1px solid #dce7e2;
  border-radius: 12px;
  background: #f8fbf9;
}
.summary-grid {
  max-width: none;
  grid-template-columns: 1fr;
  gap: 4px;
  margin: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.summary-item {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 6px;
  min-width: 0;
  padding: 2px 0;
  color: var(--qice-brand);
  background: transparent;
}
.summary-item.wide { grid-column: 1 / -1; }
.summary-label { margin: 0; color: #708078; font-size: 14px; }
.summary-label::after { content: "："; }
.summary-value { color: var(--qice-brand-dark); font-family: "Songti TC", "Noto Serif TC", serif; font-size: 14px; }
.pillar-table { display: grid; gap: 3px; margin-bottom: 5px; }
.pillar-row {
  display: grid;
  grid-template-columns: 70px repeat(4, minmax(28px, 1fr));
  gap: 6px;
  align-items: center;
  color: var(--qice-brand-dark);
  font-family: "Songti TC", "Noto Serif TC", serif;
}
.pillar-label {
  color: #708078;
  font-family: "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 14px;
  line-height: 1.2;
}
.pillar-label::after { content: "："; }
.pillar-value { font-size: 18px; font-weight: 700; text-align: center; }
.summary-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }
.chart-annotations {
  display: flex;
  max-width: none;
  min-height: 100%;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  margin: 0;
}
.chart-annotations .tag { border: 0; border-radius: 0; color: var(--qice-danger); background: transparent; }
.chart-annotations .tag.neutral { color: var(--qice-brand); }
.annotation-item { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 4px; color: var(--qice-brand); }
.annotation-label { color: #708078; font-size: 14px; }
.annotation-label::after { content: "："; }
.annotation-value { font-family: "Songti TC", "Noto Serif TC", serif; font-size: 14px; }
.motion-pattern {
  align-self: flex-end;
  margin-top: auto;
  color: var(--qice-danger);
  font-family: "Songti TC", "Noto Serif TC", serif;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .04em;
}

.grid-wrap {
  position: relative;
  width: min(100%, 748px);
  max-width: 100%;
  margin: 25px auto 27px;
  padding: 24px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid #8fa199;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 9px 22px rgba(31, 72, 61, .07);
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-touch-callout: none;
}
.grid-wrap.chart-shell {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overscroll-behavior-inline: contain;
  scrollbar-color: #9eb8ad #edf4f0;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 1181px) {
  .grid-wrap.chart-shell { overflow: visible; }
}
.chart-stage {
  position: relative;
  width: min(100%, 700px);
  min-width: 0;
  aspect-ratio: 1;
  margin: 0 auto;
}
.hidden-ring { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.hidden-stem {
  position: absolute;
  display: inline-flex;
  min-width: 22px;
  justify-content: center;
  color: #384b45;
  font: 800 17px/1 "Songti TC", "Noto Serif TC", serif;
  white-space: nowrap;
}
.hidden-stem .stem-token { padding-bottom: 0; }
.hidden-stem[data-palace="9"] { top: -28px; left: 50%; transform: translateX(-50%); }
.hidden-stem[data-palace="1"] { bottom: -10px; left: 50%; transform: translate(-50%, 100%); }
.hidden-stem[data-palace="4"] { top: 16.666%; left: -10px; transform: translate(-100%, -50%); }
.hidden-stem[data-palace="3"] { top: 50%; left: -10px; transform: translate(-100%, -50%); }
.hidden-stem[data-palace="8"] { top: 83.333%; left: -10px; transform: translate(-100%, -50%); }
.hidden-stem[data-palace="2"] { top: 16.666%; right: -10px; transform: translate(100%, -50%); }
.hidden-stem[data-palace="7"] { top: 50%; right: -10px; transform: translate(100%, -50%); }
.hidden-stem[data-palace="6"] { top: 83.333%; right: -10px; transform: translate(100%, -50%); }
.hidden-stem[data-palace="4"],
.hidden-stem[data-palace="3"],
.hidden-stem[data-palace="8"],
.hidden-stem[data-palace="2"],
.hidden-stem[data-palace="7"],
.hidden-stem[data-palace="6"] {
  align-items: center;
  flex-direction: column;
  gap: 2px;
}
@media (min-width: 761px) and (max-width: 1180px) {
  .grid-wrap.chart-shell { padding: 32px; }
}
.qimen-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 0;
  border: 1px solid #8fa199;
  background: #fff;
  box-sizing: border-box;
}
.palace {
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  position: relative;
  padding: 8px 9px;
  border-right: 1px solid #cbd5d0;
  border-bottom: 1px solid #cbd5d0;
  color: var(--qice-ink);
  background: #fff;
  cursor: pointer;
  transition: background .14s ease, box-shadow .14s ease;
}
.palace:nth-child(3n) { border-right: 0; }
.palace:nth-child(n+7) { border-bottom: 0; }
.palace.is-red, .palace.is-green, .palace.is-gold { box-shadow: none; }
.palace-head { min-height: 22px; margin-bottom: 3px; }
.palace-name { color: #1d3e36; font-size: 15px; letter-spacing: .02em; }
.palace-meta { display: none; }
.palace-head-right { display: flex; align-items: flex-start; gap: 5px; margin-left: auto; }
.palace-flags { display: inline-flex; align-items: flex-start; gap: 4px; min-height: 18px; }
.palace-flag {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  font-family: "Songti TC", "Noto Serif TC", serif;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}
.palace-flag.void { color: #c52d3a; }
.palace-flag.void .void-circle { color: #9aa59f; font-size: 13px; font-weight: 500; }
.palace-flag.horse { color: var(--qice-premium); }
.score { width: 28px; min-width: 28px; height: 28px; border: 0; color: var(--qice-brand); background: transparent; font-size: 10px; }

.palace-layers {
  display: grid;
  height: calc(100% - 45px);
  grid-template-rows: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 2px;
}
.palace-layer {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  font-family: "Songti TC", "Noto Serif TC", serif;
  line-height: 1.2;
}
.layer-value { position: relative; min-width: 0; grid-column: 2; overflow-wrap: anywhere; font-size: 18px; font-weight: 700; text-align: center; }
.layer-stem { display: inline-flex; min-width: 0; grid-column: 3; justify-content: flex-end; color: #27332f; font-size: 17px; font-weight: 700; text-align: right; white-space: nowrap; }
.stem-token, .layer-value-marked { position: relative; display: inline-block; padding-bottom: 10px; line-height: 1; }
.stem-token.is-punishment, .layer-value-marked.is-pressure { color: #c52d3a; }
.stem-token.is-tomb { color: #b49a3a; }
.component-marker {
  position: absolute;
  right: 50%;
  bottom: -1px;
  color: #7f8b85;
  font: 700 10px/1 "PingFang TC", "Microsoft JhengHei", sans-serif;
  transform: translateX(50%);
}
.palace-layer.deity .layer-value { color: #202c29; }
.palace-layer.star .layer-value { color: #202c29; }
.palace-layer.door .layer-value { color: #202c29; }
.palace-layer .eval-red, .stem-token.eval-red { color: var(--qice-danger); }
.palace-layer .eval-green, .stem-token.eval-green { color: #287a61; }
.palace-layer.door .layer-value.layer-value-marked.is-pressure { color: #c52d3a; }
.palace-tags { position: absolute; right: 8px; bottom: 3px; left: 8px; display: flex; min-height: 12px; gap: 5px; }
.palace-tags .tag { min-height: 0; padding: 0; border: 0; border-radius: 0; color: var(--qice-danger); background: transparent; font-size: 9px; }
.palace-tags .tag.horse { color: var(--qice-premium); }
.palace-tags .tag.neutral { color: #75827c; background: transparent; }
.palace[data-palace="5"] { position: relative; background: #f7f4ea; }
.palace[data-palace="5"] .palace-layers { display: none; }
.palace[data-palace="5"] .palace-tags { display: none; }
.center-palace-brand {
  position: absolute;
  inset: 0;
  display: grid;
  overflow: hidden;
  place-items: center;
  pointer-events: none;
}
.center-palace-logo {
  display: block;
  width: 92%;
  height: 92%;
  object-fit: contain;
  object-position: center;
  opacity: .98;
}
.chart-canvas-controls, .chart-canvas-status { display: none; }
.capture-hint { display: none; margin: 9px auto 0; color: var(--qice-brand); font-size: 11px; text-align: center; }
.grid-wrap.is-holding::after {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(31, 107, 91, .68);
  font-weight: 700;
  letter-spacing: .06em;
  content: "繼續按住以儲存盤面";
  pointer-events: none;
}

.side-card { border-top: 3px solid #bfd4cc; border-radius: var(--qice-radius-md); box-shadow: var(--qice-shadow-sm); }
.side-card h3 { color: var(--qice-brand); }
.topbar-actions { display: flex; grid-column: 3; align-items: center; justify-self: end; gap: 9px; }
.admin-logout-form[hidden] { display: none; }
.admin-logout-button {
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid #cbdad4;
  border-radius: 999px;
  color: #47645b;
  background: #fff;
  font: 750 10px/1.2 "PingFang TC", "Microsoft JhengHei", sans-serif;
  cursor: pointer;
}
.member-center-chip[hidden] { display: none; }
.member-access-link {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 7px 11px;
  border: 1px solid #b9d2c8;
  border-radius: 13px;
  color: var(--qice-brand-dark);
  background: #fff;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}
.member-access-link:hover, .member-access-link:focus-visible { border-color: var(--qice-brand); background: var(--qice-surface-muted); outline: none; }
.member-access-link[hidden] { display: none; }
.member-center-chip {
  display: grid;
  min-height: 36px;
  grid-template-columns: auto auto;
  gap: 7px;
  align-items: center;
  padding: 5px 7px 5px 11px;
  border: 1px solid #b9d2c8;
  border-radius: 999px;
  color: var(--qice-brand-dark);
  background: #fff;
  font: inherit;
  cursor: pointer;
}
.member-center-chip:hover { border-color: var(--qice-brand); background: var(--qice-surface-muted); }
.member-center-chip:focus-visible { outline: 3px solid rgba(31, 107, 91, .18); outline-offset: 2px; }
.member-center-chip:disabled { cursor: wait; opacity: .68; }
.member-center-chip-name { max-width: 112px; overflow: hidden; font-size: 11px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.member-center-chip-plan { padding: 3px 7px; border-radius: 999px; color: #6d5120; background: #fff3d9; font-size: 9px; font-weight: 800; white-space: nowrap; }

.card-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--qice-brand);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .15em;
}

.free-preview-card { border-top-color: var(--qice-brand); }
.free-preview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.free-preview-head h3 { margin-bottom: 3px; }
.preview-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid #c8ddd5;
  border-radius: 999px;
  color: var(--qice-brand);
  background: var(--qice-surface-muted);
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}
.free-preview-intro { margin: 0; color: #43534d; font-size: 12px; line-height: 1.7; }
.free-focus-picker { display: grid; gap: 8px; margin-top: 12px; }
.free-focus-picker[hidden], .free-score-card[hidden], .free-summary-result[hidden] { display: none; }
.free-focus-picker-label { margin: 0; color: var(--qice-brand-dark); font-size: 11px; font-weight: 850; }
.free-focus-options { display: grid; gap: 7px; }
.free-focus-option {
  display: grid;
  width: 100%;
  min-height: 44px;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid #cbdcd5;
  border-radius: 10px;
  color: var(--qice-brand-dark);
  background: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.free-focus-option:hover:not(:disabled) { border-color: #78ab99; background: #edf7f2; }
.free-focus-option:focus-visible { outline: 3px solid rgba(11, 107, 92, .2); outline-offset: 2px; }
.free-focus-option[aria-pressed="true"] { border-color: var(--qice-brand); color: #fff; background: var(--qice-brand); }
.free-focus-option:disabled { cursor: wait; opacity: .62; }
.free-focus-option strong { font-size: 12px; line-height: 1.45; }
.free-focus-option span { font-size: 10px; line-height: 1.45; opacity: .78; }
.free-score-card, .free-summary-result {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  padding: 11px;
  border: 1px solid #cbe1d7;
  border-radius: 11px;
  background: #f2f8f5;
}
.free-score-card h4, .free-summary-result h4 { margin: 0; color: var(--qice-brand-dark); font-size: 12px; }
.free-score-use-god, .free-summary-meta, .free-summary-copy { margin: 0; color: #43534d; font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
.free-score-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0; }
.free-score-metrics div { padding: 8px; border: 1px solid #d7e6df; border-radius: 9px; background: #fff; }
.free-score-metrics dt { color: var(--qice-muted); font-size: 9px; }
.free-score-metrics dd { margin: 2px 0 0; color: var(--qice-brand-dark); font-size: 18px; font-weight: 850; }
.free-summary-result { border-left: 4px solid var(--qice-brand); background: #fbfdfc; }
.generate-report-button { width: 100%; margin-top: 10px; }
.side-card .ai-offshore-notice {
  margin: 8px 0 0;
  color: var(--qice-muted);
  font-size: 11px;
  line-height: 1.5;
}
.report-system-notice {
  margin: 8px 0 0;
  color: #8a4a22;
  font-size: 11px;
  line-height: 1.5;
}
.report-system-notice[hidden] { display: none; }
.report-style-control { margin-top: 12px; padding: 11px 12px; border: 1px solid #d8e5df; border-radius: 11px; background: #f7faf8; }
.report-style-control[hidden] { display: none; }
.report-style-control-label { display: block; margin-bottom: 7px; color: var(--qice-brand-dark); font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.report-style-options { display: grid; gap: 6px; }
.report-style-option[hidden] { display: none !important; }
.report-style-option {
  display: grid;
  width: 100%;
  gap: 2px;
  padding: 8px 9px;
  border: 1px solid #cbdcd5;
  border-radius: 9px;
  color: var(--qice-brand-dark);
  background: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .16s, background .16s, color .16s, box-shadow .16s;
}
.report-style-option:hover:not(:disabled) { border-color: #78ab99; background: #edf7f2; }
.report-style-option:focus-visible { outline: 3px solid rgba(11, 107, 92, .2); outline-offset: 2px; }
.report-style-option[aria-pressed="true"] { border-color: var(--qice-brand); color: #fff; background: var(--qice-brand); box-shadow: 0 5px 12px rgba(31, 107, 91, .14); }
.report-style-option:disabled { cursor: not-allowed; opacity: .55; }
.report-style-option-title { font-size: 11px; font-weight: 850; line-height: 1.35; }
.report-style-option-description { font-size: 10px; line-height: 1.4; opacity: .78; }
.report-style-option[aria-pressed="true"] .report-style-option-description { opacity: .88; }
.report-style-control p { margin: 7px 0 0; color: var(--qice-muted); font-size: 10px; line-height: 1.55; }

.paywall-card {
  border-color: #214f43;
  border-top-color: #78ab99;
  color: #fff;
  background: #173f35;
  box-shadow: 0 15px 35px rgba(23, 63, 53, .18);
}
.paywall-card h3 { margin-bottom: 5px; color: #fff; }
.paywall-card > p { color: rgba(255, 255, 255, .72); }
.locked-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 13px 0; }
.locked-item {
  position: relative;
  min-height: 58px;
  padding: 9px 8px 8px 26px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 9px;
  color: rgba(255, 255, 255, .88);
  background: rgba(255, 255, 255, .055);
  font-size: 10px;
  line-height: 1.35;
}
.locked-item::before { position: absolute; top: 9px; left: 9px; color: #b9d8cc; content: "鎖"; font-size: 9px; font-weight: 800; }
.locked-item strong { display: block; margin-bottom: 2px; font-size: 11px; }
.locked-item span { color: rgba(255, 255, 255, .55); }
.unlock-offer { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 11px 0 9px; }
.unlock-offer[hidden] { display: none !important; }
.unlock-offer span { color: rgba(255, 255, 255, .65); font-size: 10px; }
.unlock-price { color: #fff; font-size: 12px; }
.unlock-price del { margin-right: 5px; color: rgba(255, 255, 255, .48); font-weight: 400; }
.unlock-price strong { color: #e5b96d; font-size: 18px; }
.paywall-card .button.primary { width: 100%; min-height: 44px; border-color: #fff; color: var(--qice-brand-dark); background: #fff; box-shadow: none; }
.paywall-card .button.primary:hover { border-color: #dbe9e3; color: #123d32; background: #edf6f2; }
.paywall-card .ai-offshore-notice { color: rgba(255, 255, 255, .72); }
.paywall-note { margin: 8px 0 0; color: rgba(255, 255, 255, .53); font-size: 9px; line-height: 1.5; text-align: center; }
.paywall-consumption-note {
  margin: 9px 0 0;
  padding: 7px 8px;
  border: 1px solid rgba(229, 185, 109, .36);
  border-radius: 8px;
  color: rgba(255, 255, 255, .86);
  background: rgba(229, 185, 109, .09);
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}
.membership-status { margin: 7px 0 0; color: #d8eee5; font-size: 10px; font-weight: 750; text-align: center; }
.membership-status[data-state="loading"] { color: #e5d5a9; }
.membership-status[data-state="error"] { color: #f0b7ad; }


.full-report-card { border-top-color: var(--qice-premium); }
.full-report-card > p { color: var(--qice-muted); }
.full-report-status-card { margin-top: 12px; padding: 11px 12px; border: 1px solid #dbe7e1; border-radius: 11px; background: #f7faf8; }
.full-report-status-pill { display: inline-flex; padding: 4px 8px; border: 1px solid #a9cec0; border-radius: 999px; color: #215242; background: #edf8f3; font-size: 10px; font-weight: 800; }
.full-report-status-card dl { display: grid; grid-template-columns: 1.5fr repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0 0; }
.full-report-status-card dt { color: var(--qice-muted); font-size: 9px; }
.full-report-status-card dd { margin: 2px 0 0; color: var(--qice-ink); font-size: 11px; font-weight: 750; overflow-wrap: anywhere; }
.full-report-sections:empty { display: none; }
.full-report-sections { display: grid; gap: 9px; margin-top: 12px; }
.full-report-sections article { padding: 12px; border: 1px solid #dbe7e1; border-radius: 11px; background: #fbfdfc; }
.full-report-sections h4 { margin: 0 0 5px; color: var(--qice-brand-dark); font-size: 12px; }
.full-report-sections p { margin: 0; color: #43534d; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.full-report-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 12px; }
.full-report-actions .button { min-height: 42px; text-align: center; }
.full-report-actions .button.primary { grid-column: 1 / -1; }
.full-report-energy-panel { margin-top: 12px; padding: 13px; border: 1px solid #d2e3dc; border-radius: 13px; background: #f8fbf9; }
.full-report-energy-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.full-report-energy-head .card-kicker { margin: 0; color: var(--qice-brand); }
.full-report-energy-head h4 { flex: 1 1 180px; margin: 0; color: var(--qice-brand-dark); font-size: 14px; }
.full-report-energy-status { padding: 4px 8px; border: 1px solid #b5d6ca; border-radius: 999px; color: #205e4d; background: #edf8f3; font-size: 10px; font-weight: 800; }
.full-report-energy-explanation, .full-report-energy-limitations, .full-report-energy-loading, .full-report-energy-error { margin: 9px 0 0; color: var(--qice-muted); font-size: 11px; line-height: 1.65; }
.full-report-energy-error { color: #a54036; }
.full-report-energy-obstacles, .full-report-energy-actions { display: grid; gap: 7px; margin-top: 10px; }
.full-report-energy-obstacles h5, .full-report-energy-actions h5 { margin: 0; color: var(--qice-brand-dark); font-size: 11px; }
.full-report-energy-obstacle, .full-report-energy-action { padding: 9px 10px; border: 1px solid #d8e7e0; border-radius: 10px; background: #fff; }
.full-report-energy-obstacle strong, .full-report-energy-action h6 { display: block; margin: 0; color: var(--qice-ink); font-size: 11px; }
.full-report-energy-obstacle p, .full-report-energy-action p { margin: 4px 0 0; color: var(--qice-muted); font-size: 10px; line-height: 1.55; }
.full-report-energy-action .button { min-height: 34px; margin-top: 8px; }
.full-report-energy-checklist { display: grid; gap: 5px; margin-top: 8px; padding: 8px 9px; border: 1px solid #c7dbd3; border-radius: 9px; background: #f4faf7; }
.full-report-energy-checklist h6 { margin: 0; color: var(--qice-brand-dark); font-size: 11px; }
.full-report-energy-checklist p, .full-report-energy-checklist strong { margin: 0; color: var(--qice-muted); font-size: 10px; line-height: 1.55; }
.full-report-energy-checklist strong { color: var(--qice-ink); }
.full-report-energy-checklist-empty { color: #7b5a20 !important; }
.full-report-energy-checklist-subheading { margin-top: 2px !important; }
.full-report-energy-checklist-list { display: grid; gap: 3px; margin: 0; padding-left: 18px; color: var(--qice-ink); font-size: 10px; line-height: 1.55; }
.full-report-energy-checklist-handling { padding-top: 5px; border-top: 1px dashed #d2e3dc; color: var(--qice-brand-dark) !important; }
.full-report-energy-ai-explanation { display: grid; gap: 7px; margin-top: 10px; padding: 10px; border: 1px solid #b9d8ce; border-radius: 10px; background: #eef8f3; }
.full-report-energy-ai-explanation h5 { margin: 0; color: var(--qice-brand-dark); font-size: 12px; }
.full-report-energy-ai-explanation p { margin: 0; color: var(--qice-muted); font-size: 10px; line-height: 1.6; }
.full-report-energy-ai-actions { display: grid; gap: 7px; }
.full-report-energy-ai-action { padding: 8px 9px; border: 1px solid #d8e7e0; border-radius: 9px; background: #fff; }
.full-report-energy-ai-action strong { display: block; color: var(--qice-ink); font-size: 11px; }
.full-report-energy-ai-action p { margin-top: 3px; }
.full-report-energy-ai-loading { margin: 9px 0 0; color: var(--qice-muted); font-size: 11px; line-height: 1.6; }
.full-report-energy-ai-loading[data-state="fallback"] { color: #7b5a20; }
.full-report-energy-panel[data-state="no_applicable_obstacle"] .full-report-energy-status { color: #336e59; background: #eef8f2; }
.full-report-energy-panel[data-state="pending_teacher_review"] .full-report-energy-status, .full-report-energy-panel[data-state="rule_unavailable"] .full-report-energy-status { color: #7b5a20; border-color: #e4c886; background: #fff8e8; }

.member-report-history-dialog {
  width: min(1280px, calc(100% - 24px));
  height: min(880px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
  border-color: #c9d9d2;
  background: var(--qice-bg);
}
body[data-entry-view="member"] { padding: 0; overflow: hidden; }
body[data-entry-view="member"] .member-report-history-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  border: 0;
  border-radius: 0;
}
body[data-entry-view="member"] .member-report-history-dialog::backdrop { background: var(--qice-bg); }
.member-dashboard-shell {
  display: grid;
  width: min(var(--qice-shell-max), calc(100% - (var(--qice-page-gutter) * 2)));
  height: 100%;
  min-height: 0;
  grid-template-columns: 190px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  margin: 0 auto;
}
.member-global-topbar {
  display: grid;
  width: 100%;
  min-height: 95px;
  grid-column: 1 / -1;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  justify-self: stretch;
  margin: var(--qice-header-top) 0 0;
  padding: 14px 18px;
  border: 1px solid rgba(217, 221, 216, .88);
  border-radius: var(--qice-radius-md);
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--qice-shadow-sm);
}
.member-global-brand {
  display: inline-flex;
  grid-column: 1;
  align-items: center;
  justify-self: start;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.member-global-brand img {
  width: 58px;
  height: 58px;
  border: 1px solid rgba(31, 107, 91, .16);
  border-radius: 15px;
  object-fit: cover;
  background: #f7f4ea;
  box-shadow: 0 7px 18px rgba(31, 107, 91, .16);
}
.member-global-brand strong {
  display: block;
  color: #173a32;
  font: 700 clamp(22px, 3vw, 31px)/1.2 "Songti TC", "Noto Serif TC", serif;
  letter-spacing: .08em;
}
.member-global-brand span span { display: block; margin-top: 3px; color: var(--qice-muted); font-size: 13px; }
.member-global-nav {
  display: flex;
  grid-column: 2;
  align-items: center;
  justify-self: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid #d7e2dd;
  border-radius: 999px;
  background: #f7faf8;
}
.member-global-nav a {
  display: inline-flex;
  min-width: 142px;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 11px 18px;
  border-radius: 999px;
  color: var(--qice-muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}
.member-global-nav a:hover { color: var(--qice-brand-dark); background: var(--qice-brand-soft); }
.member-global-nav a[aria-current="page"] { color: #fff; background: var(--qice-brand); }
.member-global-nav a:focus-visible { outline: 3px solid rgba(11, 107, 92, .18); outline-offset: 2px; }
.member-global-entry {
  display: inline-flex;
  min-height: 42px;
  grid-column: 3;
  align-items: center;
  justify-content: center;
  justify-self: end;
  padding: 9px 16px;
  border: 1px solid #b9d2c8;
  border-radius: 13px;
  color: var(--qice-brand-dark);
  background: #fff;
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}
.member-global-entry:hover, .member-global-entry:focus-visible { border-color: var(--qice-brand); background: var(--qice-surface-muted); outline: none; }
.member-dashboard-rail {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 22px 16px;
  color: #fff;
  background:
    radial-gradient(circle at 20% 100%, rgba(213, 154, 34, .18), transparent 17rem),
    linear-gradient(165deg, #084f45, #0b6b5c 65%, #075548);
}
.member-dashboard-nav { display: grid; gap: 7px; margin-top: 0; }
.member-dashboard-nav a {
  display: flex;
  min-height: 42px;
  align-items: center;
  padding: 9px 12px;
  border-radius: 10px;
  color: rgba(255, 255, 255, .76);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}
.member-dashboard-nav a:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.member-dashboard-nav a[aria-current="page"] { color: var(--qice-brand-dark); background: #fff; }
.member-dashboard-nav a:focus-visible { outline: 3px solid rgba(255, 255, 255, .3); outline-offset: 2px; }
.member-dashboard-rail-note { margin: auto 4px 0; color: rgba(255, 255, 255, .58); font-size: 9px; line-height: 1.6; }
.member-dashboard-main { display: flex; min-width: 0; min-height: 0; grid-column: 2; grid-row: 2; flex-direction: column; }
.member-center-dialog .member-dashboard-header { align-items: flex-start; flex: 0 0 auto; padding: 17px 22px; background: rgba(255, 255, 255, .82); }
.member-center-dialog .member-dashboard-header p { margin: 5px 0 0; color: var(--qice-muted); font-size: 12px; line-height: 1.5; }
.member-dashboard-body { flex: 1 1 auto; max-height: none; min-height: 0; padding: 18px; background: #f7f4ec; }
.member-dashboard-hero {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 21px 23px;
  border: 1px solid #d9e4df;
  border-radius: 16px;
  background:
    radial-gradient(circle at 8% 30%, rgba(213, 154, 34, .09), transparent 10rem),
    #fff;
  box-shadow: var(--qice-shadow-sm);
}
.member-dashboard-hero-logo { width: 88px; height: 88px; padding: 7px; border-radius: 50%; object-fit: contain; background: #f8f3e8; }
.member-dashboard-hero h3 { margin: 0 0 8px; color: var(--qice-ink); font: 700 24px/1.3 "Songti TC", "Noto Serif TC", serif; }
.member-dashboard-hero p { margin: 0; color: var(--qice-muted); font-size: 11px; line-height: 1.65; }
.member-decision-topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.member-decision-topic { padding: 6px 9px; border: 1px solid #c7dbd3; border-radius: 999px; color: var(--qice-brand-dark); background: var(--qice-surface-muted); font-size: 10px; font-weight: 750; }
.member-decision-topic.premium { border-color: #ead3a1; color: #815d16; background: #fff9eb; }
.member-new-chart-button { min-width: 170px; min-height: 48px; }
.member-dashboard-content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 14px; align-items: start; margin-top: 14px; }
.member-dashboard-account-stack { display: grid; gap: 14px; }
.member-center-summary { display: grid; gap: 14px; }
.member-center-card { min-width: 0; padding: 15px; border: 1px solid #d8e5df; border-radius: 13px; background: #fbfdfc; }
.member-center-card h3 { margin: 0 0 5px; color: var(--qice-brand-dark); font-size: 17px; }
.member-center-card p { margin: 0; color: var(--qice-muted); font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.member-profile-role { margin-top: 3px !important; color: #47665c !important; font-weight: 750; }
.member-display-name-form { margin-top: 13px; padding-top: 12px; border-top: 1px solid #e1ebe6; }
.member-display-name-form label { display: block; margin-bottom: 6px; color: #435b52; font-size: 10px; font-weight: 800; }
.member-display-name-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.member-display-name-control input { min-width: 0; min-height: 38px; padding: 7px 9px; }
.member-display-name-control .button { min-height: 38px; padding: 7px 12px; }
.member-profile-update-status { margin-top: 8px !important; padding: 8px 9px; border-radius: 8px; background: #f2f7f5; }
.member-profile-update-status[hidden] { display: none; }
.member-profile-update-status[data-kind="error"] { color: #762721; background: #fff0ee; }
.member-profile-update-status[data-kind="success"] { color: #215242; background: #edf8f3; }
.member-profile-update-status[data-kind="loading"] { color: #6a5225; background: #fff9e9; }
.member-plan-card { color: #fff; border-color: #2e6b5b; background: linear-gradient(145deg, #173f35, #246957); }
.member-plan-card .card-kicker { color: #f0cb88; }
.member-plan-card h3 { color: #fff; }
.member-plan-card p { color: rgba(255, 255, 255, .78); }
.member-plan-benefits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 12px; }
.member-plan-benefits[hidden] { display: none; }
.member-plan-benefit { position: relative; min-height: 42px; padding: 9px 8px 8px 27px; border: 1px solid rgba(255, 255, 255, .17); border-radius: 9px; color: rgba(255, 255, 255, .9); background: rgba(255, 255, 255, .06); font-size: 10px; font-weight: 700; line-height: 1.4; }
.member-plan-benefit::before { position: absolute; top: 9px; left: 9px; color: #f0cb88; content: "✓"; font-weight: 900; }
.member-plan-validity { margin-top: 12px !important; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .16); color: #f4d89f !important; font-weight: 800; }
.member-cloud-reports { min-width: 0; padding: 18px; border: 1px solid #d8e5df; border-radius: 14px; background: #fff; box-shadow: var(--qice-shadow-sm); }
.member-cloud-reports-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.member-cloud-reports-head h3 { margin: 0; color: var(--qice-brand-dark); font-size: 17px; }
.member-cloud-report-summary { display: flex; align-items: center; gap: 7px; }
.member-dashboard-report-count { min-width: 28px; color: var(--qice-brand); font-size: 22px; line-height: 1; text-align: right; }
.member-cloud-note { padding: 4px 7px; border-radius: 999px; color: #557269; background: var(--qice-surface-muted); font-size: 9px; font-weight: 750; white-space: nowrap; }
.member-center-footer { margin-top: 14px; padding-top: 12px; border-top: 1px solid #dde8e3; }
.member-center-footer p { margin: 7px 0 0; color: var(--qice-muted); font-size: 10px; line-height: 1.55; }
.member-center-footer [hidden] { display: none; }
.member-report-history-status {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--qice-line);
  border-radius: 10px;
  color: var(--qice-muted);
  background: #f7faf8;
  font-size: 12px;
  line-height: 1.55;
}
.member-report-history-status[hidden] { display: none; }
.member-report-history-status[data-kind="error"] { border-color: #e0aaa5; color: #762721; background: #fff0ee; }
.member-report-history-status[data-kind="success"] { border-color: #a9cec0; color: #215242; background: #edf8f3; }
.member-report-history-status[data-kind="loading"] { border-color: #d9c38e; color: #6a5225; background: #fff9e9; }
.member-report-history-list { display: grid; gap: 10px; }
.member-report-history-empty { margin: 0; padding: 32px 14px; color: var(--qice-muted); text-align: center; }
.member-report-history-empty h3 { margin: 0 0 7px; color: var(--qice-brand-dark); font-size: 16px; }
.member-report-history-empty p { max-width: 390px; margin: 0 auto; font-size: 11px; line-height: 1.65; }
.member-report-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  padding: 14px;
  border: 1px solid #d8e5df;
  border-radius: 12px;
  background: #fbfdfc;
}
.member-report-history-item:hover { border-color: #b8d0c6; background: #f7fbf9; }
.member-report-history-copy { min-width: 0; }
.member-report-history-copy h3 { margin: 0 0 5px; color: var(--qice-brand-dark); font-size: 14px; }
.member-report-history-question { margin: 0 0 5px; color: #43534d; font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.member-report-history-meta { margin: 0; color: var(--qice-muted); font-size: 10px; line-height: 1.5; }

.a4-report-dialog { width: min(900px, calc(100% - 20px)); max-height: calc(100vh - 20px); }
.a4-report-dialog .dialog-head { align-items: flex-start; }
.a4-report-dialog .dialog-head p { margin: 4px 0 0; color: var(--qice-muted); font-size: 11px; line-height: 1.5; }
.a4-report-toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.a4-report-body { padding: 18px; background: #e8eeeb; }
.a4-report-paper {
  position: relative;
  width: min(210mm, 100%);
  min-height: 297mm;
  margin: 0 auto;
  padding: 15mm 16mm 14mm;
  border: 1px solid #d6dfdb;
  color: #273a34;
  background: #fff;
  box-shadow: 0 12px 34px rgba(25, 55, 47, .15);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", "Arial Unicode MS", sans-serif;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.a4-report-watermarks { display: none; }
.a4-report-brand { display: flex; align-items: center; gap: 11px; padding-bottom: 7mm; border-bottom: 1px solid #cadbd4; }
.a4-report-logo { width: 18mm; height: 18mm; object-fit: contain; }
.a4-report-brand-copy strong { display: block; color: var(--qice-brand-dark); font-size: 20px; font-weight: 800; line-height: 1.25; letter-spacing: .04em; }
.a4-report-brand-copy span { display: block; margin-top: 3px; color: var(--qice-muted); font-size: 11px; letter-spacing: .1em; }
.a4-report-document-title { margin: 8mm 0 5mm; color: #173f35; font-size: 28px; font-weight: 800; line-height: 1.35; }
.a4-report-meta { display: grid; grid-template-columns: 24mm minmax(0, 1fr); margin: 0 0 8mm; border-top: 1px solid #dbe6e1; border-bottom: 1px solid #dbe6e1; }
.a4-report-meta dt, .a4-report-meta dd { margin: 0; padding: 2.7mm 3mm; border-bottom: 1px solid #e7eeeb; font-size: 12px; line-height: 1.65; }
.a4-report-meta dt { color: #46635a; background: #f2f7f5; font-weight: 800; }
.a4-report-meta dd { overflow-wrap: anywhere; }
.a4-report-meta dt:last-of-type, .a4-report-meta dd:last-of-type { border-bottom: 0; }
.a4-report-chart {
  margin: 0 0 8mm;
  padding: 4.5mm;
  border: 1px solid #d7e5df;
  border-radius: 2.2mm;
  background: #fbfdfc;
  break-inside: avoid;
  page-break-inside: avoid;
}
.a4-report-chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3.5mm;
  padding-bottom: 2.5mm;
  border-bottom: 1px solid #dbe6e1;
}
.a4-report-chart-head h2 { margin: 0; color: #173f35; font-size: 18px; line-height: 1.45; }
.a4-report-chart-kicker { display: block; margin-bottom: 1mm; color: #0b6b5c; font-size: 9px; font-weight: 850; letter-spacing: .12em; }
.a4-report-chart-status { margin: 0; color: #687a74; font-size: 10px; line-height: 1.5; text-align: right; }
.a4-report-chart-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 238mm;
  margin: 0 auto;
  border: 1px solid #dbe6e1;
  background: #fbfaf7;
  object-fit: contain;
}
.a4-report-chart-fallback {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid #8fa199;
  background: #8fa199;
}
.a4-report-chart-fallback[hidden], .a4-report-chart-image[hidden], .a4-report-chart[hidden] { display: none; }
.a4-report-chart-fallback-cell {
  display: grid;
  min-height: 31mm;
  padding: 3mm;
  align-content: start;
  gap: 1.5mm;
  color: #202c29;
  background: #fff;
  font-size: 10px;
  line-height: 1.45;
}
.a4-report-chart-fallback-cell.center { place-items: center; color: #0b6b5c; background: #f7f4ea; font-size: 16px; font-weight: 800; text-align: center; }
.a4-report-chart-fallback-name { color: #1d3e36; font: 800 12px/1.3 "Songti TC", "Noto Serif TC", serif; }
.a4-report-chart-fallback-line { display: grid; grid-template-columns: 12mm minmax(0, 1fr); gap: 1mm; }
.a4-report-chart-fallback-line strong { color: #708078; font-size: 9px; }
.a4-report-chart-fallback-line span { min-width: 0; overflow-wrap: anywhere; font-weight: 700; }
.a4-report-chart-fallback-note { margin: 3mm 0 0; color: #687a74; font-size: 9px; line-height: 1.55; }
.a4-report-sections { display: grid; gap: 6mm; }
.a4-report-sections article {
  --chapter-accent: #0b6b5c;
  --chapter-tint: #e8f4f0;
  overflow: hidden;
  padding: 0 0 5mm;
  border: 1px solid #d7e5df;
  border-top: 1.5mm solid var(--chapter-accent);
  border-radius: 2.2mm;
  background: #fff;
  break-inside: avoid;
  page-break-inside: avoid;
}
.a4-report-sections article[data-section="overallSituation"] { --chapter-accent: #0b6b5c; --chapter-tint: #e7f3ef; }
.a4-report-sections article[data-section="opportunity"] { --chapter-accent: #287d68; --chapter-tint: #eaf5f1; }
.a4-report-sections article[data-section="risk"] { --chapter-accent: #a94b45; --chapter-tint: #fbefed; }
.a4-report-sections article[data-section="timing"] { --chapter-accent: #28708c; --chapter-tint: #eaf3f7; }
.a4-report-sections article[data-section="directions"] { --chapter-accent: #6a6598; --chapter-tint: #f0eff8; }
.a4-report-sections article[data-section="actionStrategy"] { --chapter-accent: #a87520; --chapter-tint: #faf3e5; }
.a4-report-sections article[data-section="deepAnalysis"] { --chapter-accent: #465d56; --chapter-tint: #eef2f0; }
.a4-report-sections h2 {
  margin: 0 0 4mm;
  padding: 3.5mm 4.5mm;
  color: var(--chapter-accent);
  background: var(--chapter-tint);
  font-size: 19px;
  font-weight: 850;
  line-height: 1.45;
  letter-spacing: .025em;
  break-after: avoid;
  page-break-after: avoid;
}
.a4-report-sections p {
  margin: 0 0 4.5mm;
  padding: 0 4.5mm;
  color: #263c35;
  font-size: 14px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: break-word;
  orphans: 3;
  widows: 3;
}
.a4-report-sections p:last-child { margin-bottom: 0; }
.a4-report-disclaimer { margin: 9mm 0 0; padding-top: 4mm; border-top: 1px solid #dbe6e1; color: #687a74; font-size: 10px; line-height: 1.7; }

.upgrade-dialog { width: min(520px, calc(100% - 24px)); }
.upgrade-dialog .dialog-body { display: grid; gap: 14px; }
.upgrade-dialog-intro { margin: 0; color: var(--qice-muted); font-size: 13px; line-height: 1.7; }
.upgrade-feature-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.upgrade-feature-list li { padding: 10px; border: 1px solid #dce7e2; border-radius: 10px; color: #385047; background: var(--qice-surface-muted); font-size: 12px; }
.upgrade-safe-note { margin: 0; padding: 10px 12px; border-left: 3px solid var(--qice-premium); color: #6b572f; background: #fff9ec; font-size: 11px; line-height: 1.6; }
.checkout-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.checkout-option { display: grid; gap: 7px; padding: 13px; border: 1px solid #d8e5df; border-radius: 12px; background: #fbfdfc; }
.checkout-option h3 { margin: 0; color: var(--qice-brand-dark); font-size: 14px; }
.checkout-option p { margin: 0; color: var(--qice-muted); font-size: 10px; line-height: 1.55; }
.checkout-option strong { color: var(--qice-brand); font-size: 17px; }
.development-confirm { border-style: dashed; border-color: var(--qice-premium); color: #6b572f; background: #fff9ec; }
.site-footer { margin-top: 18px; padding: 13px 16px; border-top: 1px solid rgba(174, 187, 180, .55); color: var(--qice-muted); font-size: 10px; line-height: 1.6; text-align: center; }

dialog { border-color: var(--qice-line); background: #fff; box-shadow: 0 30px 80px rgba(28, 50, 43, .23); }
dialog::backdrop { background: rgba(25, 39, 35, .42); }
.history-item { background: #fbfdfb; }

.capture-dialog { width: min(760px, calc(100% - 20px)); }
.capture-dialog .dialog-head { align-items: flex-start; }
.capture-dialog .dialog-head h2 { margin-bottom: 4px; }
.capture-dialog .dialog-head p { max-width: 540px; margin: 0; color: var(--qice-muted); font-size: 12px; line-height: 1.5; }
.capture-body { display: grid; gap: 14px; }
.capture-preview-wrap { max-height: min(65vh, 720px); overflow: auto; border: 1px solid var(--qice-line); background: var(--qice-brand-soft); }
.capture-preview-wrap img { display: block; width: 100%; height: auto; -webkit-touch-callout: default; user-select: auto; }
.capture-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }
.capture-help { margin: 0; color: var(--qice-muted); font-size: 12px; text-align: center; }

@media (min-width: 1181px) {
  .chart-panel { height: 100%; }
}

@media (max-width: 520px) {
  .checkout-options { grid-template-columns: 1fr; }
  .member-center-summary { grid-template-columns: 1fr; }
  .member-cloud-reports-head { display: block; }
  .member-cloud-note { display: inline-flex; margin-top: 7px; }
  .member-report-history-item { grid-template-columns: 1fr; }
  .member-report-history-item .button { width: 100%; }
}

@media (max-width: 1180px) {
  .control-row { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .field.system-field, .gender-field, #calculateButton { grid-column: span 2; }
  .workspace { margin-top: 12px; }
}

@media (max-width: 1040px) {
  .topbar, .member-global-topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .product-nav, .member-global-nav { width: 100%; grid-column: 1 / -1; grid-row: 2; }
  .product-nav a { flex: 1 1 0; }
  .member-global-nav a { flex: 1 1 0; }
  .member-global-entry { grid-column: 2; grid-row: 1; }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .member-dashboard-shell { grid-template-columns: 160px minmax(0, 1fr); }
  .member-dashboard-content-grid { grid-template-columns: 1fr; }
  .member-dashboard-account-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { width: min(100% - 14px, var(--qice-shell-max)); padding-top: var(--qice-header-top); }
  .topbar { margin-bottom: 11px; padding: 11px 12px; border-radius: 13px; }
  .brand-mark { width: 44px; height: 44px; border-radius: 12px; }
  h1 { font-size: 20px; }
  .control-panel { padding: 14px; }
  .control-panel { max-height: none; overflow: visible; }
  .control-intro { margin-bottom: 12px; padding-bottom: 11px; }
  .control-intro h2 { font-size: 17px; }
  .control-intro p { font-size: 11px; }
  .control-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .field.system-field, .gender-field, #calculateButton { grid-column: 1 / -1; }
  .field label { font-size: 10px; }
  select, input { padding: 7px 7px; font-size: 13px; }
  .now-control { min-width: 0; padding: 7px 4px; font-size: 12px; }
  .chart-panel { padding: 10px 3px 17px; border-radius: 13px; }
  .chart-heading { margin-bottom: 11px; padding: 0 7px 7px; }
  .chart-heading h2 { font-size: 18px; }
  .chart-heading p { font-size: 11px; }
  .chart-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-actions .button { min-width: 0; padding: 6px 5px; }
  .summary-board { width: min(100%, 350px); grid-template-columns: minmax(0, 1fr) 102px; gap: 7px; padding: 8px; }
  .summary-grid { width: auto; grid-template-columns: 1fr; gap: 2px; }
  .summary-item { grid-template-columns: 48px minmax(0, 1fr); gap: 2px; padding: 1px 0; }
  .summary-label { font-size: 11px; }
  .summary-value { font-size: 11px; }
  .pillar-row { grid-template-columns: 42px repeat(4, minmax(20px, 1fr)); gap: 1px; }
  .pillar-label, .annotation-label { font-size: 11px; }
  .pillar-value { font-size: 14px; }
  .summary-facts { gap: 1px 5px; }
  .chart-annotations { width: auto; }
  .annotation-item { grid-template-columns: 36px minmax(0, 1fr); gap: 1px; }
  .annotation-value { font-size: 11px; }
  .motion-pattern { font-size: 13px; }
  .hidden-stem { font-size: 13px; }
  .chart-canvas-controls {
    display: grid;
    width: min(calc(100% - 14px), 390px);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin: 11px auto 0;
  }
  .chart-canvas-controls .button { min-width: 0; min-height: 34px; padding: 6px 4px; font-size: 11px; }
  .chart-canvas-controls .button[aria-pressed="true"] {
    border-color: var(--qice-brand);
    color: #fff;
    background: var(--qice-brand);
    box-shadow: 0 4px 10px rgba(31, 107, 91, .14);
  }
  .chart-canvas-status {
    display: block;
    width: min(calc(100% - 18px), 390px);
    margin: 7px auto 0;
    color: #60706b;
    font-size: 11px;
    line-height: 1.5;
    text-align: center;
  }
  .grid-wrap { width: min(100%, 348px); padding: 18px; }
  .grid-wrap.chart-shell {
    width: 100%;
    max-width: 100%;
    margin: 13px auto 9px;
    padding: 38px 36px 34px;
    overflow: hidden;
  }
  .grid-wrap.chart-shell .chart-stage { width: min(100%, 390px); min-width: 0; }
  .grid-wrap.chart-shell[data-chart-view="detail"] { padding: 40px; overflow: auto; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .chart-stage { width: 700px; min-width: 700px; }
  .palace { min-height: 0; padding: 4px 4px 3px; }
  .palace-head { min-height: 14px; margin-bottom: 1px; }
  .palace-name { font-size: 10px; }
  .palace-head-right { gap: 2px; }
  .palace-flags { gap: 2px; min-height: 12px; }
  .palace-flag { font-size: 9px; }
  .palace-flag.void .void-circle { font-size: 8px; }
  .score { width: 18px; min-width: 18px; height: 18px; font-size: 7px; }
  .palace-layers { height: calc(100% - 21px); gap: 0; }
  .grid-wrap.chart-shell[data-chart-view="overview"] .palace-layer { grid-template-columns: 0 minmax(26px, 1fr) max-content; column-gap: 1px; }
  .grid-wrap.chart-shell[data-chart-view="overview"] .palace-layers { grid-template-rows: repeat(3, minmax(22px, 1fr)); row-gap: 2px; }
  .grid-wrap.chart-shell[data-chart-view="overview"] .chart-stage { min-height: 306px; }
  .grid-wrap.chart-shell[data-chart-view="overview"] .palace { aspect-ratio: auto; }
  .layer-value { font-size: 13px; }
  .grid-wrap.chart-shell[data-chart-view="overview"] .layer-value { white-space: nowrap; overflow-wrap: normal; }
  .layer-stem { min-width: 11px; font-size: 12px; }
  .stem-token, .layer-value-marked { padding-bottom: 8px; }
  .component-marker { bottom: 0; font-size: 8px; }
  .palace-hidden { right: 3px; bottom: 8px; min-height: 6px; font-size: 6px; }
  .palace-tags { right: 3px; bottom: 1px; left: 3px; min-height: 6px; gap: 2px; overflow: hidden; white-space: nowrap; }
  .palace-tags .tag { font-size: 6px; }
  /* Detail keeps the fixed design canvas; overview uses the compact rules above. */
  .grid-wrap.chart-shell[data-chart-view="detail"] .palace { padding: 8px 9px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .palace-head { min-height: 22px; margin-bottom: 3px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .palace-name { font-size: 15px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .palace-head-right { gap: 5px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .palace-flags { gap: 4px; min-height: 18px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .palace-flag { font-size: 14px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .palace-flag.void .void-circle { font-size: 13px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .score { width: 28px; min-width: 28px; height: 28px; font-size: 10px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .palace-layers { height: calc(100% - 45px); gap: 2px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .palace-layer { grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 4px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .layer-value { font-size: 18px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .layer-stem { min-width: 0; font-size: 17px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .stem-token,
  .grid-wrap.chart-shell[data-chart-view="detail"] .layer-value-marked { padding-bottom: 10px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .hidden-ring .stem-token { padding-bottom: 0; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .component-marker { bottom: -1px; font-size: 10px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .hidden-ring .hidden-stem { font-size: 17px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .palace-tags { right: 8px; bottom: 3px; left: 8px; min-height: 12px; gap: 5px; overflow: visible; white-space: normal; }
  .grid-wrap.chart-shell[data-chart-view="detail"] .palace-tags .tag { font-size: 9px; }
  .capture-hint { display: block; }
  .side-stack { margin-top: 12px; }
  .side-stack { grid-template-columns: 1fr; }
  .free-preview-head { display: block; }
  .preview-badge { margin-top: 7px; }
  .locked-grid, .upgrade-feature-list { grid-template-columns: 1fr; }
  .locked-item { min-height: 48px; }
  .topbar-actions { align-items: flex-end; flex-direction: column-reverse; gap: 5px; }
  .product-nav { gap: 2px; padding: 3px; }
  .product-nav a { min-width: 0; min-height: 38px; padding: 8px 7px; font-size: 11px; }
  .member-report-history-dialog { width: 100%; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  .member-dashboard-shell { grid-template-columns: 1fr; grid-template-rows: auto auto minmax(0, 1fr); }
  .member-global-topbar { width: 100%; gap: 8px; margin: var(--qice-header-top) 0 0; padding: 10px 11px; border-radius: 13px; }
  .member-global-brand { gap: 9px; }
  .member-global-brand img { width: 44px; height: 44px; border-radius: 12px; }
  .member-global-brand strong { font-size: 20px; }
  .member-global-brand span span { display: none; }
  .member-global-nav { width: 100%; gap: 2px; padding: 3px; }
  .member-global-nav a { min-width: 0; min-height: 38px; flex: 1 1 0; padding: 8px 7px; font-size: 11px; }
  .member-dashboard-rail { grid-column: 1; grid-row: 2; }
  .member-dashboard-main { grid-column: 1; grid-row: 3; }
  .member-dashboard-rail { display: block; padding: 8px 10px 9px; }
  body[data-entry-view="member"] .member-dashboard-rail { padding-top: max(8px, env(safe-area-inset-top)); }
  .member-dashboard-rail-note { display: none; }
  .member-dashboard-nav { display: flex; gap: 4px; margin-top: 0; overflow-x: auto; scrollbar-width: none; }
  .member-dashboard-nav::-webkit-scrollbar { display: none; }
  .member-dashboard-nav a { min-width: 88px; min-height: 34px; justify-content: center; padding: 7px 9px; font-size: 10px; white-space: nowrap; }
  .member-center-dialog .member-dashboard-header { position: sticky; top: 0; z-index: 2; padding: 12px 14px; }
  .member-dashboard-header .card-kicker { display: none; }
  .member-dashboard-body { padding: 10px 8px 16px; }
  .member-dashboard-hero { grid-template-columns: 56px minmax(0, 1fr); gap: 11px; padding: 16px; }
  .member-dashboard-hero-logo { width: 56px; height: 56px; padding: 4px; }
  .member-dashboard-hero h3 { font-size: 20px; }
  .member-new-chart-button { width: 100%; grid-column: 1 / -1; }
  .member-dashboard-account-stack { grid-template-columns: 1fr; }
  .member-cloud-reports { padding: 14px; }
  .member-center-chip { min-height: 30px; padding: 3px 5px 3px 9px; }
  .member-center-chip-name { max-width: 92px; font-size: 10px; }
  .member-center-chip-plan { font-size: 8px; }
  .member-access-link, .member-global-entry { min-height: 34px; padding: 7px 9px; font-size: 10px; }
  .capture-dialog .dialog-head { padding: 12px; }
  .capture-dialog .dialog-body { padding: 10px; }
  .a4-report-dialog .dialog-head { display: grid; padding: 12px; }
  .a4-report-toolbar { justify-content: stretch; }
  .a4-report-toolbar .button { flex: 1 1 120px; }
  .a4-report-body { padding: 8px; }
  .a4-report-paper { min-height: calc((100vw - 54px) * 1.4143); padding: 7vw 6vw; }
  .a4-report-brand { padding-bottom: 4vw; }
  .a4-report-logo { width: 48px; height: 48px; }
  .a4-report-document-title { margin: 6vw 0 4vw; font-size: 21px; }
  .a4-report-meta { grid-template-columns: 70px minmax(0, 1fr); margin-bottom: 6vw; }
  .a4-report-sections { gap: 10px; }
  .a4-report-sections article { padding: 0 0 11px; }
  .full-report-status-card dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .full-report-actions { grid-template-columns: 1fr; }
  .full-report-actions .button.primary { grid-column: auto; }
}

@media (max-width: 390px) {
  .brand { gap: 9px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
  .grid-wrap { width: min(calc(100% - 52px), 300px); }
  .grid-wrap.chart-shell { padding-inline: 32px; }
  .grid-wrap.chart-shell[data-chart-view="detail"] { padding-inline: 16px; }
  .chart-actions .button { font-size: 10px; }
}

/* The form and report cards follow the reading order on every screen. */
body.qimen-page .app-shell > :is(.control-panel, .workspace, .hour-switcher, .site-footer) {
  width: min(100%, 880px);
  margin-inline: auto;
}
body.qimen-page .control-panel { padding: 0; border: 0; background: transparent; box-shadow: none; }
body.qimen-page .question-hero { margin: 0; padding: 48px 0 32px; border: 0; text-align: center; }
body.qimen-page .control-kicker[hidden] { display: none; }
body.qimen-page .control-mode { color: var(--qice-brand); font-size: 14px; font-weight: 650; }
body.qimen-page #questionHeroTitle {
  margin: 8px 0 16px;
  color: var(--qice-ink);
  font: 700 52px/1.1 var(--qice-font-sans);
}
body.qimen-page .question-hero-lead { margin: 0; color: var(--qice-muted); font-size: 19px; line-height: 1.6; }
body.qimen-page .question-card,
body.qimen-page .side-card {
  padding: clamp(20px, 4vw, 32px);
  border: 0;
  border-radius: 24px;
  background: var(--qice-surface);
  box-shadow: var(--qice-shadow-sm);
}
body.qimen-page[data-membership="active"] .question-card { border-top: 3px solid var(--qice-premium); }
body.qimen-page .question-setup { display: grid; gap: 8px; }
body.qimen-page #noteTitle,
body.qimen-page .question-offshore-notice { margin: 0; color: var(--qice-muted); font-size: 13px; line-height: 1.6; }
body.qimen-page #questionInput { padding: 6px 0; border: 0; background: transparent; font-size: 22px; }
body.qimen-page #questionInput::placeholder { color: var(--qice-muted); opacity: 1; }
body.qimen-page .question-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--qice-hairline);
}
body.qimen-page .option-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  color: var(--qice-ink-soft);
  background: var(--qice-fill-quiet);
  font: 500 14px/1.4 var(--qice-font-sans);
  cursor: pointer;
}
body.qimen-page .option-chip select { width: auto; padding-inline: 2px; border: 0; background: transparent; font: inherit; }
body.qimen-page #pickerTimeSummary { color: var(--qice-ink); font-variant-numeric: tabular-nums; }
body.qimen-page #calculateButton { min-height: 44px; margin-inline-start: auto; padding: 10px 28px; border-radius: var(--qice-radius-pill); }
body.qimen-page #advancedSettings { margin-top: 12px; }
body.qimen-page #advancedSettings summary {
  width: fit-content;
  min-height: 44px;
  padding-block: 12px;
  color: var(--qice-brand);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
body.qimen-page #advancedSettings p { margin: 8px 0; color: var(--qice-ink-soft); font-size: 14px; line-height: 1.6; }
body.qimen-page #advancedSettings > .field { margin-top: 16px; }
body.qimen-page .control-row { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 16px; }
body.qimen-page .system-field { grid-column: span 2; }
body.qimen-page :is(.question-card, .hour-switcher) :focus-visible {
  outline: 2px solid var(--qice-brand);
  outline-offset: 3px;
}
body.qimen-page :is(.workspace, .side-stack) { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
body.qimen-page .workspace { margin-top: 48px; }
body.qimen-page .side-stack { margin-top: 0; }
body.qimen-page .side-card h3 { font: 700 28px/1.3 var(--qice-font-sans); }
body.qimen-page .side-card .card-kicker { margin-bottom: 8px; font-size: 13px; letter-spacing: .04em; }
body.qimen-page .side-card > p { font-size: 14px; }
body.qimen-page .side-card button { min-height: 44px; }
body.qimen-page .free-score-metrics dd { font-size: 40px; }
body.qimen-page .side-card.paywall-card { background: var(--qice-brand-dark); }
body.qimen-page .paywall-card :is(.card-kicker, .locked-item span, .unlock-offer span, .unlock-price del),
body.qimen-page .paywall-card > p { color: var(--qice-brand-100); }
body.qimen-page .paywall-card #lockedReportPrice { color: var(--qice-premium-accent); font-size: clamp(26px, 4vw, 40px); }
body.qimen-page #unlockButton { border: 0; border-radius: var(--qice-radius-pill); color: var(--qice-brand-dark); background: white; }
body.qimen-page #unlockButton:focus-visible { outline: 2px solid white; outline-offset: 3px; }
body.qimen-page .hour-switcher { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-block: 40px; }
body.qimen-page .hour-switcher .button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: var(--qice-radius-pill);
  color: var(--qice-ink-soft);
  background: var(--qice-fill-quiet);
  text-decoration: none;
}
body.qimen-page .site-footer > p { margin: 12px 0 0; font-size: 12px; }

@media (max-width: 760px) {
  body.qimen-page .question-hero { padding: 32px 4px 24px; text-align: left; }
  body.qimen-page #questionHeroTitle { font-size: 34px; }
  body.qimen-page .question-hero-lead { font-size: 16px; }
  body.qimen-page .question-options { gap: 8px; }
  body.qimen-page #calculateButton { width: 100%; min-height: 50px; }
  body.qimen-page .control-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.qimen-page .workspace { margin-top: 32px; }
  body.qimen-page :is(.workspace, .side-stack) { gap: 20px; }
  body.qimen-page .hour-switcher .button { padding: 8px 12px; }
  body.qimen-page .hour-switcher a { flex-basis: 100%; }
}

@page { size: A4 portrait; margin: 15mm 16mm 14mm; }

@media print {
  html, body { width: auto; margin: 0; padding: 0; background: #fff; }
  body.printing-a4-report > * { display: none !important; }
  body.printing-a4-report #a4ReportDialog {
    position: static;
    display: block !important;
    width: auto;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
  }
  body.printing-a4-report #a4ReportDialog .dialog-head { display: none !important; }
  body.printing-a4-report #a4ReportDialog .a4-report-body { max-height: none; padding: 0; overflow: visible; background: #fff; }
  body.printing-a4-report .a4-report-paper { width: auto; min-height: 0; margin: 0; padding: 0; border: 0; box-shadow: none; }
  body.printing-a4-report .a4-report-watermarks {
    display: block;
    position: absolute;
    z-index: 0;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
  }
  body.printing-a4-report .a4-report-page-watermark {
    position: absolute;
    left: 50%;
    width: 92mm;
    height: 92mm;
    transform: translateX(-50%);
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body.printing-a4-report .a4-report-page-watermark img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: .13;
    filter: grayscale(100%) contrast(.72);
    mix-blend-mode: multiply;
  }
  body.printing-a4-report .a4-report-paper > *:not(.a4-report-watermarks) {
    position: relative;
    z-index: 1;
  }
  body.printing-a4-report .a4-report-brand { display: none; }
  /*
   * Classic report cover: the exported chart already contains the
   * question, timestamp, pillars, bureau and chart system. Hiding the
   * wrapper title/meta prevents duplicated information and gives the
   * complete chart the same full-page treatment as the reference PDF.
   */
  body.printing-a4-report .a4-report-document-title,
  body.printing-a4-report .a4-report-meta { display: none; }
  body.printing-a4-report .a4-report-chart {
    margin-bottom: 0;
    padding: 0;
    border: 0;
    background: transparent;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body.printing-a4-report .a4-report-chart-head { display: none; }
  body.printing-a4-report .a4-report-chart-image-frame {
    display: block;
    /* The source chart is 1080x1600 (1.48:1). 178mm fills the printable
       A4 width; its 263.7mm height stays inside the 268mm content area. */
    width: 178mm;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    overflow: visible;
  }
  body.printing-a4-report .a4-report-chart-image {
    display: block;
    width: 178mm;
    max-width: none;
    height: auto;
    max-height: none;
    border: 0;
  }
  body.printing-a4-report .a4-report-chart-fallback { break-inside: avoid; page-break-inside: avoid; }
  body.printing-a4-report .a4-report-sections { display: block; }
  body.printing-a4-report .a4-report-sections article:first-child {
    break-before: page;
    page-break-before: always;
  }
  body.printing-a4-report .a4-report-sections article {
    overflow: visible;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    break-inside: auto;
    page-break-inside: auto;
  }
  body.printing-a4-report .a4-report-sections article + article { margin-top: 6mm; }
  body.printing-a4-report .a4-report-sections h2 {
    border-top: 1.5mm solid var(--chapter-accent);
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: avoid;
    page-break-after: avoid;
  }
  body.printing-a4-report .a4-report-sections p {
    display: block;
    width: auto;
    break-inside: auto;
    page-break-inside: auto;
  }
  body.printing-a4-report .a4-report-disclaimer { break-inside: avoid; page-break-inside: avoid; }
}

