:root {
  color-scheme: light;
  --paper: #f7f2e8;
  --ink: #221f1a;
  --muted: #6e675e;
  --line: #d9cdb9;
  --panel: #fffaf0;
  --accent: #b8323a;
  --accent-dark: #84242d;
  --gold: #b68a35;
  --blue: #2f5f78;
  --green: #58764f;
  --shadow: 0 18px 42px rgba(55, 42, 25, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', 'Noto Sans TC', system-ui, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(184, 50, 58, 0.1), transparent 34%),
    linear-gradient(225deg, rgba(47, 95, 120, 0.12), transparent 36%),
    var(--paper);
}

button,
textarea,
select,
input[type='text'] {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.reading-panel {
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.title-block {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: 0;
}


.language-switch {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: -8px 0 18px;
}

.language-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 14px;
  background: #fffdf8;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.language-button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.full {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

textarea,
select,
input[type='text'] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

textarea:focus,
select:focus,
input[type='text']:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 50, 58, 0.14);
}

.topic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.topic-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 0 15px;
  background: #fffdf8;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease;
}

.topic-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.preset-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-row {
  justify-content: center;
}

.preset,
.secondary-button,
.primary-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 0 15px;
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease;
}

.preset,
.secondary-button {
  background: #fffdf8;
  color: var(--ink);
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 800;
  min-width: 128px;
}

button:hover {
  transform: translateY(-1px);
}
button:active {
  transform: translateY(0);
}

.result-area {
  margin-top: 22px;
}

.empty-state {
  min-height: 220px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.58);
}

.empty-card {
  width: 112px;
  aspect-ratio: 2 / 3;
  border: 2px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 48px;
  color: var(--gold);
  background: #fffaf0;
  margin-top: 20px;
}

.question-summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.question-summary .question-line {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.45;
}

.topic-line {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.drawn-cards {
  margin-bottom: 18px;
}

.drawn-cards h2 {
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: 0;
}
.reading-summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.reading-summary h2,
.cards-grid h2 {
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: 0;
}

.question-line {
  margin: 0 0 14px;
  color: var(--muted);
}

.summary-text {
  margin: 0;
  line-height: 1.8;
  white-space: pre-line;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 32px;
  line-height: 1;
}

.stats-table-wrap {
  overflow-x: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.stats-table th,
.stats-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.stats-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.card-frame {
  min-height: 390px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, var(--accent));
  border-radius: 8px;
  background: #fffdf8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-top {
  min-height: 220px;
  padding: 18px;
  display: grid;
  align-content: space-between;
  background:
    linear-gradient(160deg, rgba(182, 138, 53, 0.18), transparent 54%),
    linear-gradient(20deg, rgba(47, 95, 120, 0.11), transparent 58%), #fff6e5;
  border-bottom: 1px solid var(--line);
}

.position-tag {
  justify-self: start;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--accent-dark);
}

.card-name h3 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

.card-name p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.card-body {
  padding: 16px;
  display: grid;
  gap: 14px;
}

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

.badge {
  border-radius: 999px;
  background: #f1eadb;
  color: var(--ink);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge.weight-1 {
  background: #ece9df;
}
.badge.weight-2 {
  background: #e4eddf;
}
.badge.weight-3 {
  background: #ddebf0;
}
.badge.weight-4 {
  background: #f0e4cf;
}
.badge.weight-5 {
  background: #f3d8d9;
  color: var(--accent-dark);
}

.meaning,
.believer-note {
  margin: 0;
  color: #3c352f;
  line-height: 1.75;
}

.section-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }
  .reading-panel {
    padding: 18px;
  }
  
.language-switch {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: -8px 0 18px;
}

.language-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 14px;
  background: #fffdf8;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.language-button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.control-grid {
    grid-template-columns: 1fr;
  }
  .action-row {
    justify-content: center;
  }

  .preset,
  .secondary-button,
  .primary-button {
    flex: 1 1 150px;
  }
  .card-frame {
    min-height: 0;
  }
}
.mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 46px;
  padding: 0 18px;
  background: #fffdf8;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease;
  flex: 1 1 180px;
}

.mode-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.manual-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 16px;
}

.manual-head {
  margin-bottom: 14px;
}

.manual-head h2 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: 0;
}

.manual-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.manual-grid {
  display: grid;
  gap: 12px;
}

.manual-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(110px, 0.7fr) minmax(
      160px,
      1fr
    );
  gap: 12px;
  padding: 12px;
  border: 1px solid #eadfce;
  border-radius: 8px;
  background: #fffaf0;
}

@media (max-width: 720px) {
  .manual-row {
    grid-template-columns: 1fr;
  }
}
.spread-note p {
  margin: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink);
  padding: 0 13px;
  font-weight: 600;
}
.summary-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.summary-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.copy-prompt-button {
  white-space: nowrap;
}

.copy-status {
  min-width: 56px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 720px) {
  .summary-head {
    display: grid;
  }
  .summary-actions {
    justify-content: flex-start;
  }
}
.prompt-copy-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  padding: 14px 0 0;
  flex-wrap: wrap;
}

@media (max-width: 720px) {
  .prompt-copy-panel {
    justify-content: center;
  }
}

.action-row {
  justify-content: center;
}
.prompt-copy-panel {
  justify-content: center;
  flex-wrap: wrap;
}
