﻿:root {
  --bg: #f3eadf;
  --ink: #1f2431;
  --muted: #6d706f;
  --line: #d6c2af;
  --accent: #8f3d2f;
  --accent-strong: #b6563d;
  --cool: #315c73;
  --paper: rgba(255, 251, 246, 0.9);
  --paper-strong: rgba(255, 253, 250, 0.98);
  --shadow: 0 22px 50px rgba(70, 41, 29, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(182, 86, 61, 0.16), transparent 28%),
    radial-gradient(circle at 80% 15%, rgba(49, 92, 115, 0.14), transparent 22%),
    linear-gradient(180deg, #efe2d2 0%, #f7f0e7 42%, #efe7dc 100%);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 75%);
}

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

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

.page-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
  position: relative;
  z-index: 1;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(240px, 380px);
  gap: 28px;
  align-items: center;
  margin-bottom: 28px;
}

.hero-copy {
  background: linear-gradient(140deg, rgba(255, 251, 246, 0.92), rgba(247, 237, 228, 0.88));
  border: 1px solid rgba(196, 167, 144, 0.55);
  border-radius: 36px;
  padding: 34px;
  box-shadow: var(--shadow);
}

.eyebrow,
.section-label,
.mini-label {
  margin-bottom: 10px;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.eyebrow,
.section-label {
  font-size: 0.76rem;
}

.mini-label {
  font-size: 0.72rem;
}

h1,
h2,
h3 {
  font-family: "Noto Serif TC", "PMingLiU", serif;
  line-height: 1.2;
}

h1 {
  font-size: clamp(2.3rem, 4vw, 4rem);
  margin-bottom: 14px;
}

h2 {
  font-size: clamp(1.35rem, 2vw, 2rem);
  margin-bottom: 0;
}

h3 {
  font-size: 1.45rem;
  margin-bottom: 10px;
}

.hero-lead {
  max-width: 760px;
  line-height: 1.8;
  font-size: 1.02rem;
  color: #4f514f;
  margin-bottom: 0;
}

.hero-orbit {
  height: 100%;
  min-height: 320px;
  position: relative;
  border-radius: 36px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, rgba(253, 244, 233, 0.95), rgba(240, 224, 206, 0.58) 40%, rgba(217, 194, 171, 0.3) 72%, rgba(49, 92, 115, 0.08) 100%);
  border: 1px solid rgba(196, 167, 144, 0.55);
  box-shadow: var(--shadow);
}

.hero-ring,
.bagua-compass,
.bagua-core {
  position: absolute;
  inset: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

.hero-ring-a {
  width: 250px;
  height: 250px;
  border: 2px solid rgba(143, 61, 47, 0.3);
  animation: spin 28s linear infinite;
}

.hero-ring-b {
  width: 216px;
  height: 216px;
  border: 14px solid transparent;
  background:
    linear-gradient(var(--paper-strong), var(--paper-strong)) padding-box,
    conic-gradient(from 0deg, #8f3d2f, #f1d1bc, #315c73, #ead2c1, #8f3d2f) border-box;
  animation: spinReverse 22s linear infinite;
  opacity: 0.95;
}

.bagua-compass {
  width: 248px;
  height: 248px;
}

.bagua-spoke {
  position: absolute;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: rgba(255, 250, 244, 0.82);
  border: 1px solid rgba(143, 61, 47, 0.18);
  box-shadow: 0 10px 24px rgba(58, 39, 28, 0.08);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.bagua-spoke::before {
  content: attr(data-sign);
  display: block;
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 3px;
  color: #2c3540;
}

.north { top: 6px; left: 50%; transform: translateX(-50%); }
.north-east { top: 32px; right: 28px; }
.east { top: 50%; right: 2px; transform: translateY(-50%); }
.south-east { right: 28px; bottom: 32px; }
.south { bottom: 6px; left: 50%; transform: translateX(-50%); }
.south-west { bottom: 32px; left: 28px; }
.west { top: 50%; left: 2px; transform: translateY(-50%); }
.north-west { top: 32px; left: 28px; }

.bagua-core {
  width: 98px;
  height: 98px;
  background:
    radial-gradient(circle at center, rgba(255, 247, 239, 0.96) 0 60%, rgba(224, 203, 180, 0.86) 61%, rgba(255, 255, 255, 0) 100%);
  box-shadow: 0 0 0 12px rgba(255, 249, 240, 0.55), 0 0 0 24px rgba(143, 61, 47, 0.08);
}

.bagua-yin-yang {
  position: absolute;
  inset: 50%;
  width: 62px;
  height: 62px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 26%, #fff8ef 0 10%, transparent 11%),
    radial-gradient(circle at 50% 74%, #202733 0 10%, transparent 11%),
    linear-gradient(180deg, #202733 0 50%, #fff8ef 50% 100%);
  box-shadow: 0 0 0 9px rgba(255, 248, 240, 0.88);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(340px, 1.2fr);
  gap: 22px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 22px;
}

.panel {
  background: var(--paper);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(198, 172, 149, 0.55);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 24px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 18px;
}

.compact-head {
  margin-bottom: 16px;
}

.status-pill,
.history-count {
  margin: 0;
  align-self: center;
  color: var(--cool);
  background: rgba(49, 92, 115, 0.1);
  border: 1px solid rgba(49, 92, 115, 0.16);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.84rem;
  font-weight: 700;
}

.intro-box {
  display: grid;
  gap: 8px;
  background: linear-gradient(180deg, rgba(255, 249, 240, 0.96), rgba(248, 236, 223, 0.82));
  border-radius: var(--radius-md);
  border: 1px solid rgba(226, 193, 166, 0.9);
  padding: 16px;
  line-height: 1.7;
  color: #5b5f5d;
  margin-bottom: 18px;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #3f4548;
}

input[type="text"],
textarea,
select {
  width: 100%;
  border: 1px solid rgba(198, 172, 149, 0.88);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  padding: 14px 16px;
  transition: border-color 180ms ease, transform 180ms ease, background 180ms ease;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(143, 61, 47, 0.8);
  background: rgba(255, 255, 255, 0.96);
  transform: translateY(-1px);
}

textarea {
  resize: vertical;
}

textarea[readonly] {
  background: rgba(252, 248, 242, 0.96);
}

.actions,
.result-top-actions,
.history-toolbar,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.tool-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
  font-weight: 700;
}

.primary-button:hover,
.secondary-button:hover,
.tool-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff9f4;
  box-shadow: 0 14px 22px rgba(143, 61, 47, 0.24);
  padding: 14px 22px;
}

.secondary-button {
  background: rgba(255, 248, 241, 0.9);
  color: var(--accent);
  border: 1px solid rgba(143, 61, 47, 0.18);
  padding: 13px 18px;
}

.tool-button {
  background: rgba(49, 92, 115, 0.08);
  color: var(--cool);
  border: 1px solid rgba(49, 92, 115, 0.16);
  padding: 11px 14px;
}

.tool-button.danger {
  background: rgba(143, 61, 47, 0.1);
  color: var(--accent);
  border-color: rgba(143, 61, 47, 0.18);
}

.primary-button:disabled,
.secondary-button:disabled,
.tool-button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.loading-state {
  display: grid;
  gap: 16px;
  padding: 18px;
  margin-top: 18px;
  background: linear-gradient(180deg, rgba(255, 248, 239, 0.98), rgba(248, 237, 226, 0.92));
  border: 1px dashed rgba(143, 61, 47, 0.28);
  border-radius: var(--radius-md);
}

.loading-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.loading-label,
.loading-text,
.prayer-label,
.prayer-text {
  margin-bottom: 0;
}

.loading-label {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 4px;
}

.loading-text {
  font-weight: 700;
  color: #493b33;
}

.prayer-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--accent);
}

.prayer-text {
  line-height: 1.9;
  color: #5a5048;
  font-size: 0.94rem;
}

.ritual-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.ritual-steps li {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(143, 61, 47, 0.14);
  background: rgba(255, 255, 255, 0.5);
  color: #7d746b;
  font-size: 0.85rem;
  text-align: center;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.ritual-steps li.active {
  background: rgba(143, 61, 47, 0.12);
  border-color: rgba(143, 61, 47, 0.34);
  color: var(--accent);
  transform: translateY(-1px);
}

.ritual-steps li.done {
  background: rgba(49, 92, 115, 0.12);
  border-color: rgba(49, 92, 115, 0.2);
  color: var(--cool);
}

.ritual-preview {
  display: grid;
  gap: 8px;
}

.ritual-lines-preview {
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  min-height: 150px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(143, 61, 47, 0.08);
}

.loading-orb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff6ef 0 50%, #2c313d 50% 100%);
  box-shadow: 0 0 0 6px rgba(143, 61, 47, 0.08);
  animation: pulse 1.2s ease-in-out infinite;
}

.empty-panel p:last-child {
  margin-bottom: 0;
  line-height: 1.8;
  color: var(--muted);
}

.result-head {
  margin-bottom: 22px;
}

.result-meta,
.hex-meta,
.hex-image,
.detail-text,
.empty-copy,
.record-summary-result,
.record-note,
.record-feedback,
.print-guidance {
  color: var(--muted);
  line-height: 1.75;
}

.guidance-banner {
  background: linear-gradient(135deg, rgba(143, 61, 47, 0.12), rgba(49, 92, 115, 0.08));
  border: 1px solid rgba(143, 61, 47, 0.1);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 18px;
}

.guidance-text {
  margin-bottom: 0;
  font-weight: 700;
  color: #463d38;
}

.hex-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.hex-card,
.detail-card {
  background: var(--paper-strong);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(198, 172, 149, 0.65);
  padding: 18px;
}

.warm-card {
  background: linear-gradient(180deg, rgba(255, 250, 246, 0.98), rgba(253, 241, 233, 0.94));
}

.cool-card {
  background: linear-gradient(180deg, rgba(250, 253, 255, 0.98), rgba(237, 245, 249, 0.92));
}

.hex-judgement {
  font-weight: 700;
  color: #443a35;
  line-height: 1.8;
}

.line-stack {
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  margin: 18px 0;
}

.line-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.line-symbol {
  width: 180px;
  height: 18px;
  position: relative;
  flex-shrink: 0;
}

.yang-line,
.yin-part {
  height: 100%;
  border-radius: 999px;
  background: #27303b;
}

.yin-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  height: 100%;
}

.yin-part {
  width: calc(50% - 7px);
}

.line-row.moving .yang-line,
.line-row.moving .yin-part {
  background: var(--accent);
}

.line-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: rgba(143, 61, 47, 0.08);
  color: var(--accent);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(49, 92, 115, 0.08);
  color: var(--cool);
  font-size: 0.8rem;
  font-weight: 700;
}

.detail-card {
  margin-top: 18px;
}

.detail-grid,
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.history-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.history-group {
  border: 1px solid rgba(198, 172, 149, 0.6);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(255, 253, 249, 0.78);
}

.history-group summary {
  list-style: none;
  cursor: pointer;
  padding: 15px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  color: #3d4448;
}

.history-group summary::-webkit-details-marker {
  display: none;
}

.history-group[open] summary {
  border-bottom: 1px solid rgba(198, 172, 149, 0.36);
}

.history-group-body {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.history-group-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.record-card {
  border: 1px solid rgba(198, 172, 149, 0.48);
  border-radius: var(--radius-md);
  background: rgba(255, 252, 247, 0.96);
  overflow: hidden;
}

.record-card.current {
  border-color: rgba(143, 61, 47, 0.44);
  box-shadow: inset 0 0 0 1px rgba(143, 61, 47, 0.12);
}

.record-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 14px;
}

.record-check {
  padding-top: 6px;
}

.record-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.record-summary-button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0;
  cursor: pointer;
}

.record-summary-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.record-date {
  font-size: 0.8rem;
  color: #8a8f93;
  margin-bottom: 0;
}

.record-question {
  margin-bottom: 6px;
  font-size: 1.02rem;
}

.record-summary-result {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.record-body {
  padding: 0 14px 14px 42px;
  border-top: 1px dashed rgba(198, 172, 149, 0.45);
  background: rgba(250, 246, 241, 0.75);
}

.record-body.hidden {
  display: none;
}

.record-note,
.record-feedback {
  margin-top: 12px;
  margin-bottom: 0;
  white-space: pre-wrap;
}

.record-legacy {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(49, 92, 115, 0.08);
  color: var(--cool);
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.record-action {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  background: rgba(49, 92, 115, 0.08);
  color: var(--cool);
}

.record-action.delete {
  background: rgba(143, 61, 47, 0.1);
  color: var(--accent);
}

.record-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.feedback-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 700;
}

.feedback-badge[data-status="應驗"] {
  background: rgba(30, 132, 73, 0.12);
  color: #1e8449;
}

.feedback-badge[data-status="部分應驗"] {
  background: rgba(243, 156, 18, 0.14);
  color: #b9770e;
}

.feedback-badge[data-status="未應驗"] {
  background: rgba(192, 57, 43, 0.12);
  color: #b03a2e;
}

.feedback-badge[data-status="仍在觀察"] {
  background: rgba(49, 92, 115, 0.12);
  color: var(--cool);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(30, 23, 19, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal.hidden,
.hidden {
  display: none !important;
}

.modal-card {
  width: min(720px, 100%);
  max-height: min(90vh, 920px);
  overflow: auto;
  background: rgba(255, 252, 247, 0.98);
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 80px rgba(35, 22, 14, 0.24);
  padding: 24px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  background: rgba(31, 36, 49, 0.94);
  color: #fff;
  padding: 14px 18px;
  border-radius: 999px;
  box-shadow: 0 16px 36px rgba(31, 36, 49, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.print-section {
  display: none;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes spinReverse {
  to {
    transform: translate(-50%, -50%) rotate(-360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

@media (max-width: 1080px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero-orbit {
    min-height: 240px;
  }

  .bagua-compass {
    width: 216px;
    height: 216px;
  }

  .bagua-spoke {
    width: 52px;
    height: 52px;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 16px, 1280px);
    padding-top: 16px;
  }

  .hero-copy,
  .panel,
  .modal-card {
    padding: 18px;
    border-radius: 22px;
  }

  .hex-grid,
  .detail-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .record-summary-top,
  .record-actions,
  .result-top-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .actions .primary-button,
  .actions .secondary-button,
  .result-top-actions .secondary-button,
  .tool-button,
  .record-action,
  .modal-actions .primary-button,
  .modal-actions .secondary-button {
    width: 100%;
  }

  .line-symbol {
    width: 132px;
  }

  .bagua-compass {
    width: 184px;
    height: 184px;
  }

  .bagua-spoke {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 0.82rem;
  }

  .bagua-spoke::before {
    font-size: 1rem;
  }

  .bagua-core {
    width: 82px;
    height: 82px;
  }

  .bagua-yin-yang {
    width: 50px;
    height: 50px;
  }

  .ritual-steps {
    grid-template-columns: 1fr 1fr;
  }

  .record-body {
    padding-left: 14px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .page-shell,
  .toast,
  .modal {
    display: none !important;
  }

  .print-section {
    display: block;
    width: 100%;
    padding: 24px;
  }

  .print-title {
    font-family: "Noto Serif TC", "PMingLiU", serif;
    font-size: 1.8rem;
    margin-bottom: 18px;
  }

  .print-item {
    page-break-inside: avoid;
    border-bottom: 1px solid #ccc;
    padding: 16px 0;
  }

  .print-date {
    color: #555;
    font-size: 0.9rem;
    margin-bottom: 4px;
  }

  .print-question {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 6px;
  }

  .print-result {
    color: #8f3d2f;
    font-weight: 700;
    margin-bottom: 8px;
  }

  .print-note,
  .print-guidance {
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 0.95rem;
  }
}


