/* 微光日記：暖白、鼠尾草綠、深青灰；手機優先 */
:root {
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --sage: #91A894;
  --sage-soft: #E6ECE6;
  --main: #3D6664;
  --text: #394342;
  --muted: #5F6B69;
  --line: #DCDFD9;
  --danger: #A04A3F;
  --warn-bg: #FBEFE6;
  --radius: 14px;
  --vvh: 100vh;
  --serif: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", Georgia, serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
a { color: var(--main); }
h1, h2 { color: var(--main); line-height: 1.4; font-weight: 600; }
h1 { font-size: 1.6rem; margin: .4em 0 .6em; }
h2 { font-size: 1.1rem; margin: 0 0 .5em; }
p { margin: .5em 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
:focus-visible { outline: 3px solid var(--sage); outline-offset: 2px; }

/* 版面 */
.site-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(247, 246, 242, .94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--main); letter-spacing: .05em; }
.header-actions { display: flex; gap: 8px; }
.pill {
  font: inherit; font-size: .875rem;
  padding: 4px 12px; min-height: 36px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--main); cursor: pointer;
}
.pill.help { border-color: var(--sage); }
main { max-width: 640px; margin: 0 auto; padding: 8px 16px 32px; outline: none; }
.site-footer {
  max-width: 640px; margin: 0 auto;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: baseline;
}
.site-footer p { width: 100%; margin: 4px 0 0; }

/* 元件 */
.hero { padding: 16px 0 8px; }
.hero-art { display: block; width: 100%; max-width: 360px; height: auto; margin: 0 auto 4px; }
.hero h1 { font-size: 2rem; margin-bottom: .1em; letter-spacing: .08em; }
.tagline { color: var(--muted); font-weight: 600; margin-top: 0; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 16px 0;
}
.notice { border-left: 4px solid var(--sage); }
.notice-text { font-weight: 500; }
.notice ul { padding-left: 1.2em; margin: .5em 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 1rem; text-decoration: none;
  min-height: 48px; padding: 10px 20px;
  border-radius: 12px; border: 1px solid var(--main);
  background: var(--surface); color: var(--main); cursor: pointer;
}
.btn.primary { background: var(--main); color: #fff; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.wide { width: 100%; margin-top: 12px; }
.link-btn {
  font: inherit; background: none; border: none; padding: 4px 0;
  color: var(--main); text-decoration: underline; cursor: pointer;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0; }
.actions .muted { width: 100%; margin: 0; }
.actions.stack { flex-direction: column; }
.actions.stack .btn { width: 100%; }

.gate .check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; cursor: pointer; }
.gate input[type="checkbox"] { width: 22px; height: 22px; margin-top: 4px; accent-color: var(--main); flex: none; }
.gate .btn { width: 100%; margin-top: 8px; }

.day-summary { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.day-summary li { display: flex; align-items: center; gap: 12px; line-height: 1.4; }
.day-icon { flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--bg); }
/* 每日標題：插畫不加框，與標題融為一體 */
.day-icon.lg { width: 92px; height: 92px; border-radius: 0; background: none; margin: -8px -2px -8px -6px; }
.day-head { display: flex; align-items: center; gap: 2px; margin: .5em 0 .3em; }
.day-head h1 { margin: 0; }
.num {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--sage-soft); color: var(--main); font-size: .875rem; font-weight: 600;
}

progress {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 10px; border: none; border-radius: 999px;
  background: var(--sage-soft); color: var(--sage); overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--sage-soft); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--sage); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--sage); border-radius: 999px; }
.day-list, .review-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.day-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; min-height: 56px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--text);
}
.day-item .title { flex: 1; }
.chip {
  display: inline-block; font-size: .8rem; padding: 2px 10px; border-radius: 999px;
  background: var(--sage-soft); color: var(--main); white-space: nowrap;
}
.chip.none { background: #EEEEEA; color: var(--muted); }
.chip.done { background: var(--main); color: #fff; }
.review-list li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.review-list .chip { margin-left: 6px; }
.highlight { font-family: var(--serif); }

.day-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .9rem; padding-top: 8px; }
.day-nav a { text-decoration: none; padding: 6px 0; }

.verse { margin: 16px 0; padding: 18px 20px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); }
.verse blockquote { margin: 0; font-family: var(--serif); font-size: 1.15rem; line-height: 1.9; }
.verse figcaption { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .85rem; color: var(--muted); }
.verse .ref { color: var(--main); font-weight: 600; }
.guide { font-size: 1.02rem; }
.question { margin: 16px 0; padding: 12px 16px; border-left: 4px solid var(--sage); background: var(--sage-soft); border-radius: 0 10px 10px 0; }
.question p { margin: 4px 0 0; font-weight: 500; }
.label { font-size: .8rem; color: var(--main); font-weight: 600; letter-spacing: .05em; }

.editor { margin: 20px 0; }
.prompt { display: block; font-weight: 600; color: var(--main); }
textarea, input[type="text"] {
  width: 100%; font: inherit; font-size: 16px; /* 16px 以上避免 iOS 自動放大 */
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
textarea {
  line-height: 1.8; resize: vertical;
  min-height: 180px;
  /* 鍵盤彈出時隨可視高度縮小，游標附近保持可見；內容超過時於框內捲動 */
  max-height: calc(var(--vvh) - 150px);
  scroll-padding: 24px;
}
textarea:focus, input[type="text"]:focus { outline: none; border-color: var(--main); box-shadow: 0 0 0 3px var(--sage-soft); }
.editor-meta { display: flex; justify-content: flex-end; font-size: .85rem; color: var(--muted); margin-top: 4px; }
.count.near { color: var(--danger); font-weight: 600; }
.limit-msg { color: var(--danger); font-size: .875rem; margin: 2px 0; }
.save-row { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: .875rem; min-height: 28px; }
.save-status { color: var(--muted); }
.save-status.saved { color: var(--main); }
.save-status.failed { color: var(--danger); font-weight: 600; }
.alert { background: var(--warn-bg); border: 1px solid #E6C3AE; color: #6E3B2C; border-radius: 12px; padding: 12px 14px; margin: 12px 0; }

.moods { display: flex; flex-wrap: wrap; gap: 8px; }
.mood {
  font: inherit; font-size: .95rem; min-height: 44px; padding: 6px 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
}
.mood[aria-pressed="true"] { background: var(--main); border-color: var(--main); color: #fff; }
.note { margin-top: 14px; padding: 14px 16px; background: var(--sage-soft); border-radius: 12px; }
.note .verse { background: var(--bg); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.seg button { font: inherit; border: none; background: var(--surface); color: var(--main); padding: 6px 18px; min-height: 40px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--main); color: #fff; }
.card-img { display: block; width: 100%; max-width: 480px; height: auto; border-radius: 12px; border: 1px solid var(--line); }

dialog {
  width: min(520px, calc(100vw - 32px));
  border: none; border-radius: var(--radius); padding: 0;
  color: var(--text); background: var(--surface);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .18);
}
dialog::backdrop { background: rgba(57, 67, 66, .45); }
.dialog-body { padding: 20px; }
.helplines { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.helplines a {
  display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text);
}
.helplines strong { font-size: 1.3rem; color: var(--main); min-width: 3.2em; }
.dialog-body .btn { width: 100%; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  max-width: calc(100vw - 32px);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 720px) {
  .actions.stack { flex-direction: row; }
  .actions.stack .btn { width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
