/* Phone app shell (owner-approved board docs/boards/phone-app-v2.png, rules docs/research/mobile-app-rea.md, 2026-11-22).
   A floating glass tab bar of five that never hides (Apple HIG tab bars; Material 3 navigation bar: 3–5 destinations,
   icon + one-word label, filled icon for the current one; NN/g: don't hide navigation you don't need to), a 전체 sheet
   for every other page, home as "today", sub-pages as a segmented control, a short footer. Phones only; desktop keeps its
   own header and footer. Loaded last. */
.tabbar, .sheet, .m-today { display: none; }

@media (max-width: 760px) {
  /* ---------- the shell ---------- */
  body { padding-bottom: calc(96px + env(safe-area-inset-bottom)); } /* scale-exception: optical or section offset 96px */
  .menu-btn, .drawer, .bar { display: none !important; }
  .tabbar { position: fixed; z-index: var(--z-tabbar); left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; height: 64px; padding: 4px; border-radius: 28px;
    background: rgba(247, 246, 242, .9); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7), 0 0 0 .5px rgba(11, 36, 71, .08), 0 10px 30px rgba(11, 36, 71, .14); }
  body.chrome-hide .tabbar { transform: none; }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; height: 52px; padding: 0;
    border: 0; border-radius: 28px; background: none; color: var(--ink-2); font: 600 13px/1.4 var(--sans); letter-spacing: -.02em;
    text-decoration: none; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: background-color var(--spring-quick-dur) var(--spring-quick), color var(--spring-quick-dur) var(--spring-quick), transform var(--spring-quick-dur) var(--spring-quick); }
  .tab svg { width: 24px; height: 24px; flex: none; }
  .tab .i-line { stroke-width: 1.75 !important; transition: fill var(--spring-quick-dur) var(--spring-quick); }
  .tab[aria-current], .tab[data-current] { color: var(--night); background: rgba(11, 36, 71, .08); }
  .tab[aria-current] svg > .i-line:first-child, .tab[data-current] svg rect.i-line { fill: currentColor !important; }
  .tab[aria-current] svg circle.i-line { fill: #EEF0EE !important; }   /* the pin's hole stays open */
  .tab:active { transform: scale(.94); }
  .tab:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; }

  /* ---------- 전체: a sheet from the bottom ---------- */
  .sheet { display: block; position: fixed; inset: auto 0 0 0; width: 100%; max-width: 100%; max-height: 86svh; margin: 0; padding: 0;
    border: 0; background: none; color: var(--ink); overflow: visible; }
  .sheet:not([open]) { display: none; }
  .sheet::backdrop { background: rgba(11, 36, 71, .38); animation: sheet-dim .25s ease both; }
  .sheet-in { max-height: 86svh; overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0; background: var(--sand); box-shadow: 0 -10px 40px rgba(11, 36, 71, .18);
    animation: sheet-up .32s cubic-bezier(.2, .8, .2, 1) both; transition: transform var(--spring-quick-dur) var(--spring-quick); }
  .sheet.is-closing .sheet-in { animation: sheet-down .2s ease both; }
  .sheet.is-closing::backdrop { animation: sheet-dim .2s ease reverse both; }
  .sheet-grab { display: block; width: 36px; height: 4px; margin: 4px auto 16px; border-radius: 100vmax; background: rgba(11, 36, 71, .22); }
  .sheet h2 { margin: 0 4px 16px; font: 700 21px/1.4 var(--sans) !important; letter-spacing: -.02em; color: var(--night); }
  .sheet-list { margin: 0; padding: 0; list-style: none; border-radius: 12px; background: #fff; box-shadow: 0 0 0 1px rgba(11, 36, 71, .08); overflow: hidden; }
  .sheet-list li + li { box-shadow: inset 0 1px 0 rgba(11, 36, 71, .08); }
  .sheet-list a { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 16px;
    color: var(--ink); text-decoration: none; font: 500 17px/1.4 var(--sans); }
  .sheet-list a[aria-current] { color: var(--night); font-weight: 700; }
  .sheet-list a:active { background: rgba(11, 36, 71, .05); }
  .sheet-list svg { width: 20px; height: 20px; color: var(--ink-3); }
  .sheet-reach { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 16px 4px 0; font: 500 15px/1.5 var(--sans); }
  .sheet-reach a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink-2); text-decoration: none; }
  .sheet-close { display: block; width: 100%; min-height: 48px; margin-top: 8px; border: 0; border-radius: 12px; background: rgba(11, 36, 71, .06);
    color: var(--night); font: 600 17px/1.4 var(--sans); cursor: pointer; }
  html.sheet-open, html.sheet-open body { overflow: hidden; }
  @keyframes sheet-up { from { transform: translateY(100%); } }
  @keyframes sheet-down { to { transform: translateY(100%); } }
  @keyframes sheet-dim { from { opacity: 0; } }

  /* ---------- home: "today" ---------- */
  .hm-hero { height: 46svh !important; min-height: 320px !important; }
  .hm-times { display: none !important; }
  .m-today { display: block; padding: 0 var(--margin); }
  /* 다음 예배 (owner, 2026-11-22: the boxed card and four tiles "슬롭 같지 않냐"): one line on the paper, in the 큐티 block's
     language: a small label, the time as a large light numeral, the service and place beside it, one chevron. No box,
     no tiles (the tab bar and 전체 already carry the paths). The whole line opens the timetable. */
  .next-line { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "k k k" "time what go";
    align-items: end; column-gap: 16px; row-gap: 8px; padding: 16px 0 8px;
    color: var(--night); text-decoration: none; }
  .nl-k { grid-area: k; font: 600 13px/1.4 var(--sans); letter-spacing: .02em; color: #9C5200; }
  .nl-day { margin-left: 8px; color: var(--ink-2); }
  .nl-time { grid-area: time; font: 300 56px/1 var(--sans); letter-spacing: -.03em; color: var(--night); }
  .nl-what { grid-area: what; display: flex; flex-direction: column; padding-bottom: 4px; font: 600 17px/1.4 var(--sans); color: var(--night); }
  .nl-what small { font: 400 15px/1.5 var(--sans); color: var(--ink-2); }
  .nl-go { grid-area: go; width: 20px; height: 20px; margin-bottom: 8px; color: var(--ink-3); flex: none; transition: transform var(--spring-quick-dur) var(--spring-quick); }
  .next-line:active .nl-go { transform: translateX(3px); }
  .next-line:focus-visible { outline: 2px solid var(--orange); outline-offset: 4px; }

  /* ---------- sub-pages: a segmented control under the large title ---------- */
  .subnav { margin: 0 var(--margin) var(--s3) !important; padding: 4px !important; gap: 0 !important; border-radius: 12px !important;
    background: #ECEBE5 !important; box-shadow: none !important; }
  .subnav a { min-height: 44px !important; border-radius: 8px !important; color: var(--ink-2) !important; font: 500 15px/1.4 var(--sans) !important;
    box-shadow: none !important; transition: background-color var(--spring-quick-dur) var(--spring-quick), color var(--spring-quick-dur) var(--spring-quick); }
  .subnav a[aria-current="page"] { background: #fff !important; color: var(--night) !important; font-weight: 700 !important;
    box-shadow: 0 1px 2px rgba(11, 36, 71, .14), 0 0 0 .5px rgba(11, 36, 71, .06) !important; }

  /* ---------- a short footer: logo, social, legal; addresses live on 오시는 길 ---------- */
  .ft-places, .ft-reach { display: none !important; }
}
@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .sheet-in, .sheet::backdrop, .sheet.is-closing .sheet-in { animation: none !important; }
  .tab, .quick a, .next-card { transition: none; }
}

@media (max-width: 760px) { .quick svg, .next-card svg { flex: none; } }

/* smaller (owner, 2026-11-22: "너무 크다 비율이 좀 작게"): 52px bar, 20px icons, centred and no wider than 336px; each tab
   keeps the 44px touch target and 13px label (the phone type floor) */
@media (max-width: 760px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .tabbar { left: 50%; right: auto; width: min(336px, calc(100% - 24px)); transform: translateX(-50%); height: 52px; padding: 4px; border-radius: 28px; }
  body.chrome-hide .tabbar { transform: translateX(-50%); }
  .tab { height: 44px; gap: 1px; border-radius: 20px; font: 500 13px/1.2 var(--sans); }
  .tab[aria-current], .tab[data-current] { font-weight: 600; }
  .tab svg { width: 20px; height: 20px; }
  .tab:active { transform: scale(.94); }
}

/* Contact us leads to 섬기는 분들 (owner, 2026-11-22: "교회 목사님들 그 창으로 가는게 좋을거 같은데"); the contact panel was removed */

/* the footer is the last thing on the page (owner, 2026-11-23: a pale band kept showing under it): the room for the
   floating tab bar lives inside the footer's own navy, not as body padding below it */
@media (max-width: 760px) {
  body { padding-bottom: 0 !important; }
  .footer { padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important; } /* scale-exception: optical or section offset 84px */
}

/* icon parts that stay open when the tab's icon fills (the church door, the 큐티 ribbon) */
@media (max-width: 760px) {
  .tab[aria-current] svg [data-hole], .tab[data-current] svg [data-hole] { stroke: #EEF0EE !important; fill: none !important; }
}

/* each tab's icon moves in its own way when you arrive on it (owner, 2026-11-23): home settles, the church rises,
   the Bible's ribbon drops in, the pin lands, the grid turns. Once, short, spring-timed; nothing under reduced motion. */
@media (max-width: 760px) and (prefers-reduced-motion: no-preference) {
  .tab svg { transform-box: view-box; transform-origin: 50% 90%; }
  .tab[aria-current][data-icon="home"] svg { animation: tab-settle .5s cubic-bezier(.3, 1.4, .5, 1) both; }
  .tab[aria-current][data-icon="worship"] svg { animation: tab-rise .55s cubic-bezier(.3, 1.3, .5, 1) both; }
  .tab[aria-current][data-icon="qt"] svg [data-hole] { animation: tab-ribbon .5s cubic-bezier(.3, 1.4, .5, 1) .1s both; }
  .tab[aria-current][data-icon="visit"] svg { animation: tab-drop .6s cubic-bezier(.3, 1.5, .5, 1) both; }
  .tab-all.is-tap svg { animation: tab-turn .45s cubic-bezier(.3, 1.3, .5, 1) both; transform-origin: 50% 50%; }
}
@keyframes tab-settle { from { transform: scale(1.12, .88); } }
@keyframes tab-rise { from { transform: translateY(3px) scaleY(.9); } }
@keyframes tab-ribbon { from { transform: translateY(-4px); opacity: 0; } }
@keyframes tab-drop { from { transform: translateY(-6px); } }
@keyframes tab-turn { from { transform: rotate(-90deg); } }

/* phone type and control scale (owner, 2026-11-23: sizes not unified, buttons too big, text cramped). Five steps only:
   13 caption · 15 secondary · 17 body · 20 section title · 26+ display; controls 44px tall, one line. */
.hm-word-grid .cover { isolation: isolate; }
.hm-word-grid .cover img.yt-still { z-index: var(--z-under) !important; }   /* the photo sits under the dark scrim, so the title reads */
@media (max-width: 760px) {
  .hm-head h2, main .sh h2 { font-size: 20px !important; line-height: 1.4 !important; letter-spacing: -.01em; }
  .hm-head .link, main .sh .link { font-size: 15px !important; }
  .hm-word-grid .cover:not(.big) .c-k, .hm-word-grid .cover:not(.big) .c-k .num { font-size: 13px !important; line-height: 1.4 !important; }
  .hm-word-grid .cover:not(.big) .c-t { font-size: 16px !important; line-height: 1.4 !important; font-weight: 700 !important; margin-top: 4px; }
  .hm-word-grid .cover:not(.big) .c-m { display: none !important; }
  .hm-word-grid .cover.big .c-m, .mtn-meta, .mtn-cap, .mtn-cap .num { font-size: 13px !important; line-height: 1.5 !important; }
  .hm-word-grid .cover.big .c-t { font-size: 28px !important; line-height: 1.3 !important; }
  .qtc-v2 .qtc-t { font-size: 22px !important; line-height: 1.4 !important; }
  .mtn-cap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 16px); }
  /* buttons: 44px, one line, never wider than their words */
  .al-rest, .yb-btn, .btn, .btn-go, .walk-start { min-height: 44px !important; height: auto; padding-top: 0 !important; padding-bottom: 0 !important;
    font-size: 15px !important; white-space: nowrap; }
  .al-rest { width: auto !important; margin-inline: auto; display: flex !important; padding-inline: 16px !important; }
}

/* touch screens (owner, 2026-11-23: "버튼 누르면 막 이상하게 상호작용"): a tap left :hover stuck on, so photos stayed
   zoomed and buttons stayed shifted after the finger lifted, and the browser drew a grey box over every link. On touch,
   only the press itself answers (the :active scale), and nothing hangs on afterwards. */
a, button, summary, [role="button"], label { -webkit-tap-highlight-color: transparent; }
@media (hover: none) {
  .cover:hover img, .ph-open:hover img, .mtn-grid a:hover img, .mtn-v3 a:hover img, .dawnstrip .frame:hover img, .story:hover img,
  .btn:hover, .btn-go:hover, .btn-go:hover svg, .icon-btn:hover, .qtc:hover .qtc-go, .qtc-v2:hover .qtc-btn, .qtc-v2:hover .qtc-btn svg,
  .cover.big:hover .play.play-v2, .cover:hover .play-v3 svg, .mtn-wall a:hover, .walk-start:hover, .jb-more:hover svg, .mtn-v3 .mtn-all:hover svg,
  .qt-dawn:hover svg, .qtp-dawn:hover svg, .ft-admin:hover svg, .ft-link:hover .ic, .more-btn:hover .ic, .al-yearbar .yb-btn:hover .yb-chev,
  .header .btn:hover { transform: none !important; box-shadow: none; }
  .link:hover::after, .text-link:hover::after, .ft-link:hover::after, .btn:hover::after, .link[href*="youtube"]:hover::after { transform: none !important; }
}

/* sub-page segments: all four fit one line at 320–390px (교회 소식 was cut off) */
@media (max-width: 760px) {
  .subnav { display: grid !important; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); overflow: visible !important; }
  .subnav a { justify-content: center; padding: 0 4px !important; white-space: nowrap; font-size: 15px !important; letter-spacing: -.02em; }
}
@media (max-width: 359px) { .subnav a { font-size: 13px !important; } }
@media (max-width: 760px) {
  .feature .meta-line { font-size: 15px !important; line-height: 1.5 !important; color: var(--ink-2) !important; font-weight: 400 !important; }
  .subnav + .sec, .subnav + section { padding-top: 24px !important; }
}

/* schedule tabs share the width evenly and never scroll (교회학교 was cut at 320px) */
@media (max-width: 760px) {
  .sc-tabs { display: grid !important; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; overflow: visible !important; }
  .sc-tabs button { padding-inline: 4px !important; white-space: nowrap; font-size: 15px !important; letter-spacing: -.02em; }
}
@media (max-width: 359px) { .sc-tabs button { font-size: 13px !important; } }
/* the first section sits one step under the sub-tabs (was 64px of empty paper) */
@media (max-width: 760px) { main.is-inner > .page-head + section.sec.sec { padding-top: 8px !important; } }
/* 걸어온 길 on phones (owner, 2026-11-23: "직선이랑 동그라미 정렬"): each dot hangs from its own year, so it sits on the
   rail (x) and on the year's centre line (y) whatever the row spacing */
@media (max-width: 760px) {
  main .tl-list li::before { display: none !important; }
  main .tl-list li > b { position: relative; display: block; }
  main .tl-list li > b::before { content: ""; position: absolute; left: -24px; top: calc(50% - 6px); width: 12px; height: 12px; border-radius: 50%;
    background: var(--sand); box-shadow: inset 0 0 0 2px var(--rule); }
  main .tl-list li.past > b::before { box-shadow: inset 0 0 0 2px var(--blue); }
  main .tl-list li.on > b::before { background: var(--blue); box-shadow: 0 0 0 5px rgba(11, 36, 71, .16); }
}
/* desktop: the first section sits one clear step under the sub-tabs (64–105px of empty paper before) */
@media (min-width: 761px) { main.is-inner > .page-head + section.sec.sec { padding-top: 32px !important; } }

/* phone footer (owner, 2026-11-23: "풋터가 먼가 이상하더라"): everything on the one left edge of the page; the lone "함께"
   label goes (the three icons say it); copyright and legal lines left-aligned in the 13px caption step; the admin key
   stays at the far right of the legal row. */
@media (max-width: 760px) {
  .footer .ft-cols .fh { display: none !important; }
  .footer .ft-in { gap: 16px !important; }
  .footer .ft-cols > div:not(.ft-places):not(.ft-reach) { display: flex !important; flex-direction: column; align-items: flex-start; gap: 4px; }
  .footer .a2hs { width: auto !important; justify-content: flex-start !important; padding: 0 !important; font-size: 15px !important; }
  .footer .ft-base { display: flex !important; flex-direction: column; align-items: stretch; gap: 8px; text-align: left !important; }
  .footer .ft-copy { width: 100% !important; text-align: left !important; margin: 0 !important; font-size: 13px !important; line-height: 1.6 !important; }
  .footer .ft-copy span { display: block; }
  .footer .ft-legal { width: 100% !important; display: flex !important; justify-content: flex-start !important; gap: 24px !important; margin: 0 !important; }
  .footer .ft-legal .ft-link { font-size: 13px !important; padding: 0 !important; }
  .footer .ft-legal .ft-admin { margin-left: auto !important; margin-right: -14px; }   /* scale-exception: optical — the key's glyph meets the right margin */
}

/* section titles carry the home page's divider on every page (owner + team, 2026-11-23: "메인화면에 있는 디바이더 …
   타이틀이 잘 안보여서"): a navy hairline above, one step of space, then the title — on phones too, where an older rule
   had removed it. The 지난 설교 list title gets the same line. */
@media (max-width: 760px) {
  main.is-inner .sh, main.is-inner #sermon .archive-head { border-top: 1px solid var(--ink) !important; padding-top: 16px !important; }
  main.is-inner .sh h2, main.is-inner #sermon .archive-head .h3 { font-size: 20px !important; line-height: 1.4 !important; font-weight: 700 !important; color: var(--night) !important; }
}
main.is-inner #sermon .archive-head { border-top: 1px solid var(--ink); padding-top: 16px; }
