@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;500;600;700&family=Noto+Sans+TC:wght@300;400;500;700&display=swap');

:root {
  --bg: #FAF5EE;
  --surface: #FFFFFF;
  --surface-soft: #F3E9DC;
  --primary: #8B6B4A;
  --primary-dark: #5F4630;
  --accent: #C9A876;
  --earth: #A98467;
  --text: #3E3226;
  --text-muted: #8A7968;
  --border: #E7DCC9;
  --success: #7C9070;
  --shadow: 0 4px 20px rgba(107, 79, 53, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, .serif {
  font-family: 'Noto Serif TC', serif;
  font-weight: 600;
  color: var(--primary-dark);
  line-height: 1.5;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------- Top bar ---------- */
.topbar {
  padding: 22px 20px 14px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.topbar .brand {
  font-family: 'Noto Serif TC', serif;
  font-size: 18px;
  letter-spacing: 4px;
  color: var(--primary-dark);
}
.topbar .date {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* ---------- Main content ---------- */
main {
  flex: 1;
  padding: 4px 20px 100px;
  overflow-y: auto;
}
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.section-title {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 3px;
  margin: 28px 0 10px;
  text-transform: uppercase;
}

/* ---------- Today view ---------- */
.quote-card {
  text-align: center;
  padding: 36px 24px;
  background: linear-gradient(160deg, var(--surface) 0%, var(--surface-soft) 100%);
}
.quote-sutra {
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--accent);
  margin-bottom: 14px;
}
.quote-text {
  font-family: 'Noto Serif TC', serif;
  font-size: 21px;
  line-height: 2;
  color: var(--primary-dark);
  margin: 0 0 20px;
}
.quote-reading {
  font-size: 14.5px;
  line-height: 1.9;
  color: var(--text);
  text-align: left;
  border-top: 1px dashed var(--border);
  padding-top: 18px;
  margin-top: 4px;
}
.quote-question {
  margin-top: 18px;
  padding: 16px 18px;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.8;
  color: var(--primary-dark);
  text-align: left;
}
.quote-question b { color: var(--earth); }

textarea.reflect-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  resize: none;
  min-height: 140px;
  max-height: 420px;
  overflow-y: auto;
  margin-top: 10px;
}
textarea.reflect-input:focus { outline: 2px solid var(--accent); }

.today-entry {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  line-height: 1.8;
}
.today-entry:last-child { border-bottom: none; }
.today-entry .te-time { font-size: 11.5px; color: var(--accent); letter-spacing: 1px; margin-bottom: 4px; }
.today-entry .te-text { white-space: pre-wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: 999px;
  border: none;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-block { width: 100%; }
.btn-ghost { background: var(--surface-soft); color: var(--primary-dark); }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ---------- Timer view ---------- */
.timer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 10px 10px;
}
.timer-ring {
  width: 260px;
  height: 260px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 30px;
}
.timer-ring svg { position: absolute; top: 0; left: 0; transform: rotate(-90deg); }
.timer-display {
  font-family: 'Noto Serif TC', serif;
  font-size: 46px;
  color: var(--primary-dark);
  z-index: 1;
}
.timer-presets {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 24px;
}
.preset-chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}
.preset-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.timer-controls { display: flex; gap: 14px; }
.sit-log {
  margin-top: 30px;
  width: 100%;
}
.sit-log-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-muted);
}

/* ---------- Journal view ---------- */
.journal-entry {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}
.journal-entry:last-child { border-bottom: none; }
.journal-date { font-size: 12px; color: var(--accent); letter-spacing: 1px; margin-bottom: 6px; }
.journal-text { font-size: 14.5px; line-height: 1.8; white-space: pre-wrap; }
.journal-actions { margin-top: 8px; display: flex; gap: 10px; }
.link-btn { background: none; border: none; color: var(--text-muted); font-size: 12.5px; cursor: pointer; text-decoration: underline; padding: 0; }
.empty-state { text-align: center; color: var(--text-muted); padding: 40px 10px; font-size: 14px; line-height: 1.8; }

/* ---------- Notes view ---------- */
.note-list-item {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.note-list-item:last-child { border-bottom: none; }
.note-list-title { font-family: 'Noto Serif TC', serif; font-size: 16px; color: var(--primary-dark); margin-bottom: 4px; }
.note-list-subtitle { font-size: 12.5px; color: var(--text-muted); }
.note-detail-body { font-size: 15px; line-height: 2.1; white-space: pre-wrap; }
.note-detail-body p { margin: 0 0 20px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; margin-bottom: 16px; cursor: pointer; }

/* ---------- Store / feedback view ---------- */
.product-card {
  display: block;
  padding: 18px 20px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  text-decoration: none;
  color: inherit;
}
.product-card .p-title { font-family: 'Noto Serif TC', serif; font-size: 15.5px; color: var(--primary-dark); margin-bottom: 4px; }
.product-card .p-desc { font-size: 13px; color: var(--text-muted); line-height: 1.6; }

/* ---------- Bottom nav ---------- */
nav.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  box-sizing: border-box;
  padding: 8px 4px calc(8px + var(--safe-bottom));
  z-index: 40;
}
.tabbar-inner {
  display: flex;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}
.tab-btn {
  flex: 1 1 0;
  min-width: 0;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 2px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 11px;
}
.tab-btn.active { color: var(--primary); }
.tab-btn svg { width: 22px; height: 22px; }

/* ---------- Install banner ---------- */
.install-banner {
  position: fixed;
  bottom: 78px;
  left: 12px;
  right: 12px;
  max-width: 456px;
  margin: 0 auto;
  background: var(--primary-dark);
  color: #fff;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 50;
}
.install-banner button { flex-shrink: 0; }
.hidden { display: none !important; }

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-dark);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  z-index: 100;
}
.toast.show { opacity: 1; }

::-webkit-scrollbar { width: 0; }
