:root {
  --bg: #050505;
  --panel: #101010;
  --panel2: #17120f;
  --line: #5f471d;
  --text: #fff3cf;
  --muted: #c9ad72;
  --cinnabar: #ff4c00;
  --gold: #ffd700;
  --bright-yellow: #f0c649;
  --shadow: 0 24px 70px #0007;
}
* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: radial-gradient(
    circle at 15% 5%,
    #2b0b02 0,
    #0d0806 32%,
    var(--bg) 72%
  );
  color: var(--text);
  font-family: Inter, "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  min-height: 100vh;
}
.shell {
  max-width: 1440px;
  margin: auto;
  padding: 28px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.topbar h1 {
  font-size: 1.35rem;
  margin: 4px 0;
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.brand-logo-frame {
  display: block;
  flex: 0 0 28px;
  width: 28px;
  max-width: 28px;
  max-height: 18px;
  line-height: 0;
}
.brand-logo-frame img {
  display: block;
  width: 100%;
  max-width: 28px !important;
  max-height: 18px !important;
  object-fit: contain;
  height: auto;
}
.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--bright-yellow);
  font-weight: 800;
}
.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "compass chart"
    "controls controls";
  gap: 16px;
}
.right-col {
  display: contents;
}
.panel {
  background: linear-gradient(145deg, #17110fed, #080808f5);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.compass-panel {
  grid-area: compass;
  display: flex;
  flex-direction: column;
  min-height: 760px;
}
.controls {
  grid-area: controls;
}
.chart-panel {
  grid-area: chart;
}
.period {
  display: flex;
  justify-content: space-between;
  align-items: start;
}
.period strong {
  display: block;
  font-size: 3.3rem;
  line-height: 1;
}
.period span,
.period p {
  color: var(--muted);
  margin: 0;
}
.compass-wrap {
  --dial-size: min(88%, 440px);
  display: grid;
  place-items: center;
  position: relative;
  flex: 1;
  min-height: 370px;
}
.dial {
  width: var(--dial-size);
  aspect-ratio: 1;
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
  contain: layout paint;
  transform-origin: 50% 50%;
  will-change: transform;
  backface-visibility: hidden;
  background: repeating-conic-gradient(
    from -7.5deg,
    var(--cinnabar) 0 15deg,
    #df3f00 15deg 30deg
  );
  border: 2px solid var(--gold);
  box-shadow:
    inset 0 0 0 12px #9f2b00,
    inset 0 0 0 14px var(--gold),
    0 20px 45px #0007;
  transition: none;
}
.dial:after {
  content: "";
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  background: #b83200;
  border: 1px solid var(--gold);
}
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.member-state {
  color: var(--muted);
  font-size: 0.75rem;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dial:before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 5px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, #fff3cf 0 .24deg, transparent .24deg 1deg);
  -webkit-mask: radial-gradient(circle, transparent 0 86%, #000 87% 100%);
  mask: radial-gradient(circle, transparent 0 86%, #000 87% 100%);
  pointer-events: none;
}
.ticks span {
  position: absolute;
  inset: 5px;
  display: flex;
  justify-content: center;
  padding-top: 10px;
  font-weight: 900;
  color: var(--gold);
  z-index: 2;
  transform: rotate(calc(var(--i) * 15deg));
}
.ticks span.cardinal-point {
  color: var(--bright-yellow);
}
.ticks span b {
  position: absolute;
  top: 38px;
  font-size: 0.66rem;
  line-height: 1;
  color: #0a0805;
  background: var(--bright-yellow);
  border: 1px solid #6c2500;
  border-radius: 999px;
  min-width: 19px;
  padding: 3px 4px;
  transform: rotate(calc(var(--i) * -15deg));
}
.ticks span em {
  font-style: normal;
  transform: rotate(calc(var(--i) * -15deg));
  min-width: 1.25rem;
  padding: 2px 3px;
  border: 1px solid #ffd700aa;
  border-radius: 4px;
  background: #080604dd;
  box-shadow: 0 1px 4px #000b;
  font-size: 0.82rem;
  line-height: 1.05;
  text-align: center;
}
.luopan-crosshair {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 50%;
  width: var(--dial-size);
  aspect-ratio: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.luopan-crosshair i {
  position: absolute;
  display: block;
  background: #ff2418;
  box-shadow:
    0 0 1px #fff3cf,
    0 0 4px #ff2418;
  opacity: 0.92;
}
.crosshair-vertical {
  left: 50%;
  top: -3%;
  width: 1px;
  height: 106%;
  transform: translateX(-50%);
}
.crosshair-horizontal {
  left: -3%;
  top: 50%;
  width: 106%;
  height: 1px;
  transform: translateY(-50%);
}
.luopan-crosshair b {
  position: absolute;
  left: 50%;
  padding: 1px 4px;
  border: 1px solid #ff2418;
  border-radius: 999px;
  background: #080604e8;
  color: #ff5a45;
  font-size: 0.62rem;
  line-height: 1.2;
  transform: translateX(-50%);
}
.facing-mark {
  top: -7%;
}
.sitting-mark {
  bottom: -7%;
}
.needle {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: -8px;
  transform: translateX(-50%);
  filter: drop-shadow(0 4px 7px #000);
}
.needle i {
  display: block;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-bottom: 30px solid var(--bright-yellow);
}
.readout {
  position: absolute;
  z-index: 3;
  inset: 34%;
  border-radius: 50%;
  background: #0a0907;
  color: var(--bright-yellow);
  border: 2px solid var(--gold);
  display: grid;
  place-content: center;
  text-align: center;
  box-shadow: 0 0 30px #0008;
  transform-origin: 50% 50%;
  transition: none;
}
.readout strong {
  font:
    600 2.35rem Georgia,
    serif;
}
.readout span {
  font-size: 0.8rem;
  color: #d7ba72;
}
.level-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 66px;
  contain: layout;
  margin: 4px 0 12px;
  overflow: hidden;
}
.level-track {
  position: relative;
  width: 62px;
  height: 62px;
  flex: 0 0 62px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background:
    linear-gradient(transparent 49%, #f0c64955 49% 51%, transparent 51%),
    linear-gradient(90deg, transparent 49%, #f0c64955 49% 51%, transparent 51%),
    #090807;
  box-shadow: inset 0 0 14px #000a;
  overflow: hidden;
}
.level-track::after {
  content: "";
  position: absolute;
  inset: 20px;
  border: 1px solid #f0c64988;
  border-radius: 50%;
}
.level-bubble {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cinnabar);
  border: 2px solid #fff3cf;
  box-shadow: 0 2px 8px #000b;
  transform: translate(-50%, -50%);
}
.level-card.is-level .level-bubble {
  background: var(--bright-yellow);
  border-color: #fff9df;
  box-shadow: 0 0 12px #ffd700aa;
}
.level-copy {
  display: grid;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}
.level-copy > span,
.level-copy small {
  color: var(--muted);
  font-size: 0.7rem;
}
.level-copy strong {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.2;
  min-height: 1.2em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.level-copy small {
  display: block;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}
.level-card.is-level .level-copy strong {
  color: var(--bright-yellow);
}

/* Measurement overlay: stays fixed at the true compass centre while the dial rotates. */
.compass-wrap > .level-card {
  position: absolute;
  z-index: 12;
  top: 50%;
  left: 50%;
  width: 66px;
  height: 66px;
  min-height: 0;
  margin: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.compass-wrap > .level-card .level-copy {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.compass-wrap > .level-card .level-track {
  width: 66px;
  height: 66px;
  flex-basis: 66px;
  background-color: #0a0907;
}
.compass-panel > .readout {
  position: relative;
  z-index: 15;
  inset: auto;
  width: max-content;
  min-width: 138px;
  min-height: 48px;
  margin: 42px auto 10px;
  padding: 7px 16px 6px;
  border-radius: 999px;
  background: #0a0907;
  color: var(--bright-yellow);
  border: 2px solid var(--gold);
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  text-align: center;
  transform: none;
}
.compass-panel > .readout strong { font-size: 1.55rem; }
.compass-panel > .readout span { font-size: .75rem; }
.snapshot-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 9px; }
.snapshot-button { width: 100%; margin-top: 0; }
.snapshot-title { display: grid; gap: 6px; margin-top: 10px; color: var(--muted); font-size: .78rem; }
.snapshot-title input { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #0a0907; color: var(--text); }
.snapshot-title input:focus { outline: 2px solid var(--bright-yellow); outline-offset: 2px; }
@media (max-width: 680px) {
  .shell { padding: max(10px, env(safe-area-inset-top)) 10px max(18px, env(safe-area-inset-bottom)); }
  .topbar { margin-bottom: 10px; }
  .topbar h1 { font-size: 1.15rem; }
  .compass-panel { min-height: auto; }
  .compass-wrap { --dial-size: min(96vw, 520px); min-height: 0; aspect-ratio: 1; }
  .panel { padding: 14px 10px; }
  .facing-mark { top: -8%; }
  .sitting-mark { bottom: -8%; }
  .direction-cards { margin-bottom: 10px; }
}
@media (min-width: 681px) and (max-width: 1024px) {
  .shell { padding: 18px; }
  .compass-panel { min-height: 650px; }
  .compass-wrap { --dial-size: min(78vw, 510px); }
  .layout { gap: 12px; }
}
.direction-cards {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  text-align: center;
  margin: 5px 0 16px;
}
.direction-cards div {
  border: 1px solid #7b5a24;
  background: #0a0907;
  border-radius: 15px;
  padding: 13px;
}
.direction-cards span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}
.direction-cards strong {
  font-size: 1.8rem;
}
.direction-cards b {
  color: var(--gold);
}
button,
select,
input {
  font: inherit;
}
.primary,
.secondary,
.ghost {
  border-radius: 12px;
  min-height: 48px;
  font-weight: 800;
  cursor: pointer;
}
.primary {
  border: 1px solid var(--gold);
  background: var(--cinnabar);
  color: #fff6d6;
}
.secondary,
.ghost {
  margin-top: 9px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.secondary:hover,
.ghost:hover {
  border-color: var(--bright-yellow);
  color: var(--bright-yellow);
}
.ghost {
  margin: 0;
  padding: 0 16px;
}
.range-label {
  display: flex;
  justify-content: space-between;
  margin-top: 22px;
  color: var(--muted);
}
input[type="range"] {
  accent-color: var(--cinnabar);
  width: 100%;
  margin: 12px 0;
}
.hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 2px 0;
}
.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}
.section-head h2 {
  margin: 5px 0 0;
  font-size: 1.45rem;
}
.pill {
  padding: 7px 10px;
  border: 1px solid var(--bright-yellow);
  color: var(--bright-yellow);
  border-radius: 999px;
  font-size: 0.75rem;
}
.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 22px 0;
}
.fields label span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 7px;
}
select {
  width: 100%;
  background: #090807;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px;
}
.summary {
  border-top: 1px solid var(--line);
  padding-top: 17px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.summary span {
  color: var(--muted);
}
.legend {
  color: var(--muted);
  font-size: 0.75rem;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  background: #6b501f;
  border: 1px solid #6b501f;
  border-radius: 17px;
  overflow: hidden;
  margin-top: 20px;
}
.palace {
  background: #090807;
  min-height: 145px;
  padding: 13px;
  position: relative;
  display: grid;
  place-content: center;
  text-align: center;
}
.palace.center {
  background: linear-gradient(145deg, #d33f00, var(--cinnabar));
}
.pair {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 10px;
  display: flex;
  justify-content: space-between;
  font-size: 1.75rem;
  font-weight: 800;
}
.palace > strong {
  font:
    500 4rem Georgia,
    "Noto Serif TC",
    serif;
}
.palace small {
  position: absolute;
  bottom: 10px;
  left: 12px;
  color: var(--muted);
}
.methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
.methods div {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.methods span {
  font-size: 0.75rem;
  color: var(--bright-yellow);
  letter-spacing: 0.1em;
}
.methods strong {
  display: block;
  font-size: 1.2rem;
  margin: 7px 0;
}
.methods p {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0;
  line-height: 1.5;
}
dialog {
  max-width: 510px;
  background: #100c0a;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: #000a;
  backdrop-filter: blur(5px);
}
dialog button {
  float: right;
  border: 0;
  background: transparent;
  color: white;
  font-size: 1.8rem;
  cursor: pointer;
}
dialog p {
  color: #d3bc87;
  line-height: 1.7;
}
.auth-dialog { width: min(92vw, 440px); }
.member-dialog { width: min(94vw, 680px); }
.dialog-close { float: right; }
.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}
.auth-form[hidden] { display: none; }
.auth-form label { display: grid; gap: 7px; }
.auth-form label span { color: var(--muted); font-size: 0.82rem; }
.auth-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #080604;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}
.auth-form textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #080604;
  color: var(--text);
  padding: 12px;
  font: inherit;
}
.member-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 18px 0;
}
.member-tabs button {
  float: none;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #080604;
  color: var(--muted);
  font-size: 0.85rem;
}
.member-tabs button.active { border-color: var(--gold); color: var(--bright-yellow); }
.member-panel[hidden] { display: none; }
.member-note { margin: 0 0 14px; font-size: 0.82rem; }

.production-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem 1rem;
  margin-bottom: 0.65rem;
  font-size: 0.7rem;
  line-height: 1.45;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.production-footer nav a,
.member-benefits-link {
  color: var(--gold, #f0c649);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.usage-fine-print {
  max-width: 42rem;
  margin: 0 auto 0.65rem;
  color: #a99363;
  font-size: 0.7rem;
  line-height: 1.55;
}
.history-list { display: grid; gap: 10px; max-height: min(52vh, 440px); overflow: auto; }
.history-empty { padding: 22px; border: 1px dashed var(--line); border-radius: 12px; text-align: center; color: var(--muted); }
.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #080604;
}
.history-copy { min-width: 0; }
.history-copy strong, .history-copy span { display: block; }
.history-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-copy span { margin-top: 4px; color: var(--muted); font-size: 0.72rem; }
.history-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.history-actions button, .history-actions a {
  float: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 7px 9px;
  font-size: 0.72rem;
  text-decoration: none;
  cursor: pointer;
}
.auth-form input:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
.auth-form .primary { width: 100%; }
.google-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  border: 1px solid #d8d8d8;
  border-radius: 10px;
  background: #fff;
  color: #202124;
  font: 600 0.9rem Inter, system-ui, sans-serif;
  cursor: pointer;
}
.google-login span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #4285f4;
  font-size: 1rem;
  font-weight: 800;
}
.auth-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.72rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.text-button {
  float: none;
  justify-self: center;
  color: var(--muted);
  font-size: 0.78rem;
  text-decoration: underline;
}
.auth-status { min-height: 1.5em; margin-bottom: 0; font-size: 0.82rem; }
.auth-status.is-error { color: #ff8068; }
@media (max-width: 900px) {
  .shell {
    padding: 8px;
  }
  .layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "compass chart"
      "controls controls";
    gap: 8px;
    align-items: start;
  }
  .compass-panel {
    min-height: auto;
  }
  .compass-wrap {
    min-height: 0;
    aspect-ratio: 1;
  }
  .fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 520px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; max-width: 58%; }
  .brand-lockup { gap: 0.35rem; }
  .brand-logo-frame { flex-basis: 24px; width: 24px; max-width: 24px; max-height: 15px; }
  .brand-logo-frame img { max-width: 24px !important; max-height: 15px !important; }
  .member-state { order: 3; width: 100%; text-align: right; }
  .panel {
    padding: 10px;
    border-radius: 14px;
  }
  .compass-wrap {
    --dial-size: 100%;
    min-height: 0;
  }
  .dial {
    width: var(--dial-size);
  }
  .readout strong {
    font-size: 1.35rem;
  }
  .ticks span {
    padding-top: 6px;
  }
  .ticks span em {
    min-width: 0.95rem;
    padding: 1px 2px;
    font-size: 0.62rem;
  }
  .ticks span b {
    top: 27px;
    min-width: 16px;
    font-size: 0.56rem;
    padding: 2px 3px;
  }
  .luopan-crosshair b {
    font-size: 0.52rem;
  }
  .period strong {
    font-size: 2.2rem;
  }
  .direction-cards {
    gap: 4px;
  }
  .level-card {
    gap: 7px;
    height: 52px;
    margin: 3px 0 8px;
  }
  .compass-wrap > .level-card {
    width: 48px;
    height: 48px;
  }
  .compass-wrap > .level-card .level-track {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }
  .compass-panel > .readout {
    min-height: 42px;
    margin-top: -5px;
    padding: 6px 13px;
  }
  .level-track {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }
  .level-track::after {
    inset: 15px;
  }
  .level-bubble {
    width: 13px;
    height: 13px;
  }
  .level-copy > span,
  .level-copy small {
    font-size: 0.58rem;
  }
  .level-copy strong {
    font-size: 0.76rem;
  }
  .direction-cards div {
    padding: 6px;
  }
  .direction-cards strong {
    font-size: 1.2rem;
  }
  .direction-cards b {
    font-size: 0.68rem;
  }
  .palace {
    min-height: 88px;
    padding: 5px;
  }
  .palace > strong {
    font-size: 2.35rem;
  }
  .pair {
    left: 6px;
    right: 6px;
    top: 6px;
    font-size: 1.2rem;
  }
  .palace small {
    left: 6px;
    bottom: 6px;
    font-size: 0.62rem;
  }
  .action-row {
    grid-template-columns: 1fr;
  }
  .primary,
  .secondary,
  .ghost {
    min-height: 40px;
    font-size: 0.78rem;
  }
  .range-label,
  .hint,
  .external-link {
    font-size: 0.7rem;
  }
  .methods {
    grid-template-columns: 1fr;
  }
  .legend {
    display: none;
  }
}
