/* App controls and routes. Report typography and interactive charts live in reading.css. */
body { color: var(--text); }
:where(h1, h2, h3, p) { overflow-wrap: anywhere; }
h1, h2, h3 { line-height: 1.4; }
h1 { margin: 0 0 24px; font: 600 clamp(28px, 3.4vw, 38px)/1.35 var(--serif); }
h2 { margin: 24px 0 12px; font: 600 24px/1.45 var(--serif); }
h3 { margin: 20px 0 8px; font-size: 17px; }
p { margin: 8px 0; line-height: 1.8; }
svg { display: inline-block; width: 20px; height: 20px; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow, .fine, .muted { color: var(--muted); }
.eyebrow { display: block; margin-bottom: 8px; font-size: 13px; }
.fine { font-size: 13px; line-height: 1.75; }
.error { color: var(--danger); }
.btn, .text-action, .hero-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  background: var(--control-surface);
  color: var(--primary);
  font-size: 15px;
  font-weight: 550;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
}
.btn { width: 100%; margin-top: 12px; }
.btn.small { min-height: 44px; padding: 8px 12px; font-size: 14px; }
.btn.primary, .hero-action.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--secondary); }
.text-action { padding: 6px 0 6px 12px; background: transparent; border: 0; font-size: 14px; white-space: nowrap; }
.text-action svg { width: 16px; height: 16px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; }
.row { display: flex; align-items: center; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.box, .form-card, .auth-view, .settings-panel, .share-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--panel-shadow);
}
.box { margin: 16px 0; padding: 18px; }
.question { color: var(--text); font-size: 17px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }
label { display: block; color: var(--secondary); font-size: 14px; font-weight: 550; margin: 16px 0 6px; }
input, textarea, select {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  background: var(--control-surface);
  color: var(--text);
  line-height: 1.5;
}
textarea { min-height: 140px; resize: vertical; }
::placeholder { color: var(--muted); opacity: 1; }
input:disabled { border-color: var(--border); background: var(--surface-subtle); color: var(--muted); }
input[type=checkbox] { width: 17px; min-height: 0; height: 17px; flex: none; margin: 0; padding: 0; accent-color: var(--primary); }
.check { display: flex; align-items: center; gap: 9px; min-height: 44px; margin: 0; font-size: 14px; font-weight: 400; }
.form-card, .settings-panel, .auth-view { padding: clamp(20px, 3vw, 32px); }
.form-card > :first-child, .field > label:first-child { margin-top: 0; }
.form-card .btn.primary { margin-top: 24px; }
.form-card .field + .field { margin-top: 18px; }
.field-grid { display: grid; align-items: start; gap: 16px 20px; }
.field-grid .field + .field { margin: 0; }
.field-grid .field { min-width: 0; }
.form-card details { margin-top: 22px; }
details { padding: 10px 0; margin-top: 16px; border-top: 1px solid var(--border); }
summary { min-height: 44px; padding: 10px 0; cursor: pointer; color: var(--primary); font-size: 14px; }
summary::marker { color: var(--muted); }
details[open] > summary { margin-bottom: 4px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tag { min-height: 44px; padding: 6px 15px; border: 1px solid var(--border); border-radius: 24px; background: var(--surface-subtle); color: var(--secondary); font-size: 13px; }
.hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: clamp(265px, 25vw, 344px);
  overflow: hidden;
  padding: clamp(28px, 4vw, 60px);
  border-radius: var(--radius-lg);
  background: #eee6d4;
}
.hero-art, .hero-art img, .hero::after { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-art { z-index: -2; }
.hero-art img { display: block; object-fit: cover; object-position: 62% center; }
.hero::after { content: ""; z-index: -1; background: linear-gradient(90deg, #f5eddaeF 0%, #f5eddadc 29%, #f5edda45 53%, transparent 70%); }
.hero-copy { max-width: 380px; }
.hero h1 { margin: 0 0 10px; color: #203f32; font: 550 clamp(38px, 4.4vw, 64px)/1.25 var(--serif); letter-spacing: .065em; }
.hero-copy p { margin: 0; color: #354b3e; font-size: 15px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.hero-action { padding: 10px 16px; border: 1px solid #526d5f; background: #fffaf0eb; color: var(--primary); }
.hero-action svg { width: 18px; height: 18px; }
.home-examples { margin-top: clamp(28px, 3.6vw, 48px); }
.example-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.example-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  min-width: 0;
  padding: clamp(16px, 1.8vw, 24px);
  background: linear-gradient(150deg, rgb(253 243 222 / 96%), rgb(246 231 203 / 92%));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  color: var(--text);
  text-align: left;
}
.card-meta { display: flex; align-items: center; gap: 10px; color: var(--secondary); font-size: 13px; }
.card-icon { display: grid; flex: none; width: 38px; height: 38px; place-items: center; border-radius: 10px; color: var(--primary); background: var(--primary-soft); }
[data-kind=bazi] .card-icon, [data-kind=bazi_luck] .card-icon { color: var(--accent); background: var(--accent-soft); }
[data-kind=combined] .card-icon { color: #765d32; background: #ecdfbe; }
.card-meta > svg { margin-left: auto; width: 16px; height: 16px; color: var(--muted); }
.card-title { display: block; font: 600 20px/1.55 var(--serif); overflow-wrap: anywhere; }
.card-description { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: var(--secondary); font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.page-intro { margin: -10px 0 22px; color: var(--secondary); font-size: 15px; }
.record-list, .setting-links { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--panel-shadow); }
.record-row, .setting-link {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 14px 18px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  text-decoration: none;
}
.record-row + .record-row, .setting-link + .setting-link { border-top: 1px solid var(--border); }
.record-row:focus-visible, .setting-link:focus-visible { outline-offset: -4px; }
.record-copy { flex: 1; min-width: 0; }
.record-copy strong { display: block; font-size: 16px; font-weight: 550; overflow-wrap: anywhere; }
.record-copy small { display: block; margin-top: 3px; font-size: 13px; color: var(--muted); }
.record-row > svg, .setting-link > svg:last-child { width: 16px; height: 16px; flex: none; margin-left: auto; color: var(--muted); }
.record-state { color: var(--secondary); background: var(--surface-subtle); padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.record-state[data-state=completed] { color: var(--primary); background: var(--primary-soft); }
.record-state[data-state=failed] { color: var(--accent); background: var(--accent-soft); }
.settings-section { margin-top: 24px; }
.settings-section h2 { margin: 0 0 8px; font: 600 16px/1.6 var(--sans); }
.setting-link > svg:first-child { width: 19px; height: 19px; color: var(--primary); }
.setting-link.danger { color: var(--danger); }
.auth-heading, .account-identity { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-heading h1, .account-identity h1 { min-width: 0; margin: 0; font-size: 28px; }
.account-avatar { display: inline-grid; flex: none; width: 46px; height: 46px; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.account-avatar svg { width: 23px; height: 23px; }
.account-role { border-radius: 4px; padding: 2px 8px; color: var(--primary); background: var(--primary-soft); font-size: 12px; }
.auth-modes { display: flex; gap: 4px; padding: 4px; border-radius: var(--radius); background: var(--surface-subtle); }
.auth-modes button { flex: 1; min-height: 44px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--secondary); }
.auth-modes button[aria-pressed=true] { background: var(--control-surface); color: var(--primary); border-color: var(--border); font-weight: 600; }
.auth-view .btn { margin-top: 24px; }
.cast { text-align: center; }
.cast .btn { width: min(100%, 320px); }
.orb { position: relative; display: grid; place-items: center; width: min(230px, 80%); aspect-ratio: 1; margin: 24px auto; border: 1px solid var(--control-border); border-radius: 50%; background: var(--surface); }
.orb::before { content: ""; position: absolute; inset: 12px; border: 1px solid var(--border); border-radius: 50%; }
.hex { display: grid; gap: 7px; width: 76px; }
.hex .yao { position: relative; display: flex; height: 7px; gap: 10px; }
.yao i { flex: 1; background: var(--primary); }
.yao.moving::after { content: "•"; position: absolute; left: calc(100% + 5px); top: 50%; transform: translateY(-50%); color: var(--accent); }
.empty-yao { height: 7px; border: 1px dashed var(--control-border); }
.share-card { padding: 32px 24px; text-align: center; }
.share-card .hex { margin: 24px auto; }
.status { display: flex; align-items: center; gap: 10px; padding: 20px 0; color: var(--secondary); }
.credit-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  color: var(--secondary);
  font-size: .9rem;
}
.cast .credit-line { justify-content: center; }
.credit-tag {
  display: inline-block;
  margin-inline-start: .5em;
  padding-inline: .5em;
  border: 1px solid currentColor;
  border-radius: 5px;
  font-size: .85em;
  white-space: nowrap;
}
.credit-available { font-variant-numeric: tabular-nums; }
.credit-feedback {
  width: min(100%, 38rem);
  margin-block: 12px;
  padding: 12px 16px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--surface-subtle);
}
.cast .credit-feedback { margin-inline: auto; text-align: start; }
.clarification-card, .clarification-thread { margin-block: 16px; }
.clarification-card form { padding-bottom: 8px; }
.clarification-card label { margin-top: 4px; }
.clarification-options { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 8px 12px; }
.clarification-options button {
  min-height: 40px;
  padding: 6px 14px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  overflow-wrap: anywhere;
}
.clarification-options button[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.clarification-reply { padding-inline-start: 12px; border-inline-start: 2px solid var(--accent); }
.clarification-reply strong { margin-inline-end: .5em; }
.reading-overview .question-chart { margin: 0; padding: 0; border: 0; background: transparent; }
.question-chart > summary { min-height: 44px; padding-block: 10px; color: var(--primary); }
@media print { .clarification-card { display: none; } }
.credit-feedback input, .credit-wallet input { margin-block-end: 8px; }
.credit-wallet-link { position: relative; margin-block: 16px; }
.credit-wallet-link .setting-link { padding-inline-end: 18px; }
.credit-wallet-link > .credit-available { display: block; padding: 0 16px 12px; color: var(--secondary); font-size: .9rem; }
.credit-wallet dl { display: flex; flex-wrap: wrap; gap: 12px 40px; margin: 0 0 16px; }
.credit-wallet dt { color: var(--secondary); font-size: .9rem; }
.credit-wallet dd { margin: 0; font-size: 1.3rem; font-weight: 600; }
.credit-activity { list-style: none; padding: 0; }
.credit-activity li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.credit-activity li > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.credit-activity small, .credit-activity time { color: var(--secondary); font-size: .85rem; }
.spin { width: 18px; height: 18px; flex: none; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: turn .9s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }
@media (hover: hover) {
  .btn:hover, .hero-action:hover, .example-card:hover { border-color: var(--primary); background: var(--primary-soft); }
  .btn.primary:hover, .hero-action.primary:hover { color: var(--on-primary); background: var(--primary-hover); }
  .btn.danger:hover { color: white; background: #882a20; border-color: #882a20; }
  .text-action:hover { text-decoration: underline; text-underline-offset: 4px; }
  .record-row:hover, .setting-link:hover, .tag:hover { background: var(--surface-subtle); color: var(--primary); }
}
@media (min-width: 560px) {
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-wide { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .example-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .home .example-grid { grid-template-columns: 1fr; }
  .home .example-card { gap: 4px; }
}
@media (max-width: 560px) {
  .example-grid { grid-template-columns: 1fr; }
  .example-card { gap: 6px; }
  .hero { align-items: end; min-height: 300px; padding: 20px; }
  .hero-art img { object-position: 77% center; }
  .hero::after { background: linear-gradient(0deg, #f6eddb 0%, #f6eddbed 35%, #f6edda80 64%, transparent 86%); }
  .hero h1 { font-size: 38px; }
  .hero-copy p { font-size: 14px; }
  .hero-actions { margin-top: 16px; gap: 8px; }
  .hero-action { padding: 9px 13px; font-size: 14px; }
  .card-title { font-size: 18px; }
  .section-heading h2 { font-size: 22px; }
  .record-row { gap: 10px; padding: 12px; }
}
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
@media print { .btn, .text-action, form { display: none; } }
