:root {
  --bg: #fdf6ec;
  --ink: #3a2e1f;
  --muted: #7a6a53;
  --accent: #d97a3f;
  --accent-dark: #b85c26;
  --card-bg: #ffffff;
  --card-border: #e8ddc9;
  --focus-glow: #2f8f5b;
  --danger: #b03a2e;
  --safe-margin: 4vw;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  font-size: clamp(20px, 1.6vw, 30px);
  height: 100%;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  padding: var(--safe-margin);
}

#print-sheet { display: none; }

.screen {
  max-width: 1400px;
  margin: 0 auto;
}

.app-title {
  font-size: clamp(2.4em, 5vw, 3.4em);
  margin: 0 0 0.1em 0;
  color: var(--accent-dark);
  text-align: center;
}

.app-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 1.2em;
  margin: 0 0 0.8em 0;
}

.screen-title {
  font-size: clamp(1.8em, 4vw, 2.6em);
  margin: 0 0 0.15em 0;
  color: var(--accent-dark);
}

.screen-subtitle {
  color: var(--muted);
  margin: 0 0 0.6em 0;
  font-size: 1.1em;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

.settings-title {
  margin-top: 0.6em;
  font-weight: bold;
  color: var(--muted);
  font-size: 0.9em;
}

.option-card {
  display: flex;
  align-items: center;
  gap: 0.6em;
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  border-radius: 20px;
  padding: 0.6em 0.9em;
  cursor: pointer;
  min-height: 1.6em;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.option-card.display-only {
  cursor: default;
}

.option-icon {
  font-size: 1.8em;
  flex: 0 0 auto;
  width: 1.3em;
  text-align: center;
}

.option-text {
  flex: 1 1 auto;
}

.option-label {
  font-size: 1.15em;
  font-weight: bold;
}

.option-desc {
  color: var(--muted);
  font-size: 0.85em;
  margin-top: 0.15em;
}

.option-card.is-focused {
  border-color: var(--focus-glow);
  box-shadow: 0 0 0 6px rgba(47, 143, 91, 0.28);
  transform: scale(1.02);
  background: #f3fbf6;
}

.chip.chip-checked {
  border-color: var(--focus-glow);
  background: #f0faf3;
}

.back-btn {
  opacity: 0.85;
}

.danger-btn .option-label {
  color: var(--danger);
}

.note-text {
  color: var(--muted);
  font-size: 0.85em;
  line-height: 1.5em;
  padding: 0.4em 0.2em;
}

/* 螢幕焦點時的鍵盤可及性：隱藏原生外框，改用自訂樣式 */
.option-card:focus { outline: none; }

/* ---------- 列印預覽 ---------- */
.print-preview-box {
  background: #ffffff;
  color: #1a1a1a;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
  padding: 1.2em 1.4em;
  margin-bottom: 0.8em;
  font-size: 0.75em;
  line-height: 1.6em;
  text-align: left;
}

.print-preview-box h1 { font-size: 1.6em; margin: 0 0 0.2em 0; }
.print-preview-box h2 { font-size: 1.15em; margin-top: 1em; border-bottom: 2px solid #ccc; padding-bottom: 0.15em; }
.print-preview-box .print-disclaimer { background: #f3f3f3; padding: 0.5em; border-left: 4px solid #999; }
.print-preview-box .print-empty { color: #888; font-style: italic; }
.print-preview-box .print-total { font-weight: bold; margin-top: 0.5em; }
.print-preview-box .print-warning {
  color: #b03a2e;
  font-weight: bold;
  border: 2px solid #b03a2e;
  padding: 0.5em;
  margin-top: 0.5em;
}
.print-preview-box .print-footer { margin-top: 1.2em; font-size: 0.85em; color: #666; }
.print-preview-box ul { padding-left: 1.4em; }

/* ---------- 特留分不足警告 ---------- */
.warning-card {
  background: #fdeceb;
  border: 4px solid var(--danger);
  border-radius: 20px;
  padding: 0.7em 0.9em;
  margin-bottom: 0.3em;
  animation: warningShake 0.5s ease;
}

.warning-title {
  color: var(--danger);
  font-weight: bold;
  font-size: 1.25em;
  margin-bottom: 0.2em;
}

.warning-body {
  color: #7a2118;
  line-height: 1.5em;
}

.warning-scene {
  min-height: calc(100vh - 2 * var(--safe-margin));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5em;
  background: radial-gradient(ellipse at center, #fdeceb 0%, var(--bg) 75%);
  border-radius: 24px;
  padding: 2em 1em;
}

.warning-scene-icon {
  font-size: 5.5em;
  line-height: 1;
  animation: warningShake 0.6s ease infinite;
}

.warning-scene-icon-small {
  font-size: 2.6em;
  animation: none;
}

.warning-scene-title {
  color: var(--danger);
  font-size: clamp(1.8em, 4.5vw, 2.8em);
  font-weight: bold;
  margin: 0;
}

.warning-scene-body {
  color: #7a2118;
  font-size: 1.2em;
  max-width: 28em;
  line-height: 1.6em;
  margin: 0;
}

.warning-scene-actions {
  margin-top: 0.8em;
  width: 100%;
  max-width: 600px;
}

@keyframes warningShake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-4deg); }
  75% { transform: rotate(4deg); }
}

/* ---------- 閒置自動介紹畫面 ---------- */
.attract-screen {
  min-height: calc(100vh - 2 * var(--safe-margin));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.4em;
  animation: attractFade 0.5s ease;
}

.attract-icon {
  font-size: 6em;
  line-height: 1;
}

.attract-title {
  font-size: clamp(2em, 5vw, 3.2em);
  color: var(--accent-dark);
  margin: 0.2em 0 0 0;
}

.attract-body {
  font-size: 1.3em;
  color: var(--muted);
  max-width: 20em;
  margin: 0;
}

.attract-sample-screen {
  justify-content: flex-start;
  padding-top: 4vh;
  overflow: hidden;
}

.attract-sample-list {
  width: 100%;
  max-width: 900px;
  gap: 0.4em;
}

.attract-sample-list .option-card {
  cursor: default;
}

.print-preview-box.attract-doc {
  font-size: 1em;
  max-width: 900px;
  width: 100%;
  max-height: 56vh;
  overflow: hidden;
}

.attract-hint {
  position: fixed;
  bottom: 6vh;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 1.1em;
  color: var(--accent-dark);
  font-weight: bold;
  animation: attractPulse 1.8s ease-in-out infinite;
}

@keyframes attractFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes attractPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@media (max-width: 700px) {
  .option-label { font-size: 1em; }
}

/* ---------- 列印樣式 ---------- */
@media print {
  body * { visibility: hidden; }
  #print-sheet, #print-sheet * { visibility: visible; }
  #print-sheet {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 2em;
    font-family: "Microsoft JhengHei", "PingFang TC", sans-serif;
    color: #000;
  }
  #print-sheet h1 { font-size: 1.8em; margin-bottom: 0.2em; }
  #print-sheet h2 { font-size: 1.2em; margin-top: 1.2em; border-bottom: 2px solid #333; padding-bottom: 0.2em; }
  #print-sheet .print-disclaimer {
    background: #f0f0f0;
    padding: 0.6em;
    font-size: 0.85em;
    border-left: 4px solid #888;
  }
  #print-sheet .print-empty { color: #888; font-style: italic; }
  #print-sheet .print-total { font-weight: bold; margin-top: 0.6em; }
  #print-sheet .print-warning {
    color: #b03a2e;
    font-weight: bold;
    border: 2px solid #b03a2e;
    padding: 0.5em;
    margin-top: 0.6em;
  }
  #print-sheet .print-footer { margin-top: 2em; font-size: 0.8em; color: #555; }
  #print-sheet ul { line-height: 1.8em; }
}
