
:root{--kb-touch:48px}
html{-webkit-text-size-adjust:100%;scroll-behavior:smooth}
body{font-family:system-ui,-apple-system,BlinkMacSystemFont,"Apple SD Gothic Neo","Malgun Gothic","Segoe UI",sans-serif;text-rendering:optimizeLegibility}
button,a,input,select,textarea{font:inherit}
button,a[role="button"],input[type="submit"]{touch-action:manipulation}
img,video{max-width:100%;height:auto}
:focus-visible{outline:3px solid rgba(229,192,104,.8)!important;outline-offset:3px}
.kb-legal-upgrade{width:min(780px,calc(100% - 28px));margin:24px auto 72px;padding:clamp(20px,4vw,42px);background:rgba(16,22,37,.96);border:1px solid rgba(255,255,255,.1);border-radius:28px;color:#f7f4ea;line-height:1.75}
.kb-legal-upgrade h1{font-size:clamp(1.8rem,5vw,2.8rem);margin:.3rem 0 1rem}.kb-legal-upgrade h2{font-size:1.08rem;margin:1.55rem 0 .55rem;color:#f0ca70}.kb-legal-upgrade p,.kb-legal-upgrade li{color:#bec6d8}.kb-legal-upgrade a{color:#f0ca70}.legal-effective,.legal-note{padding:12px 14px;border-radius:14px;background:rgba(229,192,104,.07);border:1px solid rgba(229,192,104,.16)}
.kb-study-bridge{position:fixed;left:50%;bottom:max(12px,env(safe-area-inset-bottom));transform:translateX(-50%);z-index:8000;display:none;align-items:center;gap:8px;padding:8px;border-radius:18px;background:rgba(10,14,24,.92);border:1px solid rgba(255,255,255,.12);box-shadow:0 16px 40px rgba(0,0,0,.35);backdrop-filter:blur(16px);max-width:calc(100vw - 24px)}
.kb-study-bridge.is-visible{display:flex}.kb-study-bridge__ref{font-size:.78rem;color:#c9d0df;padding:0 8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:170px}.kb-study-bridge a{min-height:40px;display:inline-flex;align-items:center;padding:0 11px;border-radius:12px;color:#f6f4ed;text-decoration:none;background:rgba(255,255,255,.06);font-size:.8rem}.kb-study-bridge a:hover{background:rgba(229,192,104,.16)}
@media(max-width:760px){body{padding-bottom:max(0px,env(safe-area-inset-bottom))}.kb-study-bridge{left:10px;right:10px;transform:none;overflow-x:auto;justify-content:flex-start}.kb-study-bridge__ref{max-width:130px;flex:0 0 auto}.kb-study-bridge a{flex:0 0 auto}.kb-shalom-panel{max-height:min(78dvh,720px)!important}.kb-shalom-launcher{bottom:max(14px,env(safe-area-inset-bottom))!important;right:12px!important}.kb-shalom-launcher__label{display:none!important}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}

/* 2026-08 무료회원·모바일 마감 */
html,body{max-width:100%;overflow-x:hidden}
main,section,article,nav,header,footer{min-width:0}
input,textarea,select{max-width:100%}
@media(max-width:640px){
  body{font-size:15px}
  button,.btn,a.button,[role="button"]{min-height:44px}
  input,select,textarea{font-size:16px} /* iOS 입력 확대 방지 */
  .kb-study-bridge{bottom:max(82px,calc(env(safe-area-inset-bottom) + 70px));scrollbar-width:none}
  .kb-study-bridge::-webkit-scrollbar{display:none}
  .kb-legal-upgrade{width:calc(100% - 16px);margin:10px auto 88px;padding:18px;border-radius:20px}
}
@media(min-width:761px){
  .kb-study-bridge{max-width:min(920px,calc(100vw - 220px))}
}


/* 2026-08-13 final mobile QA */
@media (max-width: 760px) {
  html, body { width:100%; max-width:100%; overflow-x:clip; }
  body { min-width:0; }
  body * { min-width:0; }
  img, svg, canvas, video, iframe, audio { max-width:100%; }
  iframe, video { width:100%; }
  pre, code { max-width:100%; overflow-wrap:anywhere; word-break:break-word; }
  input, select, textarea, button { max-width:100%; }
  main, section, article, aside, nav, header, footer, form, fieldset { max-width:100%; }
  fieldset { min-inline-size:0; }

  /* 공통 카드/폼/버튼은 좁은 화면에서 컨테이너를 밀어내지 않음 */
  .container, .wrap, .suite-main, .free-shell, .legal-page,
  .login-card, .register-card, .message-card, .panel, .card,
  .reading-area, .side-panel, .tool-section, .plan-section, .stats-section,
  .qt-section, .prayer-section, .memory-section, .progress-section {
    min-width:0 !important;
    max-width:100% !important;
  }
  .actions, .controls, .form-actions, .free-actions, .suite-actions,
  .header-actions, .page-actions, .button-row, .action-row {
    min-width:0;
    max-width:100%;
    flex-wrap:wrap;
  }
  .actions > *, .controls > *, .form-actions > *, .free-actions > *,
  .suite-actions > *, .button-row > *, .action-row > * { min-width:0; }

  /* 샬롬이와 하단 학습 브리지가 서로 겹치지 않도록 간격 확보 */
  .kb-study-bridge {
    bottom:max(94px, calc(env(safe-area-inset-bottom) + 82px));
    max-width:calc(100vw - 20px);
  }
}

@media (max-width: 430px) {
  body { font-size:15px; }
  .kb-legal-upgrade { width:calc(100% - 12px); padding:16px; margin-inline:auto; }
  .free-shell { width:calc(100% - 14px) !important; }
  .free-hero { padding:20px !important; border-radius:22px !important; }
}

@media (max-width: 360px) {
  .kb-study-bridge { left:6px; right:6px; max-width:calc(100vw - 12px); gap:6px; padding:6px; }
  .kb-study-bridge__ref { max-width:104px; padding-inline:5px; }
  .kb-study-bridge a { padding-inline:9px; font-size:.75rem; }
}


/* 2026-08-13 touch target QA */
@media (max-width: 640px) {
  .tts-chip,
  .password-toggle,
  button.toggle,
  button[data-action],
  .icon-btn,
  .chip-btn {
    min-height:44px !important;
  }
}

/* 2026-08-14 final premium service integration + mobile QA */
.kb-study-bridge{
  width:min(980px,calc(100vw - 28px));max-width:none;min-height:62px;
  padding:8px 9px 8px 11px;border-radius:20px;
  background:linear-gradient(135deg,rgba(5,25,22,.96),rgba(10,15,27,.96));
  border:1px solid rgba(230,198,116,.20);
  box-shadow:0 22px 56px rgba(0,0,0,.38),inset 0 1px 0 rgba(255,255,255,.05);
  gap:10px;overflow:hidden;
}
.kb-study-bridge__identity{display:flex;align-items:center;gap:9px;min-width:175px;padding:0 6px 0 2px;flex:0 1 auto}
.kb-study-bridge__identity>b{display:grid;place-items:center;width:38px;height:38px;flex:0 0 38px;border-radius:12px;background:linear-gradient(135deg,rgba(95,211,169,.18),rgba(234,198,108,.18));border:1px solid rgba(255,255,255,.08);font-size:1.04rem}
.kb-study-bridge__identity>span{display:grid;gap:2px;min-width:0}
.kb-study-bridge__identity strong{color:#fff7e8;font-size:.78rem;font-weight:900;white-space:nowrap}
.kb-study-bridge__identity small{color:#9eafa8;font-size:.68rem;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:220px}
.kb-study-bridge__actions{display:flex;align-items:center;justify-content:center;gap:6px;min-width:0;flex:1 1 auto;overflow-x:auto;scrollbar-width:none}
.kb-study-bridge__actions::-webkit-scrollbar{display:none}
.kb-study-bridge__actions a{min-height:42px!important;display:inline-flex!important;align-items:center;justify-content:center;gap:6px;padding:0 12px!important;border-radius:13px!important;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.055)!important;color:#f5f2e9!important;font-size:.76rem!important;font-weight:800;text-decoration:none;white-space:nowrap;transition:background .18s ease,border-color .18s ease,transform .18s ease}
.kb-study-bridge__actions a:hover,.kb-study-bridge__actions a:focus-visible{background:linear-gradient(135deg,rgba(65,188,145,.16),rgba(230,196,108,.14))!important;border-color:rgba(230,196,108,.28);transform:translateY(-1px)}
.kb-study-bridge__close{width:40px;height:40px;min-height:40px!important;flex:0 0 40px;padding:0;border-radius:12px;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.045);color:#c3cec9;font-size:1.15rem;cursor:pointer}
.kb-study-bridge__close:hover{color:#fff;background:rgba(255,255,255,.09)}
body.kb-has-study-bridge{padding-bottom:max(82px,calc(env(safe-area-inset-bottom) + 76px))!important}

/* 가독성: 한글 제목은 어절 단위로, 긴 URL/영문은 컨테이너 밖으로 밀어내지 않음 */
h1,h2,h3,h4,.svc-title,.drawer-copy strong{word-break:keep-all;text-wrap:balance}
p,li,label,small,.svc-desc{word-break:keep-all;overflow-wrap:break-word;text-wrap:pretty}
a,input,textarea,select,button{min-width:0}
textarea{resize:vertical}
[hidden]{display:none!important}

/* 모바일: 320~430px에서도 가로 넘침과 고정 UI 겹침 방지 */
@media(max-width:760px){
  body.kb-has-study-bridge{padding-bottom:max(164px,calc(env(safe-area-inset-bottom) + 150px))!important}
  .kb-study-bridge{left:8px!important;right:8px!important;bottom:max(88px,calc(env(safe-area-inset-bottom) + 78px))!important;width:auto!important;max-width:none!important;transform:none!important;min-height:58px;padding:7px 7px 7px 9px;gap:7px;border-radius:18px;overflow:visible}
  .kb-study-bridge__identity{min-width:0;max-width:142px;flex:0 0 auto}
  .kb-study-bridge__identity>b{width:34px;height:34px;flex-basis:34px;border-radius:10px}
  .kb-study-bridge__identity strong{font-size:.72rem}.kb-study-bridge__identity small{font-size:.62rem;max-width:92px}
  .kb-study-bridge__actions{justify-content:flex-start;overflow-x:auto;overscroll-behavior-x:contain;scroll-snap-type:x proximity}
  .kb-study-bridge__actions a{min-height:40px!important;padding-inline:10px!important;font-size:.72rem!important;scroll-snap-align:start;flex:0 0 auto}
  .kb-study-bridge__close{width:36px;height:36px;min-height:36px!important;flex-basis:36px}
  .kb-shalom-launcher{bottom:max(14px,env(safe-area-inset-bottom))!important;right:10px!important}
  .kb-shalom-panel{left:8px!important;right:8px!important;width:auto!important;max-width:none!important;max-height:min(80dvh,720px)!important}
  dialog,[role="dialog"]{max-width:calc(100vw - 16px)}
  input,select,textarea{font-size:16px!important}
  table{max-width:100%}
}
@media(max-width:430px){
  .kb-study-bridge{left:6px!important;right:6px!important;padding-inline:6px}
  .kb-study-bridge__identity{max-width:112px}.kb-study-bridge__identity small{display:none}.kb-study-bridge__identity strong{font-size:.68rem}
  .kb-study-bridge__actions a span:first-child{font-size:.9rem}.kb-study-bridge__actions a span:last-child{font-size:.69rem}
}
@media(max-width:360px){
  .kb-study-bridge__identity{display:none}.kb-study-bridge__actions a{padding-inline:9px!important}
}
@media(prefers-reduced-motion:reduce){.kb-study-bridge__actions a{transition:none!important;transform:none!important}}

/* ── Final service QA: readability, accessibility & small-screen resilience ── */
html { scroll-padding-top: 92px; }
:where(main, section, article, form, nav) :where(h1,h2,h3,h4,[id]) { scroll-margin-top: 96px; }
:where(.kb-suite,.kb-listening-studio,.kb-speaking-studio,.kb-qt-studio,.kb-memory-studio,.kb-prayer-studio,.kb-vocab-studio,.ccm-app-shell,.video-app-shell,.mp-app) :where(p,li,dd,small,span,strong) {
  overflow-wrap: break-word;
}
:where(.kb-suite,.kb-listening-studio,.kb-speaking-studio,.kb-qt-studio,.kb-memory-studio,.kb-prayer-studio,.kb-vocab-studio,.ccm-app-shell,.video-app-shell,.mp-app) :where(button,a,input,textarea,select):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent, #69d9b1) 72%, white 28%);
  outline-offset: 3px;
}
:where(.kb-suite,.kb-listening-studio,.kb-speaking-studio,.kb-qt-studio,.kb-memory-studio,.kb-prayer-studio,.kb-vocab-studio,.ccm-app-shell,.video-app-shell,.mp-app) button,
:where(.kb-suite,.kb-listening-studio,.kb-speaking-studio,.kb-qt-studio,.kb-memory-studio,.kb-prayer-studio,.kb-vocab-studio,.ccm-app-shell,.video-app-shell,.mp-app) a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
:where(.kb-suite,.kb-listening-studio,.kb-speaking-studio,.kb-qt-studio,.kb-memory-studio,.kb-prayer-studio,.kb-vocab-studio,.ccm-app-shell,.video-app-shell,.mp-app) :where(input,textarea,select) {
  max-width: 100%;
}
:where(.kb-suite,.kb-listening-studio,.kb-speaking-studio,.kb-qt-studio,.kb-memory-studio,.kb-prayer-studio,.kb-vocab-studio,.ccm-app-shell,.video-app-shell,.mp-app) :where(table) {
  max-width: 100%;
}
.kb-scroll-guard { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }

/* Home service cards: equal rhythm even after the full service suite was added. */
.services-wrap .svc-grid { align-items: stretch; }
.services-wrap .svc-card { min-width:0; height:100%; }
.services-wrap .svc-card .svc-desc { line-height:1.68; text-wrap:pretty; }
.services-wrap .svc-card .svc-arrow { margin-top:auto; }
.quick-bar-inner { scrollbar-width:none; }
.quick-bar-inner::-webkit-scrollbar { display:none; }

/* Incoming verse context receives a subtle locator, never competing with active playback. */
.ls-verse-row.is-selected:not(.is-reading) {
  background: color-mix(in srgb, var(--ls-accent2, #f3c969) 7%, transparent);
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--ls-accent2, #f3c969) 76%, transparent);
}

@media (max-width: 760px) {
  html { scroll-padding-top: 76px; }
  :where(main, section, article, form, nav) :where(h1,h2,h3,h4,[id]) { scroll-margin-top: 80px; }
  body { -webkit-text-size-adjust:100%; }
  :where(.kb-suite,.kb-listening-studio,.kb-speaking-studio,.kb-qt-studio,.kb-memory-studio,.kb-prayer-studio,.kb-vocab-studio,.ccm-app-shell,.video-app-shell,.mp-app) :where(button,a[role="button"],input[type="button"],input[type="submit"]) {
    min-height: 44px;
  }
  :where(.kb-suite,.kb-listening-studio,.kb-speaking-studio,.kb-qt-studio,.kb-memory-studio,.kb-prayer-studio,.kb-vocab-studio,.ccm-app-shell,.video-app-shell,.mp-app) :where(input:not([type="checkbox"]):not([type="radio"]),textarea,select) {
    font-size:16px !important;
  }
  :where(.kb-suite,.kb-listening-studio,.kb-speaking-studio,.kb-qt-studio,.kb-memory-studio,.kb-prayer-studio,.kb-vocab-studio,.ccm-app-shell,.video-app-shell,.mp-app) :where(.modal,.ls-modal,.sp-modal,.qt-modal,[role="dialog"]) {
    max-width:100vw;
  }
  .services-wrap .svc-grid { gap:.8rem; }
  .services-wrap .svc-card { padding:1.05rem !important; }
  .services-wrap .svc-card .svc-desc { font-size:.82rem; }
  .quick-bar-inner { overflow-x:auto; flex-wrap:nowrap !important; justify-content:flex-start !important; padding-bottom:2px; }
  .quick-bar-inner .q-chip { flex:0 0 auto; min-height:38px; }
  .kb-shalom-panel { max-height:min(78dvh, 720px); }
}

@media (max-width: 430px) {
  :where(.kb-suite,.kb-listening-studio,.kb-speaking-studio,.kb-qt-studio,.kb-memory-studio,.kb-prayer-studio,.kb-vocab-studio,.ccm-app-shell,.video-app-shell,.mp-app) :where(h1) { line-height:1.12; }
  :where(.kb-suite,.kb-listening-studio,.kb-speaking-studio,.kb-qt-studio,.kb-memory-studio,.kb-prayer-studio,.kb-vocab-studio,.ccm-app-shell,.video-app-shell,.mp-app) :where(h2,h3) { line-height:1.28; }
  .kb-study-bridge__identity small { max-width:38vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .kb-study-bridge__actions { max-width:56vw; overflow-x:auto; scrollbar-width:none; }
  .kb-study-bridge__actions::-webkit-scrollbar { display:none; }
  .kb-study-bridge__actions a { flex:0 0 auto; }
  .kb-shalom-launcher { right:10px !important; }
}

@media (max-width: 360px) {
  .services-wrap .svc-card { padding:.9rem !important; }
  .services-wrap .svc-card .svc-title { font-size:1rem; }
  .services-wrap .svc-card .svc-desc { font-size:.78rem; }
  .kb-study-bridge { left:6px; right:6px; padding:7px; gap:6px; }
  .kb-study-bridge__identity strong { font-size:.72rem; }
  .kb-study-bridge__actions a { padding-inline:9px; font-size:.69rem; }
}
.kb-skip-link { position:fixed; left:14px; top:-80px; z-index:100000; padding:10px 14px; border-radius:12px; background:#f2d27f; color:#07140f!important; font-weight:900; text-decoration:none; box-shadow:0 14px 32px rgba(0,0,0,.28); transition:top .18s ease; }
.kb-skip-link:focus { top:max(8px,env(safe-area-inset-top)); }
body.kb-home-drawer-open { overflow:hidden; overscroll-behavior:none; }

/* Fixed mobile controls never cover Shalom or the learning bridge. */
@media (max-width:760px) {
  body:has(.bottom-tabs) .kb-shalom-launcher { bottom:max(78px,calc(env(safe-area-inset-bottom) + 68px))!important; }
  body.page-ccm:has(.ccm-mobile-dock:not([hidden])) .kb-study-bridge { bottom:max(92px,calc(env(safe-area-inset-bottom) + 82px))!important; }
  body.page-ccm:has(.ccm-mobile-dock:not([hidden])) .kb-shalom-launcher { bottom:max(164px,calc(env(safe-area-inset-bottom) + 154px))!important; }
}
