/* 慧灯藏历 · 正式样式
   One token set for every surface. Design language: 经页 (pecha page) for
   content, 边玛墙 (penbey band) for the header, 香布 (shambu valance) as the
   single multi-colour signature. Colour roles:
   绛红 = action / selected / reminder · 深青 = structure & headings ·
   古金 = hairlines & ornament only (never body text) · 暖纸 = ground. */
:root {
  color-scheme: light;
  --paper: #f4eddf; --paper-2: #ece2cf;
  --surface: #fffaf1; --surface-2: #f8f0e2;
  --ink: #2c211b; --ink-2: #47392f; --muted: #67594b;
  --line: #e2d4bb; --line-2: #ccb894; --control: #978264;
  --red: #6e1f1a; --red-2: #571712; --red-tint: #f4e5dd; --red-tint-2: #ebd4c9;
  --gold: #a47a3d; --gold-2: #c8a25c; --gold-tint: #f1e4c7;
  --teal: #1d4549; --teal-2: #2c5b5c; --teal-tint: #e7ede8;
  --focus: #6e1f1a;
  --r-sm: 4px; --r: 6px; --r-lg: 10px;
  --shadow-1: 0 1px 2px #4a321a0d, 0 6px 18px #4a321a0a;
  --shadow-2: 0 2px 6px #3a24101a, 0 24px 60px #3a241033;
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Segoe UI", "Microsoft YaHei", sans-serif;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-num: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  /* 香布: gold edge, burgundy, ochre, deep teal. Pleats are a separate overlay. */
  /* Hand-made paper: a faint fibre grain, generated once by the browser. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .25 0 0 0 0 .12 .1 0 0 0 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --shambu: linear-gradient(#b58d4c 0 1px, #6e1f1a 1px 4px, #c9a35c 4px 6px, #1d4549 6px 9px);
  /* Legacy aliases kept for the shared guide stylesheet and older modules. */
  --card: var(--surface); --red-soft: var(--red-tint); --teal-dark: var(--teal); --teal-soft: var(--teal-tint);
  --control-line: var(--control); --green: var(--teal-2); --radius: var(--r-sm); --panel-radius: var(--r);
  --font-title: var(--font-serif); --font-body: var(--font-ui);
  --action-height: 86px; --available-height: 100dvh; --header-space: 220px;
  font-family: var(--font-ui); font-synthesis: none;
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--tabs-height, 0px) + 12px); scroll-padding-bottom: calc(var(--action-height) + 24px + env(safe-area-inset-bottom)); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper) var(--grain); color: var(--ink); font-size: 16px; line-height: 1.6; }
#app { overflow-anchor: none; }
:where(button, input, select, summary, a) { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, input, select { font: inherit; }
button { cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
summary { cursor: pointer; }
a { color: inherit; text-underline-offset: 4px; }
select { display: block; width: 100%; min-width: 0; height: 48px; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--control); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: 16px; }
:where(button, a, summary, input, select):focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font: 500 30px/1.2 var(--font-serif); }
h2 { font: 600 18px/1.45 var(--font-serif); }
h3 { font-size: 16px; font-weight: 600; line-height: 1.5; }
[hidden] { display: none !important; }
.icon { display: block; flex: none; width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip { position: absolute; top: -100px; left: 16px; z-index: 30; padding: 12px; background: var(--surface); }
.skip:focus { top: 8px; }

/* ── Buttons: one height, one radius, three emphasis levels ───────────── */
.primary, .secondary, .text-button, .icon-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  border-radius: var(--r-sm); font-size: 14px; font-weight: 500; line-height: 1.5; text-decoration: none; border: 1px solid transparent;
}
.primary { padding: 10px 18px; background: var(--red); border-color: var(--red); color: #fff6e6; }
.primary:hover:not(:disabled) { background: var(--red-2); border-color: var(--red-2); }
.primary:active:not(:disabled) { background: #4a120e; }
.secondary { padding: 10px 16px; background: transparent; border-color: var(--control); color: var(--ink); }
.secondary:hover:not(:disabled) { background: var(--paper-2); }
.secondary:active:not(:disabled) { background: #e3d6c1; }
.text-button { padding: 7px 6px; background: transparent; color: var(--red); }
.icon-button { width: 44px; flex: none; padding: 10px; background: transparent; color: var(--muted); }
:is(.text-button, .icon-button):hover:not(:disabled) { background: var(--red-tint); }
:is(.text-button, .icon-button):active:not(:disabled) { background: var(--red-tint-2); }
.text-button .icon { width: 16px; height: 16px; }
/* Disabled reads as "not yet", never as a faded error colour. */
button:disabled { cursor: default; }
.primary:disabled { background: var(--paper-2); border-color: var(--line-2); color: #7d6e5c; box-shadow: none; }
:is(.secondary, .text-button, .icon-button):disabled { opacity: .5; }
.primary[aria-busy=true] { cursor: progress; }
.full { width: 100%; }
.danger { color: #8b2f2a; }

/* ── 边玛墙 header ─────────────────────────────────────────────────────── */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px max(32px, calc((100vw - 1216px) / 2));
  position: relative;
  /* 边玛墙: bundled-twig texture under a maroon wash, finished by a double gold rule. */
  background: repeating-linear-gradient(90deg, #0000001c 0 1px, transparent 1px 3px, #ffffff08 3px 4px, transparent 4px 6px),
    linear-gradient(100deg, #4a1410, #6b1d18 55%, #521511);
  color: #f6e3bd; border-bottom: 1px solid #c39a55; box-shadow: 0 2px 0 #5a1813, 0 3px 0 #a98247;
}
.heading { display: flex; align-items: center; min-width: 0; }
.brand { display: flex; align-items: center; gap: 14px; color: #f6e3bd; text-decoration: none; flex: none; }
.brand-logo { display: grid; place-items: center; width: 52px; height: 52px; padding: 7px; border-radius: 50%; background: #fff4dc; box-shadow: 0 0 0 1px #c9a35c, 0 0 0 4px #6e1f1a, 0 0 0 5px #b38a4b80; }
.brand-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-type { display: flex; align-items: baseline; gap: 12px; }
.brand h1 { font: 500 28px/1.2 var(--font-serif); letter-spacing: 6px; color: #fbe9c4; }
.brand-type small { padding-left: 12px; border-left: 1px solid #c9a35c80; font: 14px/1.4 var(--font-serif); letter-spacing: 3px; color: #e8cf9f; }
#my-subscription { position: relative; flex: none; min-height: 44px; padding-inline: 18px; border-color: #c9a35c99; border-radius: 22px; background: #ffffff0a; color: #fbe9c4; }
#my-subscription:hover { background: #ffffff17; border-color: #c9a35c; }
#my-subscription>[data-icon] { display: inline-grid; width: 20px; height: 20px; flex: none; }
.unsaved-dot { position: absolute; top: 7px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: #f1cf86; box-shadow: 0 0 0 2px #5e1914; }
.site-header :focus-visible { outline-color: #f1cf86; }

/* ── 雪山横幅 + 香布 ───────────────────────────────────────────────────── */
.editorial-masthead { position: relative; height: 150px; margin-bottom: 13px; background: #163d45 url('./assets/himalaya-1600.jpg') center 40%/cover no-repeat; }
.editorial-masthead::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, #08262fd9, #08262f66 42%, #08262f26 62%, #08262fb8); }
/* 香布 valance: solid stripes, then a scalloped deep-teal hem with faint pleats. */
.editorial-masthead::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -13px; height: 13px; pointer-events: none;
  background: repeating-linear-gradient(90deg, #0000001a 0 1px, transparent 1px 8px), var(--shambu);
  background-size: auto, 100% 9px; background-repeat: repeat, no-repeat;
  background-color: #1d4549;
  -webkit-mask: linear-gradient(#000 0 9px, transparent 9px), radial-gradient(circle 4px at 4px 9px, #000 95%, transparent) 0 0/8px 13px repeat-x;
  mask: linear-gradient(#000 0 9px, transparent 9px), radial-gradient(circle 4px at 4px 9px, #000 95%, transparent) 0 0/8px 13px repeat-x;
}
.masthead-inner { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 24px; max-width: 1216px; height: 100%; margin: auto; }
.masthead-eyebrow { display: block; margin-bottom: 6px; color: #e3c387; font: 13px/1.5 var(--font-serif); letter-spacing: 6px; }
.masthead-date .today { display: flex; flex-direction: column; gap: 4px; font-family: var(--font-serif); line-height: 1.35; }
.masthead-date #today-gregorian { font-size: 28px; letter-spacing: 2px; color: #fff3d9; }
.masthead-date #today-tibetan { min-height: 1.4em; font-size: 17px; letter-spacing: 2px; color: #f0dcb5; }
/* Next practice day: one quiet line, not a card. */
.masthead-next { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 14px; max-width: 380px; padding: 10px 18px 10px 14px; border: 1px solid #c9a35c59; border-radius: var(--r); background: #0b262dbf; box-shadow: inset 0 0 0 3px #0b262d40, inset 0 0 0 4px #c9a35c26; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); color: #f6e6c6; text-align: left; }
.masthead-next .icon { grid-row: span 2; width: 40px; height: 40px; stroke-width: 1.1; color: #e3c387; filter: drop-shadow(0 1px 2px #0006); }
.masthead-next small { font: 13px/1.5 var(--font-serif); letter-spacing: 3px; color: #ecd09a; text-shadow: 0 1px 2px #0006; }
.masthead-next strong { font: 500 18px/1.45 var(--font-serif); letter-spacing: 1px; color: #fff3d9; text-shadow: 0 1px 3px #0007; }
.masthead-next strong span { margin-left: 10px; font-size: 15px; color: #f3dfb8; }

/* ── Layout ───────────────────────────────────────────────────────────── */
main { max-width: 1280px; min-height: calc(100svh - var(--header-space)); margin: auto; padding: 0 32px 40px; }
.region-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; min-height: 60px; margin-bottom: 24px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.time-comparison { display: flex; flex-wrap: wrap; gap: 24px; min-width: 0; }
.clock-item { display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 8px; }
.clock-item>span { font-size: 13px; color: var(--muted); }
.clock-item>small { display: none; grid-column: 1/-1; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.clock-item>strong { font: 500 20px/1.3 var(--font-num); font-variant-numeric: tabular-nums lining-nums; color: var(--ink); }
.clock-item+.clock-item>strong { color: var(--red); }
.region-bar:has(.clock-item:nth-child(2)) .clock-item>small { display: block; }
.region-setting { display: flex; align-items: center; gap: 4px 8px; min-width: 0; font-size: 13px; color: var(--muted); }
.region-setting .text-button { justify-content: flex-start; gap: 7px; min-width: 0; font-size: 13px; text-align: left; }
.region-setting .icon { width: 16px; height: 16px; }
#zone-summary { overflow-wrap: anywhere; }
.workspace { overflow-anchor: none; display: grid; grid-template-columns: 330px minmax(0,1fr); gap: 40px; align-items: start; }
.selection-column, .preview-column { min-width: 0; }

/* Section headings: serif, deep teal, a short gold rule — the 经页 margin mark. */
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-height: 44px; margin: 0 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); position: relative; }
.section-heading::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 34px; height: 2px; background: var(--gold); }
/* A small jewel (诺布) caps the rule — the same lozenge used across Tibetan borders. */
.section-heading::before { content: ""; position: absolute; left: 34px; bottom: -4px; width: 6px; height: 6px; background: var(--gold); transform: rotate(45deg); }
.section-heading h2 { font: 500 22px/1.4 var(--font-serif); letter-spacing: 2px; color: var(--teal); }

/* ── Quick presets + daily dates ──────────────────────────────────────── */
.quick-section { margin-bottom: 8px; }
.quick-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; margin-bottom: 10px; }
.quick-heading h3, .category-heading h3 { display: flex; align-items: center; gap: 8px; font: 600 15px/1.5 var(--font-serif); letter-spacing: 2px; color: var(--teal); }
.quick-heading h3::before, .category-heading h3::before { content: ""; flex: none; width: 5px; height: 5px; background: var(--gold); transform: rotate(45deg); }
.quick-heading>span { font-size: 13px; color: var(--muted); }
.quick-panel { border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.preset-options { display: grid; grid-auto-rows: 1fr; }
.preset-card {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%; min-width: 0; min-height: 60px;
  padding: 12px 14px 12px 16px; border: 0; border-radius: 0; background: transparent; color: var(--ink); text-align: left;
}
.preset-card+.preset-card { border-top: 1px solid var(--line); }
.preset-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--red); transform: scaleY(0); transition: transform .2s cubic-bezier(.2,.7,.2,1); }
.preset-card:hover:not([aria-pressed=true]) { background: var(--surface-2); }
.preset-card:active { background: var(--red-tint); }
.preset-card:focus-visible { z-index: 1; outline-offset: -3px; }
.preset-card[aria-pressed=true] { background: var(--red-tint); }
.preset-card[aria-pressed=true]::before { transform: scaleY(1); }
.preset-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; color: var(--teal); }
.preset-icon .icon { width: 28px; height: 28px; stroke-width: 1.4; }
.preset-card[aria-pressed=true] .preset-icon { color: var(--red); }
.preset-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 1px; }
.preset-copy strong { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; font-size: 16px; font-weight: 600; line-height: 1.5; }
.preset-copy strong small { font-size: 13px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.preset-copy>span { font-size: 13px; line-height: 1.6; color: var(--muted); }
.preset-copy em { font-size: 13px; line-height: 1.6; font-style: normal; color: var(--red); }
.preset-check { display: grid; place-items: center; flex: none; width: 20px; height: 20px; border: 1.5px solid var(--control); border-radius: 50%; color: #fff6e6; }
.preset-card[aria-pressed=true] .preset-check { background: var(--red); border-color: var(--red); box-shadow: 0 0 0 2px var(--red-tint), 0 0 0 3px var(--gold-2); }
.preset-check .icon { width: 13px; height: 13px; stroke-width: 2.2; }
.preset-scope-note { padding: 8px 16px 10px; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.6; color: var(--muted); background: var(--surface-2); }
.daily-date-option { padding: 4px 14px 0 16px; border-top: 1px solid var(--line); }
.daily-date-option .event-label { align-items: center; gap: 14px; min-height: 60px; padding: 6px 0; }
.daily-date-icon { display: grid; place-items: center; flex: 0 0 36px; width: 36px; color: var(--teal); }
.daily-date-icon .icon { width: 24px; height: 24px; stroke-width: 1.4; }
.daily-date-copy { flex: 1; }
.daily-date-title-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 8px; }
.daily-date-title-row strong { font-size: 16px; font-weight: 600; color: var(--ink); }
.daily-date-title-row small { padding: 0 6px; border: 1px solid var(--line-2); border-radius: 3px; font-size: 12px; line-height: 18px; color: var(--muted); }
.daily-date-option #daily-date-note { display: block; margin-top: 2px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.daily-date-help { margin-left: 50px; font-size: 13px; line-height: 1.75; color: var(--muted); }
.daily-date-help summary { display: flex; align-items: center; gap: 6px; width: fit-content; min-width: 88px; min-height: 40px; list-style: none; color: var(--muted); }
.daily-date-help summary:hover { color: var(--red); }
.daily-date-help summary::-webkit-details-marker { display: none; }
.daily-date-help summary .icon { width: 14px; height: 14px; }
.daily-date-help[open] summary .icon { transform: rotate(180deg); }
.daily-date-examples { padding: 0 0 14px; }
.daily-date-examples p { margin: 0 0 8px; }
.daily-date-examples p:first-child { padding-left: 12px; border-left: 2px solid var(--gold); color: var(--ink); font-family: var(--font-serif); }

/* ── Categories ───────────────────────────────────────────────────────── */
.category-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 44px; margin: 22px 0 4px; }
.category-heading .text-button { font-size: 13px; }
.group-card { border-bottom: 1px solid var(--line); }
.group-card:first-child { border-top: 1px solid var(--line); }
.group-card>summary { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 6px 10px 4px; list-style: none; }
.group-card>summary::-webkit-details-marker { display: none; }
.group-card>summary:hover { background: var(--surface-2); }
.group-card[open] { background: var(--surface); }
.group-card>summary { transition: box-shadow .2s, background-color .15s; }
.group-card[open]>summary { box-shadow: inset 3px 0 var(--teal); }
.group-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; color: var(--teal); }
.group-icon .icon { width: 26px; height: 26px; stroke-width: 1.4; }
.group-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.group-name strong { display: block; font-size: 16px; font-weight: 500; color: var(--ink); }
.group-name small { display: block; font-size: 13px; line-height: 1.4; color: var(--muted); }
.group-count { font-size: 13px; color: var(--muted); white-space: nowrap; }
.group-count.has-selected { padding: 1px 8px; border-radius: 10px; background: var(--red-tint); color: var(--red); }
.chevron { color: var(--muted); }
.chevron .icon { width: 16px; height: 16px; transition: transform .15s; }
.group-card[open] .chevron .icon { transform: rotate(180deg); }
.group-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px 0 52px; border-top: 1px dashed var(--line); }
.group-tools>div { display: flex; gap: 4px; }
.group-tools .text-button { padding: 5px 6px; font-size: 13px; }
.group-tools [data-reminder-group] { gap: 6px; }
.event-list { padding: 0 6px 6px 52px; }
.event-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.event-label { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 44px; cursor: pointer; }
.event-label>span { min-width: 0; }
.event-label input { appearance: none; display: grid; place-content: center; flex: none; width: 20px; height: 20px; margin: 0; border: 1.5px solid var(--control); border-radius: 3px; background: var(--surface); cursor: pointer; }
.event-label input:checked { background: var(--red); border-color: var(--red); }
.event-label input:checked::after { content: ""; width: 9px; height: 5px; border-left: 2px solid #fff6e6; border-bottom: 2px solid #fff6e6; transform: translateY(-1px) rotate(-45deg); }
.event-title { display: block; font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.event-rule { display: block; margin-top: 1px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.event-reminder { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; max-width: 96px; min-height: 44px; padding: 6px 4px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: 13px; line-height: 1.5; text-align: right; }
.event-reminder .icon { width: 16px; height: 16px; }
.event-reminder.active { color: var(--red); }
.event-reminder:hover:not(:disabled) { background: var(--red-tint); }
.event-reminder:disabled { opacity: .45; }
.selection-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.selection-footer a { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; text-decoration: none; }
.selection-footer a:hover { color: var(--red); }

/* ── Preview panel: the 经页 ───────────────────────────────────────────── */
.preview-panel { position: relative; padding: 4px 26px 0; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 5px #eadbbd, var(--shadow-1); }
.preview-heading { margin-top: 14px; }
.preview-meta { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.preview-meta .text-button { max-width: 100%; font-size: 13px; text-align: left; overflow-wrap: anywhere; }
.preview-footer { display: flex; align-items: flex-start; gap: 8px; margin-top: 16px; padding: 14px 0 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.preview-footer .icon { width: 16px; height: 16px; margin-top: 2px; }
.empty { padding: 28px 8px; text-align: center; font-size: 14px; line-height: 1.8; color: var(--muted); }
.empty .icon { width: 28px; height: 28px; margin: 0 auto 10px; }
.mobile-tabs { display: none; }

/* ── Action bar ───────────────────────────────────────────────────────── */
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 12px 32px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line-2); background: #fbf5eaf2; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 -6px 20px #4a321a0d; }
.action-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1216px; margin: auto; }
.action-inner>div { min-width: 0; }
.selection-totals { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 8px; font-size: 15px; line-height: 1.5; color: var(--ink); }
.selection-totals strong { font-weight: 600; font-variant-numeric: tabular-nums; }
#reminder-count, #daily-date-count { font-size: 13px; color: var(--muted); }
#reminder-count::before, .selection-totals #daily-date-count::before { content: "·"; margin-right: 8px; }
.action-inner p { margin-top: 2px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.action-buttons { display: flex; align-items: center; gap: 12px; flex: none; }
#clear-selection { min-width: 88px; color: var(--muted); }
#clear-selection:hover:not(:disabled) { color: var(--red); }
/* The one ceremonial button: burgundy with an inner gold rule, like a sealed page. */
.action-buttons>.primary { min-width: 184px; min-height: 48px; padding: 12px 24px; gap: 14px; border-radius: var(--r-sm); font: 500 16px/1.4 var(--font-serif); letter-spacing: 2px; box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 3px #b38a4b; }
.action-buttons>.primary:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--red-2), inset 0 0 0 3px #c8a25c; }
.action-buttons>.primary:disabled { box-shadow: none; }

footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; max-width: 1216px; margin: 32px auto calc(var(--action-height) + 24px + env(safe-area-inset-bottom)); padding: 20px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
footer a { text-decoration: none; }
footer a:hover { color: var(--red); }
.footer-dot { margin: 0 8px; }
.toast { position: fixed; z-index: 20; bottom: calc(var(--action-height) + 12px); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 22px; background: var(--ink); color: #fbf3e4; font-size: 14px; line-height: 1.6; text-align: center; box-shadow: 0 6px 24px #2c211b33; }

/* ── Dialogs: a page with the shambu at its head ──────────────────────── */
dialog {
  position: fixed; top: calc(var(--viewport-top, 0px) + var(--available-height) * .5); bottom: auto; transform: translateY(-50%);
  width: min(620px, calc(100% - 32px)); max-height: min(90dvh, calc(var(--available-height) - 24px)); margin: 0 auto; padding: 0 24px;
  border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); color: var(--ink);
  overflow: auto; overscroll-behavior: contain; scroll-padding: 96px 0 90px; box-shadow: var(--shadow-2);
}
dialog::backdrop { background: #2c211b66; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog-head { position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 16px; padding: 22px 0 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.dialog-head::before { content: ""; position: absolute; top: 0; left: -24px; right: -24px; height: 6px; background: repeating-linear-gradient(90deg, #00000014 0 1px, transparent 1px 10px), linear-gradient(#6e1f1a 0 2px, #c9a35c 2px 4px, #1d4549 4px 6px); }
.dialog-head h2 { font: 500 22px/1.4 var(--font-serif); letter-spacing: 1px; overflow-wrap: anywhere; }
.overline { margin-bottom: 2px; font-size: 13px; letter-spacing: 2px; color: var(--muted); }
.dialog-actions { position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 22px; padding: 14px 0 18px; background: var(--surface); border-top: 1px solid var(--line); }
.dialog-actions :is(.primary, .secondary) { min-width: 100px; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { padding: 0 0 10px; font-size: 14px; color: var(--muted); }
.field-note { margin: 8px 0 16px; font-size: 14px; line-height: 1.7; color: var(--muted); }
.mode-choice { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin: 16px 0; }
.mode-choice label, .device-options label { position: relative; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); color: var(--ink-2); cursor: pointer; transition: border-color .15s, background-color .15s; }
.mode-choice label { justify-content: center; min-height: 48px; padding: 12px 10px; font-size: 15px; }
.device-options label { justify-content: flex-start; min-height: 64px; padding: 10px 14px; font-size: 15px; text-align: left; }
:is(.mode-choice, .device-options) label:hover { border-color: var(--control); background: var(--surface-2); }
:is(.mode-choice, .device-options) input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
:is(.mode-choice, .device-options) label:has(input:checked) { border-color: var(--red); background: var(--red-tint); color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
:is(.mode-choice, .device-options) label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }
.device-options { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-top: 18px; }
.device-options legend { grid-column: 1/-1; display: flex; align-items: center; gap: 9px; padding-bottom: 12px; font-size: 17px; font-weight: 600; color: var(--ink); }
.device-options small { display: block; margin-top: 2px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.device-options label:has(input:checked) small { color: var(--red); }
.device-options label>.icon, .device-options label>[data-icon] { color: var(--teal); }
.device-options label:has(input:checked)>[data-icon] { color: var(--red); }
.reminder-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) 44px; gap: 10px; align-items: end; margin: 14px 0; }
.reminder-row label, .url-label { display: block; font-size: 14px; color: var(--muted); }
input[type=time], .url-label input { display: block; width: 100%; min-width: 0; height: 48px; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--control); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: 16px; }
.url-label input { font-size: 14px; font-family: var(--font-ui); }
.reminder-row .icon-button { height: 48px; }
.notice { margin: 14px 0; padding: 12px 14px; border: 1px solid #d8c29a; border-left: 3px solid var(--gold); border-radius: var(--r-sm); background: var(--gold-tint); color: #4f3f2a; font-size: 14px; line-height: 1.7; }
.notice.error { border-color: #d6b0a6; border-left-color: var(--red); background: #f7e8e2; color: #7c2b26; }
.notice p { margin-bottom: 8px; }
.notice p:last-child { margin-bottom: 0; }
.device-guide { margin: 18px 0; font-size: 14px; }
.feed-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.feed-actions>* { overflow-wrap: anywhere; }
.status-note { margin: 12px 0; font-size: 14px; line-height: 1.7; color: var(--teal-2); }
.subscription-entry { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.subscription-entry h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 14px; font-size: 17px; }
.entry-actions { align-items: stretch; margin: 0 0 14px; }
.entry-actions a { min-height: 44px; text-align: center; overflow-wrap: anywhere; }
.entry-actions [data-step]:not([data-step=""])::before { content: attr(data-step); display: inline-grid; place-items: center; flex: 0 0 22px; width: 22px; height: 22px; border: 1px solid currentColor; border-radius: 50%; font-size: 13px; line-height: 1; }
.entry-actions [aria-disabled=true] { opacity: .5; cursor: wait; pointer-events: none; }
.subscription-entry .field-note { margin: 12px 0 0; }
.subscription-entry .url-label { margin-top: 12px; }
#entry-attempt { padding-left: 12px; border-left: 2px solid var(--control); }
.management, .download-fallback { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
:is(.management, .download-fallback) summary { min-height: 44px; padding: 8px 0; color: var(--ink); }
:is(.management, .download-fallback) p { margin: 10px 0; line-height: 1.8; }
.management>.danger { margin-left: 8px; }
.downloads { display: grid; gap: 8px; }
.downloads .secondary { justify-content: flex-start; text-align: left; }
.search-box { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 0 12px; border: 1px solid var(--control); border-radius: var(--r-sm); background: var(--surface); color: var(--muted); }
.search-box .icon { width: 18px; height: 18px; }
.search-box input { width: 100%; min-width: 0; height: 44px; border: 0; background: transparent; color: var(--ink); font-size: 15px; outline-offset: -2px; }
.search-box input::placeholder { color: var(--muted); opacity: 1; }
.zone-options { min-height: 88px; max-height: min(48vh, calc(var(--available-height) - 310px)); overflow: auto; overscroll-behavior: contain; scroll-padding: 8px; border: 1px solid var(--line-2); border-radius: var(--r-sm); }
.zone-option { display: flex; align-items: center; gap: 12px; min-height: 70px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.zone-option:last-child { border-bottom: 0; }
.zone-option:hover { background: var(--surface-2); }
.zone-option:has(input:checked) { background: var(--red-tint); }
.zone-option input { flex: none; width: 18px; height: 18px; accent-color: var(--red); }
.zone-option>span { min-width: 0; overflow-wrap: anywhere; }
.zone-option strong { display: block; font-size: 15px; font-weight: 500; }
.zone-option small { display: block; font-size: 13px; color: var(--muted); }
.zone-option em { display: inline-block; margin: 3px 8px 0 0; font-size: 12px; font-style: normal; color: var(--red); }
.zone-option:focus-within { outline: 2px solid var(--focus); outline-offset: -3px; }
#zone-result-status { margin-bottom: 8px; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (min-width: 1024px) and (min-height: 700px) {
  .preview-column.can-stick { position: sticky; top: 16px; }
}
@media (max-width: 1279px) {
  .workspace { grid-template-columns: 310px minmax(0,1fr); gap: 28px; }
  .masthead-inner { padding-inline: 32px; }
}
@media (max-width: 1023px) {
  :root { --header-space: 200px; }
  .site-header { padding: 12px 24px; }
  main { max-width: 760px; padding: 0 24px 32px; }
  .editorial-masthead { height: 124px; }
  .masthead-inner { padding-inline: 24px; }
  .workspace { display: block; }
  .workspace[data-active-tab=selection] .preview-column, .workspace[data-active-tab=preview] .selection-column { display: none; }
  .region-bar { margin-bottom: 4px; }
  .mobile-tabs { position: sticky; top: 0; z-index: 8; isolation: isolate; display: flex; gap: 28px; margin-bottom: 14px; border-bottom: 1px solid var(--line-2); background: var(--paper); box-shadow: 0 8px 12px -10px #4a321a26; }
  .mobile-tabs button { min-height: 46px; padding: 8px 2px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent; color: var(--muted); font: 16px/1.4 var(--font-serif); letter-spacing: 2px; transition: none; }
  .mobile-tabs button[aria-selected=true] { border-bottom-color: var(--red); color: var(--red); font-weight: 600; }
  .selection-heading, .preview-heading { display: none; }
  .preview-panel { padding: 14px 14px 0; }
  .action-bar { padding-inline: 24px; }
  footer { margin-inline: 0; }
}
@media (max-width: 639px) {
  .entry-actions { display: flex; flex-direction: column; }
  .entry-actions>:is(a, button) { width: 100%; }
  .action-inner { flex-direction: column; align-items: stretch; gap: 8px; }
  .action-summary { display: flex; align-items: baseline; justify-content: space-between; gap: 3px 10px; }
  .action-summary p { margin: 0; text-align: right; }
  .action-buttons { display: grid; grid-template-columns: 88px minmax(0,1fr); gap: 12px; }
  .action-buttons>.primary { min-width: 0; min-height: 46px; }
  /* Phones: the next practice day becomes a third quiet line under today. */
  .masthead-inner { flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; }
  .masthead-next { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px; max-width: none; padding: 0; border: 0; background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .masthead-next .icon { display: none; }
  /* Reserve the line before it is computed so nothing below shifts (CLS 0). */
  .masthead-next { min-height: 20px; }
  .masthead-next[hidden] { display: flex !important; visibility: hidden; }
  .masthead-next small { font-size: 12px; letter-spacing: 1px; }
  .masthead-next strong, .masthead-next strong span { font-size: 13px; letter-spacing: 0; }
  .masthead-next strong span { margin-left: 6px; }
}
@media (max-width: 620px) {
  .device-options { grid-template-columns: 1fr 1fr; gap: 8px; }
  .device-options label { flex-direction: column; align-items: flex-start; gap: 6px; min-height: 0; padding: 12px; }
}
@media (max-width: 480px) {
  :root { --header-space: 150px; }
  .site-header { min-height: 62px; padding: 9px 16px; }
  .heading { display: contents; }
  .brand { gap: 10px; }
  .brand-logo { width: 40px; height: 40px; padding: 5px; box-shadow: 0 0 0 1px #c9a35c, 0 0 0 3px #6e1f1a, 0 0 0 4px #b38a4b80; }
  .brand-type { gap: 9px; }
  .brand h1 { font-size: 24px; letter-spacing: 4px; }
  .brand-type small { padding-left: 9px; font-size: 12px; letter-spacing: 2px; }
  #my-subscription { margin-left: auto; padding-inline: 14px; font-size: 13px; }
  main { padding: 0 16px 24px; }
  .editorial-masthead { height: auto; min-height: 86px; margin-bottom: 13px; background-image: url('./assets/himalaya-800.jpg'); background-position: 62% 38%; }
  .masthead-inner { padding: 12px 16px; min-height: 86px; }
  .masthead-eyebrow { display: none; }
  .masthead-date .today { gap: 3px; }
  .masthead-date #today-gregorian { font-size: 19px; letter-spacing: .5px; }
  .masthead-date #today-tibetan { font-size: 14px; letter-spacing: 1px; }
  .region-bar { min-height: 50px; padding: 5px 0; gap: 0 8px; }
  .time-comparison { gap: 8px; }
  .clock-item>strong { font-size: 18px; }
  .clock-item>small { display: none; }
  .region-setting { margin-left: auto; }
  .region-setting>span { display: none; }
  .region-setting .text-button { padding: 6px 0; }
  .region-setting .icon { width: 14px; height: 14px; }
  .region-setting #zone-summary { max-width: 170px; }
  .preset-card { gap: 12px; min-height: 56px; padding: 10px 12px 10px 14px; }
  .preset-icon, .daily-date-icon { width: 32px; flex-basis: 32px; }
  .preset-icon .icon, .daily-date-icon .icon { width: 26px; height: 26px; }
  .daily-date-option { padding-inline: 14px 12px; }
  .daily-date-option .event-label { gap: 12px; }
  .daily-date-help { margin-left: 44px; }
  .group-tools { padding-left: 4px; }
  .event-list { padding-left: 4px; }
  .preview-panel { padding: 12px 10px 0; }
  .action-bar { padding: 9px 16px max(9px, env(safe-area-inset-bottom)); }
  .action-inner { gap: 8px; }
  .action-buttons>.primary { padding: 10px 16px; gap: 8px; font-size: 15px; letter-spacing: 1px; }
  .selection-totals { flex: none; gap: 0 5px; font-size: 13px; }
  #reminder-count, #daily-date-count { font-size: 12px; }
  #reminder-count::before, .selection-totals #daily-date-count::before { margin-right: 5px; }
  .action-inner p { max-width: 185px; font-size: 12px; }
  dialog { width: calc(100% - 20px); max-height: calc(var(--available-height) - 20px); padding: 0 18px; }
  .dialog-head { padding-top: 18px; }
  .dialog-head::before { left: -18px; right: -18px; }
  .dialog-head h2 { font-size: 20px; }
  .dialog-actions :is(.primary, .secondary) { min-width: 90px; }
  .reminder-row { gap: 6px; }
  .reminder-row label { font-size: 13px; }
  input[type=time] { padding: 6px; }
  .url-label input { font-size: 13px; }
  .management>.danger { margin-left: 0; }
  .zone-option { gap: 8px; padding: 10px; }
}
@media (max-width: 370px) {
  .site-header { gap: 8px; padding-inline: 12px; }
  .brand, .brand-type { gap: 7px; }
  .brand h1 { font-size: 22px; letter-spacing: 3px; }
  .brand-type small { display: none; }
  .brand-logo { width: 36px; height: 36px; padding: 4px; }
  #my-subscription { gap: 6px; padding-inline: 10px; }
  #my-subscription .icon { width: 16px; height: 16px; }
  .event-row { grid-template-columns: minmax(0,1fr) 80px; }
  .action-summary { flex-wrap: wrap; }
  .action-buttons>.primary { letter-spacing: 0; }
  .region-setting #zone-summary { max-width: 160px; }
}
@media (max-height: 600px) {
  .preview-column.can-stick { position: static; }
  dialog { max-height: calc(var(--available-height) - 16px); }
  .dialog-head { padding-top: 14px; padding-bottom: 8px; }
  .dialog-actions { margin-top: 14px; padding-bottom: 12px; }
  .zone-options { max-height: 140px; }
  .field-note { margin-bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
