/* 成功日記 — 日系雜誌風：米色紙感、明朝體、細線、留白；深色模式為星夜藍 */

/* ---------- 字型（App 內建，不連外部服務） ---------- */

@font-face {
  font-family: 'SJ Serif';
  src: url('../fonts/noto-serif-tc-500.woff2') format('woff2');
  font-weight: 400 600;
  font-display: swap;
}

@font-face {
  font-family: 'SJ Serif';
  src: url('../fonts/noto-serif-tc-700.woff2') format('woff2');
  font-weight: 700 900;
  font-display: swap;
}

@font-face {
  font-family: 'SJ Latin';
  src: url('../fonts/cormorant-500.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SJ Latin';
  src: url('../fonts/cormorant-500-italic.woff2') format('woff2');
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

/* ---------- 色彩（淺色：米色紙） ---------- */

:root {
  --bg: #f3ebdf;
  --paper: #f9f4ea;
  --ink: #2e2520;
  --ink-2: #4e4239;
  --muted: #74655a;
  --rule: #d6c8b6;
  --accent: #a85a38;
  --on-ink: #f3ebdf;
  --tape: rgba(214, 186, 150, 0.72);
  --day: #6f9478;
  --day-mix: 24%;
  /* 淺色：米白紙卡＋當日色條；深色：當日色彩融入夜空 */
  --day-card-bg: #fbf7f0;
  --day-card-top: 6px;
  --day-label: var(--day);
  --shadow: 0 18px 36px -24px rgba(50, 35, 25, 0.55);
  --grain-opacity: 0.55;
  --grain-blend: multiply;
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.27  0 0 0 0 0.2  0 0 0 0.12 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --stars: none;

  --serif: 'SJ Serif', 'Noto Serif TC', 'Noto Serif CJK TC', 'Songti TC', 'PMingLiU', serif;
  --latin: 'SJ Latin', 'SJ Serif', 'Cormorant Garamond', Georgia, serif;
  --tabbar-h: 66px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

/* 深色：星夜 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1d2238;
    --paper: #242a45;
    --ink: #efe7da;
    --ink-2: #d3cabc;
    --muted: #a9a3b2;
    --rule: #3b4268;
    --accent: #d9b871;
    --on-ink: #1d2238;
    --tape: rgba(217, 184, 113, 0.32);
    --day-mix: 32%;
    --day-card-bg: color-mix(in srgb, var(--day) 32%, var(--bg));
    --day-card-top: 0px;
    --day-label: var(--accent);
    --shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.8);
    --grain-opacity: 0.35;
    --grain-blend: screen;
    --stars: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><g fill='%23fff'><circle cx='22' cy='40' r='0.9' opacity='.7'/><circle cx='88' cy='12' r='0.6' opacity='.5'/><circle cx='150' cy='70' r='1.2' opacity='.8'/><circle cx='210' cy='30' r='0.7' opacity='.5'/><circle cx='290' cy='96' r='0.9' opacity='.6'/><circle cx='60' cy='150' r='0.6' opacity='.45'/><circle cx='130' cy='200' r='0.8' opacity='.6'/><circle cx='250' cy='180' r='1.3' opacity='.85'/><circle cx='30' cy='260' r='0.7' opacity='.5'/><circle cx='180' cy='290' r='0.6' opacity='.45'/><circle cx='300' cy='250' r='0.8' opacity='.55'/><circle cx='100' cy='300' r='1' opacity='.7'/></g></svg>");
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #1d2238;
  --paper: #242a45;
  --ink: #efe7da;
  --ink-2: #d3cabc;
  --muted: #a9a3b2;
  --rule: #3b4268;
  --accent: #d9b871;
  --on-ink: #1d2238;
  --tape: rgba(217, 184, 113, 0.32);
  --day-mix: 32%;
  --day-card-bg: color-mix(in srgb, var(--day) 32%, var(--bg));
  --day-card-top: 0px;
  --day-label: var(--accent);
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.8);
  --grain-opacity: 0.35;
  --grain-blend: screen;
  --stars: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><g fill='%23fff'><circle cx='22' cy='40' r='0.9' opacity='.7'/><circle cx='88' cy='12' r='0.6' opacity='.5'/><circle cx='150' cy='70' r='1.2' opacity='.8'/><circle cx='210' cy='30' r='0.7' opacity='.5'/><circle cx='290' cy='96' r='0.9' opacity='.6'/><circle cx='60' cy='150' r='0.6' opacity='.45'/><circle cx='130' cy='200' r='0.8' opacity='.6'/><circle cx='250' cy='180' r='1.3' opacity='.85'/><circle cx='30' cy='260' r='0.7' opacity='.5'/><circle cx='180' cy='290' r='0.6' opacity='.45'/><circle cx='300' cy='250' r='0.8' opacity='.55'/><circle cx='100' cy='300' r='1' opacity='.7'/></g></svg>");
  color-scheme: dark;
}

/* ---------- 基礎 ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg) var(--stars);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.8;
  letter-spacing: 0.04em;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 紙紋 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background-image: var(--grain);
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
  color: var(--ink);
}

p {
  margin: 0 0 0.9em;
}

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

.caps {
  font-family: var(--latin);
  text-transform: uppercase;
  letter-spacing: 0.26em;
}

.label-caps {
  font-family: var(--latin);
  text-transform: uppercase;
  letter-spacing: 0.26em;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 6px;
}

.small {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.75;
}

.lead {
  font-size: 15px;
  color: var(--ink-2);
  margin: 22px 0 18px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 22px;
}

.view {
  animation: fade 0.3s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* ---------- 刊頭 ---------- */

.mast {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 34px) 0 10px;
  border-bottom: 1.5px solid var(--ink);
}

.mast-title {
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0.26em;
  margin-right: -0.26em;
}

.mast-meta {
  margin: 0;
  font-size: 10.5px;
  text-align: right;
  line-height: 1.6;
}

.mast-sub {
  font-size: 12.5px;
  letter-spacing: 0.2em;
  color: var(--ink-2);
  margin: 10px 0 0;
}

/* ---------- 今日 ---------- */

.date-row {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
}

.date-label {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  cursor: pointer;
  padding: 2px 4px;
}

.date-big {
  font-family: var(--latin);
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.date-week {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--ink-2);
}

.date-picker {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  font-size: 16px;
}

.date-label:focus-within {
  outline: 1.5px solid var(--accent);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  font-family: var(--latin);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.text-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 14px;
  letter-spacing: 0.1em;
  padding: 6px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1px;
}

.go-today {
  display: block;
  margin: 4px 0 0 auto;
}

.day-card {
  position: relative;
  margin-top: 22px;
  padding: 28px 22px 20px;
  background: var(--day-card-bg);
  border-top: var(--day-card-top) solid var(--day);
}

.day-card .label-caps,
.day-detail .label-caps {
  color: var(--day-label);
}

.tape {
  position: absolute;
  left: 50%;
  top: -11px;
  width: 96px;
  height: 22px;
  margin-left: -48px;
  background: var(--tape);
  transform: rotate(-2deg);
  clip-path: polygon(0 8%, 6% 0, 12% 8%, 18% 0, 24% 8%, 30% 0, 36% 8%, 42% 0, 48% 8%, 54% 0, 60% 8%, 66% 0, 72% 8%, 78% 0, 84% 8%, 90% 0, 96% 8%, 100% 0, 100% 100%, 94% 92%, 88% 100%, 82% 92%, 76% 100%, 70% 92%, 64% 100%, 58% 92%, 52% 100%, 46% 92%, 40% 100%, 34% 92%, 28% 100%, 22% 92%, 16% 100%, 10% 92%, 4% 100%, 0 92%);
}

.affirmation {
  font-size: 21px;
  line-height: 1.75;
  letter-spacing: 0.06em;
  margin: 6px 0 14px;
}

.chakra-tag {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 12.5px;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  margin: 0;
}

.swatch,
.chakra-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  background: var(--day);
  flex: none;
}

#chakra-sep {
  margin: 0 6px;
  color: var(--muted);
}

.chakra-theme {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.16em;
  margin: 4px 0 0;
}

.prompt {
  margin-top: 26px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

.prompt-text {
  font-size: 15.5px;
  line-height: 1.85;
  margin: 0;
}

.wins {
  margin-top: 26px;
}

.section-title {
  font-size: 19px;
  letter-spacing: 0.14em;
  margin-bottom: 12px;
}

.wins .section-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

.win-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.win-list li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border-bottom: 1px solid var(--rule);
  padding: 8px 0 6px;
  transition: border-color 0.2s;
}

.win-list li:focus-within {
  border-bottom-color: var(--ink);
}

.win-num {
  font-family: var(--latin);
  font-size: 24px;
  line-height: 1.75;
  color: var(--accent);
  width: 30px;
  flex: none;
}

textarea {
  width: 100%;
  border: 0;
  background: transparent;
  resize: none;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.85;
  letter-spacing: 0.04em;
  padding: 6px 0;
  color: var(--ink);
}

textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

textarea:focus {
  outline: none;
}

.save-status {
  min-height: 1.5em;
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.note-card {
  position: relative;
  margin-top: 30px;
  padding: 10px 36px 10px 0;
  border-top: 1px solid var(--rule);
}

.note-card summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.note-card summary::-webkit-details-marker {
  display: none;
}

.note-card summary .label-caps {
  margin: 0;
  font-size: 10px;
  color: var(--muted);
}

.note-card summary::after {
  content: '＋';
  margin-left: auto;
  font-size: 12px;
}

.note-card details[open] summary::after {
  content: '－';
}

.note-card details > p:first-of-type {
  margin-top: 12px;
}

.note-close {
  position: absolute;
  right: 0;
  top: 6px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}


.note-card p {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.85;
}

.note-card strong {
  color: var(--ink);
  font-weight: 700;
}

/* ---------- 按鈕 ---------- */

.btn {
  display: block;
  width: 100%;
  text-align: center;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 12px 18px;
  font-size: 15px;
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: transform 0.12s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--ink);
  color: var(--on-ink);
}

.btn:disabled {
  opacity: 0.5;
}

.btn-stack {
  display: grid;
  gap: 10px;
  margin: 16px 0 14px;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.text-btn:focus-visible,
.chip:focus-visible,
.tool:focus-visible,
.cal-cell:focus-visible,
.tabbar button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 回顧 ---------- */

#view-calendar > .label-caps {
  margin-top: 24px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 4px 12px;
  background: color-mix(in srgb, var(--accent) 16%, var(--bg));
}

.stat:nth-child(2) {
  background: color-mix(in srgb, #6f9478 20%, var(--bg));
}

.stat:nth-child(3) {
  background: color-mix(in srgb, #9a7ba6 18%, var(--bg));
}

.stat-num {
  font-family: var(--latin);
  font-size: 40px;
  line-height: 1.05;
}

.stat-label {
  font-size: 11.5px;
  letter-spacing: 0.12em;
  color: var(--ink-2);
}

.stats-extra {
  font-size: 12.5px;
  color: var(--muted);
  margin: 10px 0 0;
  text-align: center;
}

.calendar {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1.5px solid var(--ink);
}

.month-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.month-title-wrap {
  text-align: center;
}

.month-en {
  font-size: 10.5px;
  margin: 0;
  color: var(--accent);
}

.month-title {
  font-size: 19px;
  letter-spacing: 0.14em;
}

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 6px;
}

.weekdays span {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 6px;
}

.cal-cell {
  justify-self: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: none;
  font-family: var(--latin);
  font-size: 17px;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}

.cal-cell.empty {
  cursor: default;
}

.cal-cell:disabled {
  opacity: 0.35;
  cursor: default;
}

.cal-cell.recorded {
  background: var(--dot);
  color: #fff;
}

.cal-cell.today {
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.cal-cell.recorded.today {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--ink);
}

.cal-cell.selected {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.legend {
  list-style: none;
  padding: 14px 0 0;
  margin: 16px 0 0;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--ink-2);
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.day-detail {
  margin-top: 24px;
  padding: 22px 20px;
  background: var(--day-card-bg);
  border-top: var(--day-card-top) solid var(--day);
}

.day-detail .section-title {
  font-size: 17px;
}

.day-detail .chakra-meta {
  display: flex;
  align-items: center;
  font-size: 12.5px;
  color: var(--ink-2);
}

.detail-list {
  margin: 14px 0 16px;
  padding-left: 0;
  list-style: none;
  counter-reset: win;
}

.detail-list li {
  counter-increment: win;
  display: flex;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 15%, transparent);
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-list li::before {
  content: '0' counter(win);
  font-family: var(--latin);
  color: var(--accent);
  font-size: 18px;
}

.detail-affirmation {
  font-size: 14px;
  color: var(--ink-2);
  margin-bottom: 16px;
}

/* ---------- 設定 ---------- */

.panel {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1.5px solid var(--ink);
}

.panel p {
  font-size: 14.5px;
}

.sub-title {
  font-size: 15px;
  letter-spacing: 0.1em;
  margin: 16px 0 4px;
}

.steps {
  margin: 0;
  padding-left: 1.3em;
  font-size: 14px;
  color: var(--ink-2);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 6px 0 16px;
}

.segmented label {
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  text-align: center;
  border: 1.5px solid var(--ink);
  padding: 9px 4px;
  font-size: 14px;
  letter-spacing: 0.1em;
}

.segmented label + label span {
  border-left: 0;
}

.segmented input:checked + span {
  background: var(--ink);
  color: var(--on-ink);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  cursor: pointer;
  margin: 6px 0 6px;
}

.switch-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

/* ---------- 底部分頁 ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 1.5px solid var(--ink);
}

.tabbar button {
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  line-height: 1.4;
}

.tab-en {
  font-family: var(--latin);
  font-style: italic;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.tab-zh {
  font-size: 14px;
  letter-spacing: 0.16em;
  margin-right: -0.16em;
}

.tabbar button[aria-selected='true'] {
  color: var(--ink);
}

.tabbar button[aria-selected='true'] .tab-zh {
  font-weight: 700;
}

.tabbar button[aria-selected='true'] .tab-en {
  color: var(--accent);
}

.tabbar button[aria-selected='true']::after {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 3px;
}

/* ---------- 提示訊息 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translate(-50%, 8px);
  max-width: calc(100% - 40px);
  background: var(--ink);
  color: var(--on-ink);
  padding: 10px 18px;
  font-size: 14px;
  letter-spacing: 0.06em;
  white-space: pre-line;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 60;
}

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

.noscript {
  text-align: center;
  padding: 20px;
}

/* ---------- 願景板清單 ---------- */

#new-board {
  margin-bottom: 26px;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px 16px;
}

.board-card {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--ink);
  text-align: left;
}

.board-card .board-stage.mini {
  width: 100%;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.board-card-title {
  display: block;
  margin-top: 10px;
  font-size: 14.5px;
  letter-spacing: 0.1em;
}

/* ---------- 願景板編輯器 ---------- */

.editor-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 14px 0 12px;
}

.editor-head .text-btn {
  align-self: flex-start;
}

.board-title-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: none;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.12em;
  padding: 4px 0 6px;
}

.board-title-input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.stage-wrap {
  display: flex;
  justify-content: center;
}

.board-stage {
  position: relative;
  width: min(100%, calc(66vh * 9 / 16));
  aspect-ratio: 9 / 16;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  box-shadow: var(--shadow);
}

.board-stage.has-selection {
  touch-action: none;
}

.board-stars,
.board-grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.board-grain {
  z-index: 1000;
  mix-blend-mode: multiply;
  opacity: 0.8;
}

.board-stage.dark .board-grain {
  mix-blend-mode: screen;
  opacity: 0.25;
}

.board-item {
  position: absolute;
  transform-origin: center center;
  touch-action: none;
  cursor: grab;
}

.board-item.locked {
  pointer-events: none;
}

.board-item img,
.board-item svg {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.board-item.type-photo {
  overflow: hidden;
  background: #fffdf8;
}

.board-item.type-photo img {
  object-fit: cover;
}

.board-item.shadow {
  box-shadow: 0 10px 24px -12px rgba(40, 28, 20, 0.55);
}

.board-item.empty-slot {
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

.board-item.empty-slot::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1.5px dashed currentColor;
  opacity: 0.45;
}

.board-stage .empty-slot {
  background: color-mix(in srgb, currentColor 6%, transparent);
}

.slot-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  letter-spacing: 0.14em;
  opacity: 0.75;
  pointer-events: none;
}

.slot-hint b {
  font-family: var(--latin);
  font-weight: 400;
  font-size: 2.4em;
  line-height: 1;
}

.board-item.type-text {
  white-space: nowrap;
  border-style: solid;
  border-width: 0;
}

.text-inner .num {
  display: inline-block;
}

.text-inner.vertical {
  display: flex;
  flex-direction: row-reverse;
  height: 100%;
}

.text-inner.vertical > div {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.text-inner.vertical span {
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-item.selected {
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
  z-index: 999;
}

.selection-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 14px 0 0;
}

.selection-bar button,
.chip {
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  padding: 6px 13px;
  font-size: 13.5px;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.selection-bar .danger,
.text-btn.danger {
  color: #b0503f;
}

.gesture-hint {
  text-align: center;
  margin: 10px 0 0;
}

.tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0 0;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: 14.5px;
  letter-spacing: 0.12em;
  line-height: 1.4;
  cursor: pointer;
}

.tool-en {
  font-family: var(--latin);
  font-style: italic;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.tool[aria-expanded='true'] {
  background: var(--ink);
  color: var(--on-ink);
}

.tool[aria-expanded='true'] .tool-en {
  color: var(--on-ink);
}

.tool:disabled {
  opacity: 0.35;
  cursor: default;
}

.tool-panel {
  margin: 12px 0 0;
  padding: 16px 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  animation: fade 0.2s ease;
}

.tool-panel textarea {
  border-bottom: 1px solid var(--ink);
  font-size: 16px;
}

.tool-panel .btn {
  margin-top: 12px;
}

.panel-label {
  margin-top: 18px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip[aria-pressed='true'] {
  background: var(--ink);
  color: var(--on-ink);
}

.chip-soft {
  border-color: var(--rule);
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  color: #2e2520;
}

.sticker-grid.dark {
  color: #efe7da;
}

.sticker-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 0;
  background: none;
  padding: 8px 2px 6px;
  font-size: 11.5px;
  color: inherit;
  cursor: pointer;
}

.sticker-prev {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
}

.sticker-prev img,
.sticker-prev svg {
  max-width: 100%;
  max-height: 100%;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.template-btn {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--ink);
  font-size: 13.5px;
  letter-spacing: 0.1em;
}

.template-btn .board-stage.mini {
  width: 100%;
  pointer-events: none;
  margin-bottom: 6px;
}

.template-btn small {
  display: block;
  font-family: var(--latin);
  font-style: italic;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.14em;
}

.template-btn[aria-pressed='true'] .board-stage {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.palette-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}

.palette-btn {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-align: left;
}

.pal-swatch {
  position: relative;
  display: block;
  height: 52px;
  margin-bottom: 4px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 15%, transparent);
}

.pal-swatch i:first-child {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 52%;
}

.pal-swatch i:last-child {
  position: absolute;
  right: 8px;
  bottom: 7px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
}

.palette-btn[aria-pressed='true'] .pal-swatch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.editor-foot {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin: 22px 0;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- 標籤 ---------- */

.win-body {
  flex: 1;
  min-width: 0;
}

.win-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.win-tags:empty {
  display: none;
}

/* 已選標籤：小字，不加框，事件為主 */
.tag-list {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding-bottom: 4px;
}

.win-list li .tag-toggle {
  display: none;
}

.win-list li.writing .tag-toggle {
  display: inline-block;
}

.win-list li:not(.writing) .win-tags:not(:has(.tag-list)) {
  display: none;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  padding: 1px 8px;
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.6;
  cursor: pointer;
}

.tag-chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}


.tag-toggle {
  border: 0;
  background: none;
  color: var(--accent);
  font-family: var(--latin);
  font-size: 15px;
  line-height: 1;
  padding: 2px 6px 6px;
  cursor: pointer;
  opacity: 0.85;
}

.tag-picker {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px;
  margin: 2px 0 8px;
  background: var(--paper);
  border: 1px solid var(--rule);
}

.tag-new {
  display: flex;
  gap: 6px;
  flex-basis: 100%;
  margin-top: 4px;
}

.tag-new input,
.tag-add input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  font-size: 16px;
  padding: 4px 0;
}

.tag-new input:focus,
.tag-add input:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.tag-new button {
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  padding: 2px 12px;
  cursor: pointer;
}


.tag-chip:focus-visible,
.tag-toggle:focus-visible,
.tag-remove:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 設定頁：管理標籤 */
.tag-manage .tag-chip {
  cursor: default;
  padding-right: 4px;
}

.tag-remove {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}

.tag-add {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-top: 14px;
}

.tag-add .btn {
  width: auto;
  padding: 7px 18px;
}

/* 回顧頁：成功類型 */
.tag-report {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1.5px solid var(--ink);
}

.segmented.period {
  grid-template-columns: repeat(4, 1fr);
  margin: 4px 0 18px;
}

.segmented.period span {
  font-size: 13.5px;
  padding: 7px 2px;
}

.tag-hero {
  font-size: 16px;
  line-height: 1.7;
  margin-bottom: 14px;
}

.tag-hero b {
  font-weight: 700;
  color: var(--accent);
}

.tag-bars {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.tag-bar {
  display: grid;
  grid-template-columns: 5.6em 1fr 4.6em;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}

.tag-bar-label {
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-bar-track {
  height: 12px;
  position: relative;
}

.tag-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  min-width: 3px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.tag-bar.muted .tag-bar-label,
.tag-bar.muted .tag-bar-value {
  color: var(--muted);
}

.tag-bar.muted .tag-bar-fill {
  background: var(--rule);
}

.tag-bar-value {
  text-align: right;
  font-family: var(--latin);
  font-size: 15px;
  color: var(--ink-2);
  white-space: nowrap;
}

.tag-bar:hover .tag-bar-fill {
  filter: brightness(1.12);
}

.tag-table-label {
  margin-top: 18px;
}

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

.tag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.tag-table th,
.tag-table td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--rule);
  text-align: right;
  font-weight: 500;
}

.tag-table thead th {
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1.5px solid var(--ink);
}

.tag-table th[scope='row'],
.tag-table thead th:first-child {
  text-align: left;
}

.tag-table td {
  font-family: var(--latin);
  font-size: 15px;
}

.tag-table tr.total th,
.tag-table tr.total td {
  font-weight: 700;
  border-bottom: 0;
  border-top: 1.5px solid var(--ink);
}

.detail-tags {
  display: block;
  flex-basis: 100%;
  padding-left: 30px;
  font-size: 12.5px;
  color: var(--accent);
  margin-top: 2px;
}

.detail-list li > span:first-child {
  flex: 1;
}

.detail-list li {
  flex-wrap: wrap;
}

/* ---------- 分享今天 ---------- */

.share-day {
  display: block;
  margin: 2px 0 0 auto;
}

/* ---------- 備份提醒 ---------- */

.backup-nudge {
  position: relative;
  margin-top: 28px;
  padding: 18px 40px 18px 18px;
  background: var(--paper);
  border-top: 3px solid var(--accent);
}

.backup-nudge-text {
  font-size: 14.5px;
  line-height: 1.8;
  margin-bottom: 12px;
}

.backup-nudge .btn {
  width: auto;
  display: inline-block;
  padding: 8px 20px;
  font-size: 14px;
}

.backup-nudge .note-close {
  top: 10px;
  right: 8px;
}

.note-card.muted-by-nudge {
  display: none;
}

.last-backup {
  margin-top: -4px;
}

/* ---------- 新手引導 ---------- */

.onboarding {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--bg) var(--stars);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 26px calc(env(safe-area-inset-bottom, 0px) + 24px);
  overflow-y: auto;
}

.ob-inner {
  width: 100%;
  max-width: 440px;
}

.ob-kicker {
  font-size: 11px;
  border-bottom: 1.5px solid var(--ink);
  padding-bottom: 10px;
  margin-bottom: 30px;
}

.ob-step {
  min-height: 330px;
  animation: fade 0.3s ease;
}

.ob-title {
  font-size: 27px;
  letter-spacing: 0.14em;
  line-height: 1.5;
  margin: 6px 0 18px;
}

.ob-step p {
  font-size: 15.5px;
  line-height: 1.9;
  color: var(--ink-2);
}

.ob-demo {
  list-style: none;
  padding: 0;
  margin: 18px 0;
}

.ob-demo li {
  display: flex;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 15.5px;
}

.ob-demo b {
  font-family: var(--latin);
  font-weight: 500;
  color: var(--accent);
  font-size: 19px;
  line-height: 1.5;
}

.ob-install {
  margin-top: 18px;
  padding: 16px;
  background: var(--paper);
  border-top: 3px solid var(--accent);
  font-size: 14.5px;
  line-height: 1.85;
}

.ob-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 26px 0 18px;
}

.ob-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rule);
}

.ob-dots i.on {
  background: var(--accent);
}

.ob-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ob-actions .btn {
  width: auto;
  padding: 11px 28px;
}

/* ---------- 帳號與雲端同步 ---------- */

.nudge-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.panel a,
.note-card a {
  color: var(--accent);
  text-underline-offset: 3px;
}

.gsi-slot {
  min-height: 44px;
  margin: 18px 0 10px;
  max-width: 320px;
}

.cloud-error {
  color: #b0412e;
}

:root[data-theme='dark'] .cloud-error {
  color: #f0a48c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .cloud-error {
    color: #f0a48c;
  }
}

.cloud-user {
  margin-top: 8px;
  word-break: break-all;
}

.cloud-user span {
  font-weight: 700;
}

.cloud-status {
  color: var(--muted);
}

.danger-zone {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}

.danger-zone summary {
  cursor: pointer;
  font-size: 13.5px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.danger-zone .btn-danger {
  margin-top: 10px;
  border-color: #b0412e;
  color: #b0412e;
}
