:root {
  color-scheme: dark;
  --bg: #0a0f0c;
  --surface: #111914;
  --surface-raised: #162019;
  --surface-soft: #1b261e;
  --ink: #f4efe2;
  --muted: #a9b1a7;
  --faint: #6f7d72;
  --line: #2a382e;
  --line-strong: #405244;
  --gold: #d7ad58;
  --gold-bright: #f2ce79;
  --green: #78c79b;
  --red: #e08d82;
  --blue: #86aee0;
  --shadow: 0 24px 80px rgb(0 0 0 / 28%);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% -5%, rgb(71 104 75 / 28%), transparent 32rem),
    radial-gradient(circle at 95% 26%, rgb(113 76 33 / 18%), transparent 30rem),
    var(--bg);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: .18;
  background-image:
    linear-gradient(rgb(255 255 255 / 2%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 2%) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

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

button, select { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
.palace-card:focus-visible {
  outline: 3px solid rgb(242 206 121 / 60%);
  outline-offset: 3px;
}

a { color: inherit; }

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 8px;
  color: #171108;
  background: var(--gold-bright);
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0;
  border-bottom: 1px solid rgb(255 255 255 / 7%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--gold-bright);
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -.06em;
  background: linear-gradient(145deg, #243328, #111713);
  box-shadow: inset 0 0 0 4px rgb(0 0 0 / 16%);
}

.brand strong,
.brand small { display: block; }

.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; font-weight: 500; }
.brand small { margin-top: 2px; color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }

.service-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgb(15 23 18 / 78%);
  font-size: .78rem;
}

.service-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 4px rgb(255 255 255 / 4%);
}

.service-dot.ok { background: var(--green); box-shadow: 0 0 0 4px rgb(120 199 155 / 12%); }
.service-dot.bad { background: var(--red); box-shadow: 0 0 0 4px rgb(224 141 130 / 12%); }

.header-actions { display: flex; align-items: center; gap: 8px; }
.header-button {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgb(15 23 18 / 78%);
  font-size: .75rem;
}
.header-button:hover { border-color: var(--gold); color: var(--ink); }

.page-shell { width: min(1480px, calc(100% - 40px)); margin: 0 auto; }

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(290px, .75fr);
  gap: clamp(30px, 7vw, 110px);
  align-items: end;
  padding: clamp(44px, 8vw, 104px) 0 clamp(40px, 6vw, 78px);
}

.eyebrow,
.kicker {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.intro h1 {
  max-width: 900px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 7.2vw, 7.3rem);
  font-weight: 400;
  letter-spacing: -.055em;
  line-height: .92;
}

.intro h1 em { color: var(--gold-bright); font-weight: 400; }

.intro-copy {
  max-width: 510px;
  margin: 0 0 5px;
  color: var(--muted);
  font-size: clamp(.98rem, 1.45vw, 1.17rem);
  line-height: 1.75;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(370px, 470px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.input-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgb(17 25 20 / 91%);
  box-shadow: var(--shadow);
}

.input-panel { overflow: clip; }

.panel-heading {
  display: flex;
  gap: 15px;
  align-items: center;
  padding: 25px 26px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, rgb(42 63 47 / 62%), transparent 72%);
}

.step-number {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--gold-bright);
  font-family: Georgia, "Times New Roman", serif;
}

.panel-heading h2,
.empty-state h2,
.result-heading h2,
.section-title-row h3,
.dialog-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

.panel-heading h2 { font-size: 1.45rem; }

#chartForm { padding: 8px 26px 26px; }

fieldset {
  min-width: 0;
  margin: 0;
  padding: 22px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
}

legend {
  margin-bottom: 14px;
  padding: 0;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 750;
}

.form-grid { display: grid; gap: 14px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-wide { grid-column: 1 / -1; }

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 650;
}

.field small { display: block; margin-top: 5px; color: var(--faint); font-size: .7rem; text-align: right; }

input,
select,
textarea {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: #0b110d;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

input,
select { padding: 0 11px; }

textarea { min-height: 86px; padding: 10px 11px; line-height: 1.5; resize: vertical; }

input:hover,
select:hover,
textarea:hover { border-color: #526857; }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  outline: 0;
  background: #0d1510;
  box-shadow: 0 0 0 3px rgb(215 173 88 / 9%);
}

input:disabled,
select:disabled { cursor: not-allowed; opacity: .58; }

.conditional-block {
  margin: 18px 0 0;
  padding: 14px;
  border: 1px solid rgb(215 173 88 / 24%);
  border-radius: 12px;
  background: rgb(215 173 88 / 5%);
}

.conditional-hint { margin: 0 0 12px; color: #c9bea6; font-size: .77rem; line-height: 1.55; }

.advanced { border-bottom: 1px solid var(--line); }

.advanced > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  cursor: pointer;
  color: var(--gold-bright);
  font-size: .82rem;
  font-weight: 750;
  list-style: none;
}

.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::after { content: "+"; color: var(--muted); font-size: 1.1rem; }
.advanced[open] > summary::after { content: "−"; }
.advanced-body { padding: 0 0 20px; }

.advanced hr {
  margin: 20px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.check-field {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
  color: var(--muted);
  font-size: .78rem;
  cursor: pointer;
}

.check-field input { width: 17px; min-height: 17px; accent-color: var(--gold); }

.privacy-note {
  display: flex;
  gap: 11px;
  margin: 20px 0;
  padding: 13px;
  border-radius: 12px;
  color: var(--muted);
  background: rgb(255 255 255 / 3%);
  font-size: .75rem;
  line-height: 1.5;
}

.privacy-note > span { color: var(--green); font-size: 1.3rem; line-height: 1; }
.privacy-note p { margin: 0; }
.privacy-note strong { color: #cbd8cd; }

.form-actions { display: flex; align-items: center; gap: 12px; }

.primary-button,
.outline-button,
.text-button,
.icon-button {
  border: 0;
  color: inherit;
  background: none;
}

.primary-button {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 12px;
  color: #211707;
  background: linear-gradient(135deg, var(--gold-bright), #c7973f);
  font-weight: 850;
  box-shadow: 0 12px 32px rgb(174 121 33 / 16%);
}

.primary-button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; filter: saturate(.35); opacity: .7; transform: none; }

.text-button { padding: 11px 6px; color: var(--muted); font-size: .78rem; }
.text-button:hover { color: var(--ink); }

.form-status { min-height: 1.2em; margin: 12px 0 0; color: var(--muted); font-size: .75rem; }
.form-status.error { color: var(--red); }
.form-status.success { color: var(--green); }

.result-panel { min-height: 780px; padding: clamp(22px, 3.2vw, 42px); }

.empty-state {
  display: grid;
  min-height: 690px;
  max-width: 650px;
  margin: auto;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.empty-orbit {
  display: grid;
  width: 150px;
  height: 150px;
  margin-bottom: 30px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: radial-gradient(circle, rgb(215 173 88 / 18%), transparent 58%);
  box-shadow: inset 0 0 0 18px rgb(255 255 255 / 1.5%), 0 0 70px rgb(94 132 100 / 12%);
}

.empty-orbit::before,
.empty-orbit::after {
  position: absolute;
  width: 110px;
  height: 110px;
  border: 1px dashed rgb(215 173 88 / 30%);
  border-radius: 50%;
  content: "";
}

.empty-orbit::after { width: 72px; height: 72px; }
.empty-orbit span { color: var(--gold-bright); font-family: Georgia, "Times New Roman", serif; font-size: 2rem; }

.empty-state h2 { max-width: 550px; font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.04; }
.empty-state > p:not(.kicker) { max-width: 560px; margin: 18px 0 30px; color: var(--muted); line-height: 1.7; }

.empty-steps {
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  list-style: none;
}

.empty-steps li { display: flex; align-items: center; gap: 7px; font-size: .75rem; }
.empty-steps span { display: grid; width: 24px; height: 24px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--gold); }

.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.result-heading h2 { font-size: clamp(1.9rem, 4vw, 3.2rem); }
.muted { color: var(--muted); }
.result-heading .muted { margin: 8px 0 0; font-size: .85rem; }

.result-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.outline-button {
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--muted);
  font-size: .75rem;
}

.outline-button:hover { border-color: var(--gold); color: var(--ink); background: rgb(215 173 88 / 6%); }

.summary-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin: 24px 0 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgb(255 255 255 / 1.5%);
}

.summary-item { min-width: 0; padding: 15px 13px; border-right: 1px solid var(--line); }
.summary-item:last-child { border-right: 0; }
.summary-item small { display: block; margin-bottom: 5px; color: var(--faint); font-size: .65rem; letter-spacing: .06em; text-transform: uppercase; }
.summary-item strong { display: block; overflow: hidden; color: var(--ink); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }

.board-section { margin-top: 10px; }
.section-title-row { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.section-title-row h3 { font-size: 1.65rem; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--faint); font-size: .68rem; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.legend-dot.focus { background: var(--gold); }
.legend-dot.void { background: var(--blue); }
.legend-dot.horse { background: var(--red); }

.lac-thu-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  overflow: clip;
  background: var(--line);
  gap: 1px;
}

.palace-card {
  position: relative;
  min-width: 0;
  min-height: 192px;
  padding: 13px;
  border: 0;
  color: var(--ink);
  text-align: left;
  background: #101713;
  transition: background .16s ease, box-shadow .16s ease;
}

.palace-card:hover { z-index: 1; background: #172119; box-shadow: inset 0 0 0 1px rgb(215 173 88 / 35%); }
.palace-card.focus { background: linear-gradient(145deg, rgb(215 173 88 / 12%), #111914 65%); box-shadow: inset 0 0 0 1px rgb(215 173 88 / 55%); }
.palace-card.center { background: #0d130f; }

.palace-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 13px; }
.palace-location { min-width: 0; }
.palace-location strong { display: block; overflow: hidden; font-family: Georgia, "Times New Roman", serif; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.palace-location small { color: var(--faint); font-size: .61rem; }
.palace-number { display: grid; width: 27px; height: 27px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--gold); font-family: Georgia, "Times New Roman", serif; font-size: .78rem; }

.palace-main { display: grid; gap: 5px; }
.palace-main-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 7px; align-items: baseline; }
.palace-main-row span { color: var(--faint); font-size: .59rem; text-transform: uppercase; }
.palace-main-row strong { overflow: hidden; font-size: .74rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }

.palace-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.mini-tag { padding: 3px 6px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .56rem; }
.mini-tag.void { border-color: rgb(134 174 224 / 36%); color: #adc8e9; }
.mini-tag.horse { border-color: rgb(224 141 130 / 36%); color: #efafa6; }
.mini-tag.focus { border-color: rgb(215 173 88 / 40%); color: var(--gold-bright); }

.board-hint { margin: 10px 0 0; color: var(--faint); font-size: .66rem; text-align: center; }

.result-tabs {
  display: flex;
  gap: 3px;
  margin-top: 34px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
  background: #0c120e;
}

.result-tab {
  flex: 1 0 auto;
  padding: 9px 11px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}

.result-tab:hover { color: var(--ink); }
.result-tab.active { color: #241908; background: var(--gold); }

.tab-panels { padding-top: 20px; }
.tab-panel { animation: panel-in .2s ease; }

@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } }

.content-card {
  margin-bottom: 13px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgb(255 255 255 / 1.5%);
}

.content-card:last-child { margin-bottom: 0; }
.content-card h4 { margin: 0 0 10px; font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; font-weight: 500; }
.content-card > p { margin: 0; color: #c2c9c1; font-size: .8rem; line-height: 1.65; }
.content-card .meta { margin-top: 10px; color: var(--faint); font-size: .66rem; }

.verdict-card { border-color: rgb(215 173 88 / 30%); background: linear-gradient(135deg, rgb(215 173 88 / 8%), transparent 75%); }
.verdict-badge { display: inline-block; margin-bottom: 10px; padding: 4px 8px; border: 1px solid rgb(215 173 88 / 36%); border-radius: 999px; color: var(--gold-bright); font-size: .64rem; font-weight: 750; text-transform: uppercase; }

.evidence-grid,
.indicator-grid,
.audit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.evidence-item,
.indicator-item,
.audit-item { padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #0d140f; }
.evidence-item header,
.indicator-item header { display: flex; align-items: start; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.evidence-item strong,
.indicator-item strong { font-size: .76rem; }
.evidence-item p,
.indicator-item p,
.audit-item p { margin: 0; color: var(--muted); font-size: .7rem; line-height: 1.55; }
.evidence-item small,
.indicator-item small,
.audit-item small { color: var(--faint); font-size: .59rem; }

.stance { flex: 0 0 auto; padding: 2px 5px; border-radius: 999px; font-size: .54rem; }
.stance.support { color: #a7ddbd; background: rgb(120 199 155 / 12%); }
.stance.obstacle { color: #efada4; background: rgb(224 141 130 / 12%); }
.stance.mixed { color: #b6cae7; background: rgb(134 174 224 / 12%); }
.stance.neutral { color: var(--muted); background: rgb(255 255 255 / 6%); }

.simple-list { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: .75rem; line-height: 1.65; }
.simple-list li + li { margin-top: 5px; }

.hexagram-list,
.trace-list { display: grid; gap: 8px; }
.hexagram-row,
.trace-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 11px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #0d140f; }
.hexagram-number,
.trace-number { display: grid; width: 31px; height: 31px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--gold); font-family: Georgia, "Times New Roman", serif; font-size: .72rem; }
.hexagram-row strong,
.trace-row strong { display: block; margin-bottom: 3px; font-size: .76rem; }
.hexagram-row p,
.trace-row p { margin: 0; color: var(--muted); font-size: .68rem; line-height: 1.5; }

.warning-list { margin: 0; padding: 0; list-style: none; }
.warning-list li { margin-top: 7px; padding: 9px 11px; border-left: 2px solid var(--red); color: #d8b9b4; background: rgb(224 141 130 / 5%); font-size: .7rem; line-height: 1.5; }

.palace-dialog {
  width: min(720px, calc(100% - 28px));
  max-height: min(820px, calc(100vh - 40px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  color: var(--ink);
  background: #111914;
  box-shadow: 0 40px 140px rgb(0 0 0 / 70%);
}

.palace-dialog::backdrop { background: rgb(2 5 3 / 72%); backdrop-filter: blur(5px); }

.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { font-size: 1.6rem; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 1.5rem; }
.icon-button:hover { color: var(--ink); border-color: var(--gold); }
#palaceDialogBody { padding: 22px; overflow-y: auto; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.detail-item { padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: #0b110d; }
.detail-item small { display: block; margin-bottom: 4px; color: var(--faint); font-size: .61rem; text-transform: uppercase; }
.detail-item strong { display: block; color: #d8dfd7; font-size: .76rem; line-height: 1.45; }
.detail-wide { grid-column: 1 / -1; }

.account-dialog,
.history-dialog {
  width: min(900px, calc(100% - 28px));
  max-height: min(900px, calc(100vh - 36px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  color: var(--ink);
  background: #111914;
  box-shadow: 0 40px 140px rgb(0 0 0 / 70%);
  overflow: auto;
}
.history-dialog { width: min(1040px, calc(100% - 28px)); }
.account-dialog::backdrop,
.history-dialog::backdrop { background: rgb(2 5 3 / 76%); backdrop-filter: blur(5px); }
#accountGuestPanel,
#accountUserPanel,
#credentialPanel,
.history-dialog > :not(.dialog-heading) { margin-right: 22px; margin-left: 22px; }
#accountGuestPanel,
#accountUserPanel { padding: 22px 0; }
.account-notice { margin: 18px 22px 0; padding: 12px 14px; border: 1px solid rgb(224 141 130 / 35%); border-radius: 10px; color: #e7b5ae; background: rgb(224 141 130 / 7%); font-size: .78rem; }
.auth-tabs { display: flex; gap: 5px; margin-bottom: 20px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #0b110d; }
.auth-tab { flex: 1; padding: 10px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: .78rem; }
.auth-tab.active { color: #1b1408; background: var(--gold); font-weight: 800; }
.auth-form { display: grid; gap: 14px; }
.auth-form .compact-button { width: fit-content; }
.turnstile-slot { min-height: 65px; overflow: hidden; }
.turnstile-slot[hidden] { display: none; }
.compact-button { flex: none; min-width: 210px; justify-content: center; }
.account-explain { margin: 20px 0 0; color: var(--faint); font-size: .72rem; line-height: 1.6; }
.account-summary { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: center; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: #0c120e; }
.account-summary small,
.account-summary strong { display: block; }
.account-summary small { margin-bottom: 4px; color: var(--faint); font-size: .64rem; text-transform: uppercase; }
.account-section { display: grid; gap: 12px; margin-top: 18px; padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: rgb(255 255 255 / 1.5%); }
.account-section h3,
.account-section p { margin: 0; }
.account-section h3 { font-size: 1rem; }
.account-section p { color: var(--muted); font-size: .72rem; line-height: 1.55; }
.warning-check { color: #e6c88d; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.file-button { padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--muted); font-size: .75rem; cursor: pointer; }
.file-button:hover { border-color: var(--gold); color: var(--ink); }
.danger-zone { border-color: rgb(224 141 130 / 30%); }
.danger-button { width: fit-content; padding: 10px 13px; border: 1px solid rgb(224 141 130 / 55%); border-radius: 9px; color: #f3c0b9; background: rgb(224 141 130 / 8%); font-weight: 750; }
.danger-button:hover { background: rgb(224 141 130 / 16%); }
.credential-panel { margin-bottom: 20px; padding: 18px; border: 1px solid rgb(215 173 88 / 55%); border-radius: 14px; background: rgb(215 173 88 / 7%); }
.credential-panel h3 { margin: 0 0 6px; color: var(--gold-bright); }
.credential-panel p { margin: 0; color: var(--muted); font-size: .75rem; }
.credential-panel dl { display: grid; gap: 8px; margin: 16px 0; }
.credential-panel dl > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; padding: 9px; border-radius: 8px; background: #0b100d; }
.credential-panel dt { color: var(--faint); font-size: .68rem; }
.credential-panel dd { margin: 0; overflow-wrap: anywhere; color: #dce7dd; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .72rem; }
#accountStatus { margin: 0 22px 22px; }
.history-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 12px; }
.history-list { display: grid; gap: 9px; padding-bottom: 12px; }
.history-empty { padding: 36px 18px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.history-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #0c120e; }
.history-item h3 { margin: 0 0 5px; font-size: .92rem; }
.history-meta { display: flex; flex-wrap: wrap; gap: 7px; color: var(--faint); font-size: .65rem; }
.history-meta span { padding: 3px 6px; border-radius: 6px; background: rgb(255 255 255 / 4%); }
.history-item-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; align-content: center; }
.history-item-actions button { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: transparent; font-size: .68rem; }
.history-item-actions button:hover { color: var(--ink); border-color: var(--gold); }
#loadMoreHistoryButton { margin: 0 22px 4px; }
#historyStatus { margin: 8px 22px 22px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  max-width: min(390px, calc(100% - 40px));
  padding: 12px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--ink);
  background: #18231b;
  box-shadow: var(--shadow);
  font-size: .78rem;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  width: min(1480px, calc(100% - 40px));
  margin: 24px auto 0;
  padding: 24px 0 34px;
  color: var(--faint);
  border-top: 1px solid rgb(255 255 255 / 6%);
  font-size: .68rem;
}

.site-footer p { max-width: 620px; margin: 0; }

[hidden] { display: none !important; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(340px, 410px) minmax(0, 1fr); }
  .summary-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .summary-item { border-bottom: 1px solid var(--line); }
  .summary-item:nth-child(3n) { border-right: 0; }
  .summary-item:nth-last-child(-n + 3) { border-bottom: 0; }
  .palace-card { min-height: 178px; padding: 11px; }
  .palace-main-row { grid-template-columns: 48px minmax(0, 1fr); }
}

@media (max-width: 940px) {
  .intro { grid-template-columns: 1fr; gap: 24px; }
  .intro-copy { max-width: 700px; }
  .workspace { grid-template-columns: 1fr; }
  .input-panel { position: static; }
  .result-panel { min-height: 650px; }
  .empty-state { min-height: 560px; }
  .site-footer { flex-direction: column; gap: 8px; }
}

@media (max-width: 640px) {
  .site-header,
  .page-shell,
  .site-footer { width: min(100% - 24px, 1480px); }
  .site-header { padding: 15px 0; }
  .brand strong { font-size: .92rem; }
  .brand small { font-size: .61rem; }
  .brand-mark { width: 37px; height: 37px; }
  .header-actions { gap: 5px; }
  .header-button { padding: 8px 9px; font-size: .66rem; }
  .service-pill { padding: 8px; }
  #serviceText { position: absolute; width: 1px; height: 1px; clip: rect(0 0 0 0); overflow: hidden; }
  .intro { padding: 42px 0 34px; }
  .intro h1 { font-size: clamp(2.65rem, 15vw, 4.7rem); }
  .intro-copy { font-size: .93rem; }
  .input-panel,
  .result-panel { border-radius: 18px; }
  .panel-heading { padding: 20px; }
  #chartForm { padding: 4px 20px 22px; }
  .two-columns { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .text-button { order: 2; }
  .result-panel { min-height: 540px; padding: 20px 13px; }
  .empty-state { min-height: 480px; }
  .empty-orbit { width: 110px; height: 110px; }
  .empty-orbit::before { width: 82px; height: 82px; }
  .empty-orbit::after { width: 50px; height: 50px; }
  .empty-steps { display: grid; grid-template-columns: 1fr; justify-items: start; }
  .result-heading { align-items: stretch; flex-direction: column; }
  .result-actions { justify-content: flex-start; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-item:nth-child(3n) { border-right: 1px solid var(--line); }
  .summary-item:nth-child(2n) { border-right: 0; }
  .summary-item:nth-last-child(-n + 3) { border-bottom: 1px solid var(--line); }
  .summary-item:nth-last-child(-n + 2) { border-bottom: 0; }
  .section-title-row { align-items: flex-start; flex-direction: column; }
  .lac-thu-board { border-radius: 11px; }
  .palace-card { min-height: 153px; padding: 8px; }
  .palace-topline { margin-bottom: 9px; }
  .palace-location strong { font-size: .82rem; }
  .palace-location small { font-size: .53rem; }
  .palace-number { width: 23px; height: 23px; font-size: .66rem; }
  .palace-main { gap: 4px; }
  .palace-main-row { display: block; }
  .palace-main-row span { display: none; }
  .palace-main-row strong { display: block; font-size: .62rem; }
  .palace-tags { margin-top: 7px; }
  .mini-tag { font-size: .48rem; }
  .result-tabs { margin-top: 25px; }
  .result-tab { flex: 0 0 auto; }
  .evidence-grid,
  .indicator-grid,
  .audit-grid,
  .detail-grid { grid-template-columns: 1fr; }
  .detail-wide { grid-column: auto; }
  .palace-dialog,
  .account-dialog,
  .history-dialog { max-height: calc(100vh - 20px); }
  .account-summary { grid-template-columns: 1fr; }
  .credential-panel dl > div { grid-template-columns: 1fr; gap: 4px; }
  .history-item { grid-template-columns: 1fr; }
  .history-item-actions { justify-content: flex-start; }
  .site-footer { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
}

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

@media print {
  body { color: #111; background: #fff; }
  body::before,
  .site-header,
  .intro,
  .input-panel,
  .result-actions,
  .result-tabs,
  .site-footer,
  .board-hint { display: none !important; }
  .page-shell { width: 100%; }
  .workspace { display: block; }
  .result-panel { min-height: 0; padding: 0; border: 0; color: #111; background: #fff; box-shadow: none; }
  .palace-card,
  .content-card,
  .summary-strip { color: #111; background: #fff; border-color: #777; }
  .palace-main-row span,
  .muted,
  .content-card > p { color: #333; }
}
