@font-face {
  font-family: "PracticeCalligraphy";
  src: url("assets/lxgw-wenkai-tc.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

.auth-shell{min-height:100dvh;display:grid;place-items:center;padding:28px 20px;background:linear-gradient(180deg,#f4f7f6,#e7efef)}
.auth-card{width:min(100%,430px);padding:34px 26px;border:1px solid rgba(107,130,139,.2);border-radius:30px;background:rgba(255,255,255,.94);box-shadow:0 24px 70px rgba(43,64,75,.12);text-align:center}
.auth-card h1{margin:10px 0 12px;color:#253851;font-size:26px}.auth-card>p{color:#657184;line-height:1.75}
.auth-mark{display:grid;place-items:center;width:64px;height:64px;margin:0 auto 18px;border-radius:22px;background:linear-gradient(145deg,#eef3f1,#b9d3d3);color:#344b63;font-family:"PracticeCalligraphy",serif;font-size:32px}
.auth-form{display:grid;gap:10px;margin-top:24px;text-align:left}.auth-form label{font-weight:700;color:#34465c}.auth-form input,.scripture-form input,.scripture-form textarea,.scripture-form select{width:100%;box-sizing:border-box;border:1px solid #ccd7dc;border-radius:14px;background:#fff;padding:13px 14px;color:#253851;font:inherit}
.auth-form .primary-button{margin-top:4px}.auth-notice{padding:12px 14px;border-radius:14px;background:#eef4ef;color:#53695f!important}.privacy-note{margin-top:20px;font-size:13px;color:#7a8490!important}
.auth-guest-action{margin-top:10px}
.auth-about{margin-top:24px;padding-top:22px;border-top:1px solid #dce4e5;text-align:left}.auth-about h2{margin:0 0 6px;color:#34465c;font-size:1rem}.auth-about p{margin:0;color:#657184;font-size:.88rem;line-height:1.7}
.auth-loading{width:32px;height:32px;margin:24px auto 4px;border:3px solid #d7e1e2;border-top-color:#49677a;border-radius:50%;animation:auth-spin .8s linear infinite}@keyframes auth-spin{to{transform:rotate(360deg)}}
.topbar-actions{display:flex;align-items:center;gap:8px;flex:0 0 auto}.topbar-actions .logout-button{margin:0;white-space:nowrap;font-size:13px}.migration-notice button{display:block;margin-top:6px;padding:0;color:#8c7443}
.scripture-main-actions{margin:16px 0}.custom-scripture-card{position:relative}.custom-card-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}.custom-card-heading h3{margin-right:auto}.custom-card-heading button{padding:0;white-space:nowrap}.daily-badge{display:inline-block;margin-top:12px;padding:5px 9px;border-radius:999px;background:#f5ecd2;color:#8c7443}.scripture-form{display:grid;gap:18px}.scripture-form>label{display:grid;gap:7px;color:#34465c;font-weight:700}.scripture-form textarea{resize:vertical;line-height:1.75}.scripture-options{display:grid;gap:12px;padding:14px;border-radius:16px;background:#f3f6f5}.danger-button{border-color:#bf6b6b!important;color:#8b3434!important;background:#fff5f3!important}
.daily-editor-list{display:grid;gap:12px}.daily-editor-item{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;padding:14px;border:1px solid #dce4e5;border-radius:16px;background:#fbfcfb}.daily-editor-item>div:first-child{display:grid;gap:3px}.daily-editor-item small{color:#78838e}.compact-toggle{align-self:start}.daily-target{grid-column:1/-1;display:flex;align-items:center;gap:7px;color:#657184}.daily-target input{width:76px;border:1px solid #ccd7dc;border-radius:10px;padding:8px;font:inherit}.daily-order-actions{grid-column:1/-1;display:flex;flex-wrap:wrap;gap:7px}.daily-order-actions button{min-height:38px;padding:8px 12px}
.privacy-panel{margin-top:14px}.privacy-panel summary{cursor:pointer;font-weight:700;color:#34465c}.privacy-panel p{color:#657184;line-height:1.7}

:root {
  color-scheme: light;
  --ink: #1f2d3d;
  --muted: #657487;
  --blue: #253851;
  --blue-2: #405978;
  --mist: #edf3f5;
  --paper: #fbfcfb;
  --gold: #b28a42;
  --gold-pale: #f2e6c8;
  --line: #d8e0e3;
  --white: #ffffff;
  --danger: #9d554e;
  --shadow: 0 12px 34px rgba(28, 45, 63, .08);
  --radius: 22px;
  --calligraphy: "PracticeCalligraphy", "Kaiti TC", "STKaiti", "DFKai-SB", "BiauKai", "KaiTi", serif;
}

* { box-sizing: border-box; }

html { background: var(--mist); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 86% -4%, rgba(178,138,66,.16), transparent 31rem),
    linear-gradient(180deg, #f8faf9 0%, var(--mist) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body.is-writing { overflow: hidden; overscroll-behavior: none; }
body.reading-night-page { background: #111b27; color: #e9eef3; }
body.reading-night-page .page-header p { color: #aebdca; }
body.reading-night-page .back-button { border-color: #34465a; color: #f0d9a0; background: #192635; }
body.reading-night-page .bottom-nav { border-color: #34465a; background: rgba(17,27,39,.96); }
body.reading-night-page .nav-button { color: #aebdca; }
body.reading-night-page .nav-button.active { color: #f0d9a0; background: #213246; }
body.reading-night-page .counter-card { border-color: #34465a; color: #e9eef3; background: #192635; }
body.reading-night-page .count-meta div { background: #213246; }
body.reading-night-page .count-meta strong { color: #f0d9a0; }
body.reading-night-page .dedication-mode { background: #213246; }
body.reading-night-page .dedication-mode button { color: #dfe7ee; background: #2b4055; }
body.reading-night-page .dedication-mode button.active { color: #253851; background: #f0d9a0; }
body.reading-night-page .reader-counter .text-button { color: #aebdca; }
body.reading-night-page .reader-count-top,
body.reading-night-page .reader-actions,
body.reading-night-page .scripture-attribution { border-color: #34465a; color: #c5d0db; background: #192635; }
body.reading-night-page .reader-count-top strong { color: #f0d9a0; }
body.reading-night-page .reader-actions .text-button { color: #aebdca; }
body.reading-night-page .scripture-attribution strong { color: #f0d9a0; }
body.reading-night-page .segment-auto-setting,
body.reading-night-page .counter-placement { background: #213246; }
body.reading-night-page .floating-counter span { color: #c5d0db; background: #192635; }

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 18px calc(96px + env(safe-area-inset-bottom));
}
.focus-shell { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 2px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 14px;
  color: var(--gold-pale);
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(37,56,81,.18);
}

.brand-mark svg { width: 26px; height: 26px; }
.brand h1 { margin: 0; font-size: 1.05rem; line-height: 1.25; letter-spacing: .04em; }
.brand p { margin: 2px 0 0; font-size: .79rem; color: var(--muted); }

.date-line { margin: 8px 2px 14px; color: var(--muted); font-size: .9rem; }

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 23px;
  border-radius: 28px;
  color: white;
  background: linear-gradient(145deg, #253851, #405978);
  box-shadow: 0 18px 40px rgba(37,56,81,.2);
}

.hero-card::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -55px;
  top: -70px;
  border: 1px solid rgba(240,217,160,.32);
  border-radius: 50%;
  box-shadow: 0 0 0 20px rgba(240,217,160,.04), 0 0 0 42px rgba(240,217,160,.025);
}

.eyebrow { margin: 0 0 8px; color: #dbe8ea; font-size: .82rem; letter-spacing: .12em; }
.hero-title { margin: 0; font-size: 1.45rem; font-weight: 650; }
.goal-row { position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 22px 0; z-index: 1; }
.goal-count { display: flex; align-items: baseline; gap: 8px; }
.goal-count strong { font-family: ui-serif, "Noto Serif TC", serif; font-size: 3.25rem; line-height: 1; font-weight: 500; color: var(--gold-pale); }
.goal-count span { color: #dbe8ea; }

.progress-track { position: relative; z-index: 1; height: 7px; border-radius: 99px; background: rgba(255,255,255,.16); overflow: hidden; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f0d9a0, #fff0c9); transition: width .3s ease; }

.primary-button, .secondary-button, .ghost-button, .danger-button {
  min-height: 50px;
  border: 0;
  border-radius: 15px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 650;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}

.primary-button:active, .secondary-button:active, .ghost-button:active { transform: scale(.985); }
.primary-button { width: 100%; color: var(--blue); background: var(--gold-pale); }
.secondary-button { color: white; background: var(--blue); }
.ghost-button { color: var(--blue); background: #e7eef0; }
.danger-button { color: var(--danger); background: #f6e9e7; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.button-stack { display: grid; gap: 10px; }
.button-stack .secondary-button, .button-stack .ghost-button { width: 100%; }
.hero-card .primary-button { position: relative; z-index: 1; margin-top: 18px; }

.section { margin-top: 28px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 2px 13px; }
.section-heading h2 { margin: 0; font-size: 1.12rem; }
.section-heading span { font-size: .8rem; color: var(--muted); }

.practice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.practice-card, .stat-card, .panel {
  border: 1px solid rgba(216,224,227,.9);
  background: rgba(255,255,255,.84);
  box-shadow: var(--shadow);
}

.practice-card {
  display: flex;
  flex-direction: column;
  min-height: 155px;
  padding: 17px;
  border-radius: 20px;
}
.practice-card.wide { grid-column: 1 / -1; min-height: 140px; }
.practice-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: var(--blue); background: var(--gold-pale); font-family: ui-serif, serif; }
.practice-card h3 { margin: 12px 0 4px; font-size: 1rem; line-height: 1.4; }
.practice-card p { margin: 0 0 14px; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.mini-actions { display: flex; gap: 8px; margin-top: auto; }
.mini-actions button { flex: 1; min-height: 38px; border: 0; border-radius: 11px; color: var(--blue); background: var(--mist); font-size: .85rem; cursor: pointer; }

.notice {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255,255,255,.58);
  font-size: .82rem;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 760px);
  transform: translateX(-50%);
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(216,224,227,.9);
  background: rgba(251,252,251,.94);
  backdrop-filter: blur(15px);
}
.nav-button { min-height: 56px; border: 0; border-radius: 14px; color: var(--muted); background: transparent; font-size: .76rem; cursor: pointer; }
.nav-button .nav-icon { display: block; margin-bottom: 1px; font-size: 1.2rem; }
.nav-button.active { color: var(--blue); background: #e8eff1; font-weight: 650; }

.page-header { display: flex; align-items: center; gap: 12px; padding: 17px 0 12px; }
.back-button, .icon-button { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 14px; color: var(--blue); background: rgba(255,255,255,.78); cursor: pointer; }
.page-header h1 { margin: 0; font-size: 1.22rem; line-height: 1.35; }
.page-header p { margin: 2px 0 0; color: var(--muted); font-size: .8rem; }

.panel { padding: 20px; border-radius: var(--radius); }
.panel + .panel { margin-top: 13px; }
.panel h2, .panel h3 { margin: 0 0 8px; }
.panel p { margin-top: 0; }

.scripture {
  font-family: ui-serif, "Noto Serif TC", "Songti TC", serif;
  font-size: 1.12rem;
  line-height: 2;
  letter-spacing: .025em;
  white-space: pre-line;
}
.scripture-block { padding: 21px 18px; border-left: 3px solid var(--gold); border-radius: 0 16px 16px 0; background: #f7f5ef; }
.scripture-block + .scripture-block { margin-top: 13px; }
.scripture-block h3 { margin: 0 0 10px; color: var(--blue); font-family: inherit; font-size: 1rem; }
.scripture-title-block { margin: 13px 0; padding: 24px 16px; border: 1px solid rgba(178,138,66,.35); border-radius: 16px; background: #fffaf0; text-align: center; }
.scripture-title-block h2 { margin: 0; color: var(--blue); font-family: ui-serif, "Noto Serif TC", serif; font-size: clamp(1.2rem, 5.2vw, 1.55rem); line-height: 1.65; }
.scripture-title-block p { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }

.reader-toolbar { position: relative; z-index: 1; margin-bottom: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 16px; background: rgba(251,252,251,.96); box-shadow: 0 5px 16px rgba(28,45,63,.05); }
.reader-tools-row, .reader-auto-row { display: flex; align-items: center; gap: 8px; }
.reader-tools-row { justify-content: space-between; }
.reader-auto-row { justify-content: space-between; margin-top: 6px; }
.font-tools { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 10px; background: var(--mist); }
.font-tools button, .reader-tool { min-height: 34px; border: 0; border-radius: 9px; color: var(--blue); background: transparent; cursor: pointer; }
.font-tools button { min-width: 34px; font-weight: 700; }
.font-tools span { min-width: 38px; color: var(--muted); text-align: center; font-size: .75rem; }
.reader-tool { padding: 6px 9px; background: #e7eef0; font-size: .78rem; }
.reader-tool.active { color: white; background: var(--blue); }
.reader-mode-group { display: grid; grid-template-columns: auto 1fr 1fr; align-items: center; gap: 6px; margin-top: 7px; padding: 6px; border-radius: 11px; background: var(--mist); }
.reader-mode-group > span { padding: 0 4px; color: var(--muted); font-size: .73rem; }
.reader-mode-group .reader-tool { min-height: 38px; background: white; }
.reader-mode-group .reader-tool.active { color: white; background: var(--blue); }
.reader-mode-help { margin: 6px 2px 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }
.reader-auto-row label { color: var(--muted); font-size: .82rem; }
.seconds-setting input { width: 60px; min-height: 38px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; text-align: center; }
.reader-speed-label { display: grid; grid-template-columns: auto minmax(70px, 1fr); align-items: center; gap: 0 8px; min-width: 145px; flex: 1; }
.reader-speed-label input { width: 100%; accent-color: var(--blue); }
.speed-ends { grid-column: 2; display: flex; justify-content: space-between; margin-top: -5px; }
.speed-ends small { font-size: .68rem; }
.segment-auto-setting { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 7px; padding: 7px 9px; border-radius: 10px; color: var(--muted); background: var(--mist); font-size: .78rem; }
.segment-auto-setting input { width: 60px; min-height: 34px; padding: 3px 5px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; text-align: center; }
.reader-section-control { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: -3px 2px 8px; }
.reader-section-control .text-button { margin: 0; color: var(--blue); }
.reader-section-control small { color: var(--muted); font-size: .72rem; }
.reader-section-menu, .daily-section-menu { margin: 0 0 10px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.88); }
.reader-section-menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.reader-section-menu button, .daily-section-menu button { min-height: 38px; padding: 6px 8px; border: 0; border-radius: 9px; color: var(--blue); background: var(--mist); font-size: .75rem; }
.reader-section-menu button:active, .daily-section-menu button.active { color: white; background: var(--blue); }
.reader-floating-stop { position: fixed; right: max(16px, calc((100vw - 760px) / 2 + 16px)); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30; min-height: 44px; padding: 9px 14px; border: 1px solid rgba(240,217,160,.65); border-radius: 99px; color: #f8e9bd; background: rgba(37,56,81,.94); box-shadow: var(--shadow); }
.reader-panel .scripture { font-size: var(--reader-size); }
.reading-lines { display: grid; gap: 10px; }
.reading-line { width: 100%; padding: 17px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: #f7f9f9; text-align: left; cursor: pointer; }
.reading-line span { display: block; margin-bottom: 6px; color: var(--gold); font-size: .82rem; }
.reading-line strong { display: block; font-family: ui-serif, "Noto Serif TC", serif; font-size: var(--reader-size); font-weight: 400; line-height: 2; letter-spacing: .025em; }
.reading-line.active { border-color: var(--gold); background: #fff9e9; box-shadow: inset 4px 0 0 var(--gold); }
.reader-progress { margin-top: 13px; color: var(--muted); text-align: center; font-size: .82rem; }
.single-segment { display: grid; grid-template-rows: auto auto; }
.segment-navigation { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: .8rem; text-align: center; }
.segment-navigation .ghost-button { min-height: 40px; padding: 8px; }
.reader-night { border-color: #34465a; color: #e9eef3; background: #192635; }
.reader-night .scripture-block { color: #e9eef3; background: #213246; }
.reader-night .scripture-block h3 { color: #f0d9a0; }
.reader-night .scripture-title-block { border-color: #4c6075; background: #213246; }
.reader-night .scripture-title-block h2 { color: #f0d9a0; }
.reader-night .scripture-title-block p { color: #c5d0db; }
.reader-night .reading-line { border-color: #34465a; color: #e9eef3; background: #213246; }
.reader-night .reading-line.active { border-color: #d5b874; background: #2b4055; box-shadow: inset 4px 0 0 #d5b874; }
.reader-night .reader-progress { color: #aebdca; }
.reader-toolbar-night { border-color: #34465a; background: rgba(25,38,53,.97); }
.reader-toolbar-night .font-tools { background: #213246; }
.reader-toolbar-night .font-tools span, .reader-toolbar-night .reader-auto-row label { color: #c5d0db; }
.reader-toolbar-night .font-tools button { color: #f0d9a0; }
.reader-toolbar-night .reader-tool { color: #dfe7ee; background: #2b4055; }
.reader-toolbar-night .reader-tool.active { color: #253851; background: #f0d9a0; }
.reader-toolbar-night .reader-mode-group { background: #213246; }
.reader-toolbar-night .reader-mode-group > span { color: #c5d0db; }
.reader-toolbar-night .reader-mode-group .reader-tool { background: #2b4055; }
.reader-toolbar-night .reader-mode-group .reader-tool.active { color: #253851; background: #f0d9a0; }

.reader-bottom-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 7px; margin-top: 14px; padding: 8px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.9); }
.reader-bottom-nav button { min-height: 48px; padding: 6px 8px; border: 0; border-radius: 10px; color: var(--blue); background: var(--mist); font-size: 1rem; }
.reader-bottom-nav button span { display: block; margin-top: 2px; font-size: .72rem; }
.daily-stage-buttons:has(> :only-child) { grid-template-columns: 1fr; }

.stepper { display: flex; gap: 5px; margin: 5px 0 18px; }
.step-dot { height: 4px; flex: 1; border-radius: 99px; background: #d7dfe2; }
.step-dot.done, .step-dot.current { background: var(--gold); }

.counter-card { text-align: center; }
.session-number { margin: 16px 0 2px; font-family: ui-serif, serif; font-size: 4.5rem; line-height: 1; color: var(--blue); }
.session-label { color: var(--muted); font-size: .85rem; }
.count-button {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  margin: 24px auto 18px;
  border: 0;
  border-radius: 50%;
  color: #24364f;
  background: radial-gradient(circle at 38% 32%, #fff8e6, #ead5a4);
  box-shadow: 0 14px 30px rgba(104,82,35,.18), inset 0 0 0 1px rgba(178,138,66,.28);
  font-family: ui-serif, serif;
  font-size: 2rem;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
.count-button:active { transform: scale(.975); }
.count-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.count-meta div { padding: 13px; border-radius: 14px; background: var(--mist); }
.count-meta strong { display: block; color: var(--blue); font-size: 1.2rem; }
.count-meta span { color: var(--muted); font-size: .78rem; }
.reader-counter { margin-top: 12px; }
.reader-counter .session-number { margin: 4px 0 8px; font-size: 2.7rem; }
.compact-count { width: 112px; height: 112px; margin: 10px auto 12px; }
.reading-complete-button { width: 100%; margin: 8px 0 12px; }
.reader-count-top { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 8px; margin-bottom: 8px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.9); box-shadow: 0 4px 14px rgba(28,45,63,.04); }
.reader-count-top div { min-width: 0; }
.reader-count-top span { display: block; color: var(--muted); font-size: .7rem; }
.reader-count-top strong { display: block; margin-top: 1px; color: var(--blue); font-size: 1.15rem; }
.mini-count-button { width: 58px; height: 58px; margin: 0; font-size: 1.4rem; box-shadow: inset 0 0 0 1px rgba(178,138,66,.28); }
.reader-actions { margin-top: 12px; }
.scripture-attribution { margin-bottom: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 14px; color: var(--muted); background: rgba(255,255,255,.78); text-align: center; font-size: .76rem; }
.scripture-attribution strong, .scripture-attribution > span { display: block; }
.scripture-attribution strong { color: var(--blue); font-family: ui-serif, "Noto Serif TC", serif; font-size: .86rem; }
.scripture-attribution .setting-toggle { justify-content: center; margin-top: 7px; }
.counter-placement { display: grid; grid-template-columns: auto repeat(3, 1fr); align-items: center; gap: 5px; margin: 12px 0; padding: 7px; border-radius: 12px; background: var(--mist); }
.counter-placement span { color: var(--muted); font-size: .72rem; }
.counter-placement button { min-height: 36px; padding: 5px; border: 0; border-radius: 8px; color: var(--blue); background: white; font-size: .75rem; }
.counter-placement button.active { color: white; background: var(--blue); }
.has-floating-counter { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
.floating-counter { position: fixed; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 18; display: grid; justify-items: center; gap: 2px; }
.floating-counter.left { left: max(16px, calc((100vw - 760px) / 2 + 16px)); }
.floating-counter.center { left: 50%; transform: translateX(-50%); }
.floating-counter.right { right: max(16px, calc((100vw - 760px) / 2 + 16px)); }
.floating-counter span { padding: 1px 7px; border-radius: 99px; color: var(--muted); background: rgba(255,255,255,.92); font-size: .68rem; }
.dedication-mode { display: grid; grid-template-columns: auto 1fr 1fr; align-items: center; gap: 6px; margin: 12px 0; padding: 8px; border-radius: 12px; background: var(--mist); }
.dedication-mode span { color: var(--muted); font-size: .75rem; }
.dedication-mode button { min-height: 38px; padding: 5px 7px; border: 0; border-radius: 9px; color: var(--blue); background: white; font-size: .75rem; }
.dedication-mode button.active { color: white; background: var(--blue); }

.choice-list { display: grid; gap: 10px; }
.choice-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 58px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255,255,255,.85);
  text-align: left;
  cursor: pointer;
}
.choice-button span:last-child { color: var(--muted); }
.draft-panel { margin: 12px 0; }
.draft-list { display: grid; gap: 8px; }
.draft-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: white; text-align: left; cursor: pointer; }
.draft-item strong, .draft-item small { display: block; }
.draft-item small { margin-top: 2px; color: var(--muted); }
.draft-item > span:last-child { color: var(--gold); white-space: nowrap; }
.resume-panel { text-align: center; }
.resume-panel p { color: var(--muted); }

.goal-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 13px 0; }
.goal-option { min-height: 46px; border: 1px solid var(--line); border-radius: 13px; color: var(--blue); background: white; cursor: pointer; }
.goal-option.selected { color: white; border-color: var(--blue); background: var(--blue); }
.goal-custom { display: flex; gap: 8px; }
.goal-custom input { min-width: 0; width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: white; }

.writing-target { padding: 16px 14px; text-align: center; }
.writing-shell, .writing-target, .trace-wrap { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.writing-auto-panel { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.9); }
.setting-toggle { display: flex; align-items: center; gap: 9px; color: var(--blue); font-size: .9rem; }
.setting-toggle input { width: 20px; height: 20px; accent-color: var(--blue); }
.seconds-setting { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.writing-char { margin: 9px 0 2px; font-family: var(--calligraphy); font-size: 3.65rem; line-height: 1.15; color: var(--blue); }
.writing-context { min-height: 30px; color: var(--muted); font-family: var(--calligraphy); font-size: 1rem; }
.trace-wrap { position: relative; width: clamp(238px, 72vw, 318px); aspect-ratio: 1; margin: 12px auto; border: 1px solid #cfd9dd; border-radius: 20px; overflow: hidden; background: white; isolation: isolate; touch-action: none; overscroll-behavior: contain; }
.trace-wrap::before, .trace-wrap::after { content: ""; position: absolute; z-index: 0; pointer-events: none; opacity: .55; }
.trace-wrap::before { left: 50%; top: 0; bottom: 0; border-left: 1px dashed #d9e0e2; }
.trace-wrap::after { top: 50%; left: 0; right: 0; border-top: 1px dashed #d9e0e2; }
.trace-guide { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(37,56,81,.09); font-family: var(--calligraphy); font-size: clamp(8.5rem, 43vw, 12rem); line-height: 1; pointer-events: none; user-select: none; }
#writing-canvas { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; touch-action: none; overscroll-behavior: contain; cursor: crosshair; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.writing-finish { text-align: center; }
.writing-finish p { color: var(--muted); }
.writing-signature-settings { display: grid; gap: 9px; margin: 18px 0; padding: 15px; border: 1px solid var(--line); border-radius: 16px; text-align: left; background: rgba(239,244,246,.72); }
.writing-signature-settings > label:first-child { color: var(--blue); font-size: .9rem; font-weight: 700; }
.writing-signature-settings input[type="text"] { width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: white; font: inherit; }
.writing-signature-settings input[type="text"]:focus { outline: 2px solid rgba(37,56,81,.18); border-color: var(--blue); }
.writing-signature-settings .signature-toggle { margin-top: 2px; }
.writing-signature-settings p { margin: 0; font-size: .76rem; line-height: 1.55; }
.finish-mark { display: grid; place-items: center; width: 74px; height: 74px; margin: 6px auto 16px; border-radius: 50%; color: var(--blue); background: var(--gold-pale); font-family: var(--calligraphy); font-size: 2.5rem; }
.export-preview { max-height: 52vh; margin: 18px 0; overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: #f4f0e4; }
.export-preview img { display: block; width: 100%; height: auto; }
.export-preview.portrait img { width: min(100%, 390px); margin: 0 auto; }
.export-format-note { margin: 10px 0 -8px; color: var(--muted); font-size: .82rem; }
.export-options { margin-top: 18px; }
.export-dedication { color: var(--blue); }
.write-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.write-progress { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 8px; color: var(--muted); font-size: .82rem; }
.meditation-panel, .sutra-title-panel { display: grid; place-content: center; text-align: center; }
.meditation-panel { min-height: 0; padding: 28px 20px; }
.sutra-title-panel { min-height: 36vh; }
.meditation-panel p, .sutra-title-panel p { margin: 8px auto 0; color: var(--muted); }
.meditation-mark { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 50%; color: var(--blue); background: var(--gold-pale); font-family: var(--calligraphy); font-size: 2.2rem; }
.sutra-title-panel h2 { max-width: 18em; color: var(--blue); font-family: ui-serif, "Noto Serif TC", serif; font-size: 1.55rem; line-height: 1.8; }
.meditation-setting { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 20px 0 8px; color: var(--muted); }
.meditation-setting input { width: 74px; min-height: 42px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 10px; text-align: center; font: inherit; }
.meditation-countdown { margin: 4px 0 16px; color: var(--blue); font-family: ui-serif, serif; font-size: 2rem; }
.meditation-buttons { width: 100%; }
.bell-note { margin-top: 11px !important; font-size: .75rem; line-height: 1.6; }
.daily-quick-actions { display: flex; justify-content: flex-end; gap: 14px; margin: -8px 2px 8px; }
.daily-quick-actions .text-button { margin: 0; color: var(--muted); font-size: .78rem; }
.daily-section-menu p { margin: 0 0 8px; color: var(--muted); font-size: .74rem; line-height: 1.5; }
.daily-section-menu > div { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.stat-card { padding: 17px; border-radius: 18px; }
.stat-card strong { display: block; margin-bottom: 3px; color: var(--blue); font-size: 1.5rem; }
.stat-card span { color: var(--muted); font-size: .8rem; }
.record-table { width: 100%; border-collapse: collapse; }
.record-table th, .record-table td { padding: 13px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.record-table th { color: var(--muted); font-size: .78rem; font-weight: 500; }
.record-table td:last-child, .record-table th:last-child { text-align: right; }

.placeholder { padding: 42px 22px; text-align: center; }
.placeholder-mark { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 16px; border-radius: 24px; color: var(--gold); background: var(--gold-pale); font-family: ui-serif, serif; font-size: 1.8rem; }
.placeholder h2 { margin: 0 0 8px; }
.placeholder p { margin: 0; color: var(--muted); }

.dedication { min-height: calc(100vh - 155px); display: grid; align-content: center; text-align: center; }
.dedication .scripture { margin: 26px 0 34px; font-size: 1.45rem; line-height: 2.1; color: var(--blue); }
.dedication-symbol { width: 54px; height: 1px; margin: 0 auto 18px; background: var(--gold); }
.dedication-label { margin: 0 0 6px; color: var(--gold); font-size: .82rem; letter-spacing: .08em; }
.custom-dedication-display { margin: 24px 0; padding-top: 22px; border-top: 1px solid var(--line); }
.custom-dedication-editor { margin: 12px 0 16px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.72); text-align: left; }
.custom-dedication-editor label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: .8rem; }
.custom-dedication-editor textarea { width: 100%; min-height: 118px; padding: 12px; resize: vertical; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: white; font: inherit; line-height: 1.8; }
.custom-dedication-editor .secondary-button { width: 100%; margin-top: 10px; }
.edit-dedication-button { width: 100%; margin: 4px 0 12px; }
.text-button { display: block; margin: 10px auto 0; border: 0; background: transparent; cursor: pointer; }
.danger-text { color: var(--danger); }
.complete-dedication-button { width: 100%; }
body.reading-night-page .custom-dedication-editor { border-color: #34465a; background: #192635; }
body.reading-night-page .reader-section-menu,
body.reading-night-page .daily-section-menu { border-color: #34465a; background: #192635; }
body.reading-night-page .reader-section-menu button,
body.reading-night-page .daily-section-menu button { color: #dfe7ee; background: #2b4055; }
body.reading-night-page .daily-section-menu button.active { color: #253851; background: #f0d9a0; }
body.reading-night-page .reader-bottom-nav { border-color: #34465a; background: #192635; }
body.reading-night-page .reader-bottom-nav button { color: #dfe7ee; background: #2b4055; }

.toast { position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 50; transform: translateX(-50%); width: max-content; max-width: calc(100% - 36px); padding: 11px 16px; border-radius: 13px; color: white; background: rgba(31,45,61,.94); box-shadow: var(--shadow); font-size: .86rem; animation: toast-in .2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 420px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .home-topbar { display: grid; grid-template-columns: minmax(0, 1fr); }
  .home-topbar .topbar-actions { display: grid; grid-template-columns: 44px minmax(0, 1fr); width: 100%; }
  .home-topbar .logout-button { min-height: 44px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.78); }
  .hero-card { padding: 20px; }
  .practice-grid { grid-template-columns: 1fr; }
  .practice-card.wide { grid-column: auto; }
  .practice-card { min-height: 135px; }
  .button-row { grid-template-columns: 1fr; }
  .scripture { font-size: 1.06rem; }
  .reader-tools-row { display: flex; gap: 6px; }
  .font-tools { min-width: 0; justify-content: center; }
  .font-tools button { min-width: 28px; padding: 3px; }
  .font-tools span { min-width: 34px; }
  .reader-tool { min-width: 0; padding: 5px; }
  .reader-tools-row > .reader-tool { min-width: 72px; font-size: .72rem; line-height: 1.25; }
  .reader-mode-group { grid-template-columns: auto 1fr 1fr; }
  .reader-auto-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; }
  .reader-speed-label { width: 100%; min-width: 0; }
  .reader-section-menu { grid-template-columns: repeat(2, 1fr); }
  .writing-auto-panel { align-items: flex-start; flex-direction: column; }
}

@media (min-width: 680px) {
  .app-shell { padding-left: 28px; padding-right: 28px; }
  .practice-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
