/* Layout only. Shared viewport geometry keeps screen switches and fixed navigation aligned. */
html { overflow-y: scroll; scrollbar-gutter: stable; scroll-padding-bottom: 110px; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
body[data-ui] { overflow-wrap: anywhere; }
body[data-ui] :where(main, section, article, header, nav, div, form, fieldset, label) { min-width: 0; }
body[data-ui] :where(img, video, iframe) { max-width: 100%; }
body[data-ui] :where(button, input, select, textarea) { max-width: 100%; }
body[data-ui] :where(button, a, summary, input, select, textarea):focus-visible { outline: 3px solid #2176c1; outline-offset: 3px; }
body[data-ui] :where(input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea) { min-width: 0; font-size: 16px; }
body[data-ui] :where(button, summary) { touch-action: manipulation; }
body[data-ui] :where(.button, .small-button, .back, .member-link, .history-link) { min-height: 44px; }
body[data-ui] :where(.status, .message, .empty, .lead) { line-height: 1.7; }
body[data-ui] :where(.row, .data-row, .member-row, .history-candidate, .top) > * { min-width: 0; }
body[data-ui] :where(.top, .top-actions) { flex-wrap: wrap; row-gap: 10px; }
body[data-ui] :where(.brand) { min-width: 0; }
body[data-ui] :where(.brand img, .logo) { flex-shrink: 0; }
body[data-ui] :where(.app-name, .brand-title) { white-space: normal; }
body[data-ui] :where(.info strong, .field strong, .member-row strong, .history-candidate strong, .data-row strong) { overflow-wrap: anywhere; }

/* Member app: the shell and the existing five-button dock share one width. */
body[data-ui=member] { --shell-width: 1160px; }
body[data-ui=member] .app { width: 100%; max-width: var(--shell-width); padding-inline: clamp(16px, 3vw, 32px); padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
body[data-ui=member] .nav { inset-inline: 0; left: 0; right: 0; transform: none; margin-inline: auto; width: auto; max-width: var(--shell-width); padding-inline: clamp(12px, 3vw, 32px); box-shadow: 0 -4px 18px #0000000c; }
body[data-ui=member] .nav button { min-width: 0; min-height: 52px; font-size: 10px; white-space: nowrap; }
body[data-ui=member] .nav i { max-width: 64px; margin: 0 auto 3px; }
body[data-ui=member] .screen { width: 100%; }
body[data-ui=member] .title { font-size: clamp(25px, 3vw, 32px); line-height: 1.4; }
body[data-ui=member] :where(.card p, .home-positive-message, .visit-weekly p, .visit-badge p, .pro-record-message, .bjj-record-message) { font-size: 14px; line-height: 1.7; }
body[data-ui=member] :where(.card h3, .bjj-record-event-head strong) { font-size: 16px; line-height: 1.5; }
body[data-ui=member] :where(.eyebrow, .app-name small, .pro-record-label, .bjj-record-label, .visit-summary-label, .tech-feature-label) { font-size: 12px; }
body[data-ui=member] :where(.tabs button, .home-gym-tabs button, .visit-history-tabs button, .ranking-division-tabs button) { min-height: 44px; min-width: 0; font-size: 13px; }
body[data-ui=member] :where(.history-page-controls button, .visit-month-controls button, .video-dialog-close, .member-card-close) { min-width: 44px; min-height: 44px; }
body[data-ui=member] .card { padding: 18px; margin-bottom: 14px; }
body[data-ui=member] .info-list { padding-block: 0; }
body[data-ui=member] .info { font-size: 14px; }
body[data-ui=member] .info > span { flex: 0 1 42%; }
body[data-ui=member] .info > strong { min-width: 0; }
body[data-ui=member] .event .row { flex-wrap: wrap; }
body[data-ui=member] .event .row > div { flex: 1 1 180px; }
body[data-ui=member] .event .tag { white-space: normal; }
body[data-ui=member] .tech-video-copy p { font-size: 13px; }
body[data-ui=member] .tech-video-meta { flex-wrap: wrap; font-size: 12px; }
body[data-ui=member] .tech-category small { font-size: 12px; }
body[data-ui=member] .home-section { margin-top: 22px; }
body[data-ui=member] .home-visit-area { margin-block: 0 18px; }
body[data-ui=member] .clap-home small { font-size: 13px; }
body[data-ui=member] .achievement-stars { flex-wrap: wrap; }
body[data-ui=member] .achievement-stars summary { padding-block: 8px; min-height: 44px; line-height: 1.7; }
body[data-ui=member] .achievement-load-state { font-size: 13px; }
body[data-ui=member] .bjj-record-stat span { font-size: 11px; letter-spacing: 0; }
body[data-ui=member] :where(.pro-record-fight-date, .pro-record-fight-main span, .pro-record-result small, .bjj-record-event-head time, .bjj-record-event-head small, .bjj-record-division span) { font-size: 12px; line-height: 1.6; }
body[data-ui=member] .pro-record-fight { grid-template-columns: 78px minmax(0,1fr) auto; }
body[data-ui=member] .bjj-record-division b { color: var(--ink); }
body[data-ui=member] .pro-record-result.is-win b { color: #8b1d1d; }
body[data-ui=member] .pro-theme .pro-record-result.is-win b { color: #ff7777; }
body[data-ui=member] .pro-theme .visit-history-tabs button[aria-selected=true] { color: #fff; }
body[data-ui=member] .video-dialog-box { width: min(100%, 820px); }
body[data-ui=member] .clap-dialog { max-width: 680px; }
body[data-ui=member] .member-card-dialog { width: min(100%, 440px); }
body[data-ui=member] .mypage-reload { margin-top: 24px; }
body[data-ui=member] #logout-button { margin-top: 14px; }
body[data-ui=member] :where(button, input, select, textarea) { scroll-margin-bottom: 110px; }

/* Readable working surfaces for staff and administration. */
body[data-ui=admin] .app, body[data-ui=staff] .app { max-width: 1160px; padding-inline: clamp(16px, 3vw, 32px); }
body[data-ui=admin] .tools { gap: 12px; }
body[data-ui=admin] .tools button { min-height: 76px; font-size: 14px; line-height: 1.5; }
body[data-ui=admin] .tools button small { font-size: 12px; line-height: 1.5; }
body[data-ui=admin] :where(.card, .period-card), body[data-ui=staff] .card { padding: 20px; }
body[data-ui=admin] :where(.field label, .field .field-label, .member-row small, .data-row small), body[data-ui=staff] :where(.member small, .sync, .list-count, .basic-sub, .record-meta) { font-size: 13px; line-height: 1.6; }
body[data-ui=admin] .field { grid-template-columns: 110px minmax(0,1fr); }
body[data-ui=admin] .field input, body[data-ui=admin] .field select { min-height: 44px; }
body[data-ui=admin] .field input { text-align: left; }
body[data-ui=admin] :where(.notice-row, .history-item) { grid-template-columns: minmax(0,1fr) 132px; }
body[data-ui=admin] :where(.notice-actions, .history-actions) { width: 132px; }
body[data-ui=admin] :where(.notice-actions, .history-actions) .small-button { height: auto; min-height: 44px; font-size: 12px; }
body[data-ui=admin] :where(.member-list, #application-list) { gap: 12px; }
body[data-ui=admin] :where(.member-row, .history-candidate, .overview-day, .data-row) { padding: 14px 8px; }
body[data-ui=admin] .overview-day.selected { margin: 0; }
body[data-ui=admin] :where(.field-help, .application-admin-field small) { font-size: 12px; line-height: 1.6; }
body[data-ui=admin] :where(#member-editor, #notice-form, #tech-video-form, #checkin-editor, #checkin-add-form, #application-detail) { max-width: 820px; margin-inline: auto; }
body[data-ui=admin] :where(.video-list-item, .application-row) { min-width: 0; }
body[data-ui=staff] .member { min-height: 140px; font: inherit; }
body[data-ui=staff] .member strong { font-size: 16px; line-height: 1.5; }
body[data-ui=staff] .filters label { font-size: 13px; }
body[data-ui=staff] .record-tools { flex-wrap: wrap; }
body[data-ui=staff] #athlete-detail-view { max-width: 900px; margin-inline: auto; }

/* Login and public forms retain a comfortable reading width. */
body[data-ui=login] main, body[data-ui=result] main { max-width: 600px; padding-inline: clamp(20px, 4vw, 40px); }
body[data-ui=login] .brand { margin-bottom: 36px; }
body[data-ui=login] .title { font-size: clamp(30px, 5vw, 38px); }
body[data-ui=login] .line-button { font-size: 22px; min-height: 56px; }
body[data-ui=login] #login-retry { min-height: 44px; }
body[data-ui=join] main, body[data-ui=withdraw] .withdraw-page { max-width: 820px; padding-inline: clamp(16px, 3vw, 28px); }
body[data-ui=join] :where(.hint, .rules, .foot, .field label), body[data-ui=withdraw] .note { font-size: 13px; line-height: 1.7; }
body[data-ui=join] .grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
body[data-ui=join] .fee-table { table-layout: fixed; font-size: 12px; }
body[data-ui=join] summary { min-height: 44px; padding-block: 10px; }
body[data-ui=withdraw] input[type=month], body[data-ui=join] input[type=date] { appearance: none; -webkit-appearance: none; min-width: 0; width: 100%; }

@media (min-width:768px) {
  body[data-ui=member] .top { padding-block: 22px; }
  body[data-ui=member] .nav button { font-size: 13px; }
  body[data-ui=member] #home.active { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); column-gap: 24px; align-items: start; }
  body[data-ui=member] #home > * { grid-column: 1 / -1; }
  body[data-ui=member] #home > :is(#today-schedule,.home-visit-area,.home-section) { grid-column: auto; }
  body[data-ui=member] #visit-stat-error:not([hidden]) { grid-row: auto; }
  body[data-ui=member] :where(#schedule-content, #tech-featured, #tech-video-list) { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; align-items: start; }
  body[data-ui=member] #schedule-content .schedule-day { grid-column: 1 / -1; font-size: 15px; padding-top: 20px; }
  body[data-ui=member] #schedule-content .card { margin: 0; }
  body[data-ui=member] :where(#schedule-content, #tech-featured, #tech-video-list) > :is(p,.data-load-error,.retry-action) { grid-column: 1 / -1; }
  body[data-ui=member] .tech-video-card + .tech-video-card { margin: 0; padding: 0; border: 0; }
  body[data-ui=member] .tech-categories { grid-template-columns: repeat(4,minmax(0,1fr)); }
  body[data-ui=member] .visit-summary { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 16px; }
  body[data-ui=member] .visit-summary > * { grid-column: 1 / -1; margin: 0; }
  body[data-ui=member] .visit-summary > :is(.visit-weekly,.visit-badge,.achievement-stars) { grid-column: span 3; }
  body[data-ui=member] .info-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); column-gap: 28px; }
  body[data-ui=member] .info:last-child { border-bottom: 1px solid var(--line); }
  body[data-ui=member] .bjj-record-tournaments { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
  body[data-ui=member] .bjj-record-tournament { border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
  body[data-ui=member] .pro-record-metrics { grid-template-columns: repeat(3,minmax(0,1fr)); }
  body[data-ui=member] .pro-record-metric.is-wide { grid-column: auto; }
  body[data-ui=member] .clap-members { grid-template-columns: repeat(2,minmax(0,1fr)); }
  body[data-ui=admin] .tools { grid-template-columns: repeat(4,minmax(0,1fr)); }
  body[data-ui=admin] #member-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  body[data-ui=admin] #visits.is-active { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); column-gap: 24px; align-items: start; }
  body[data-ui=admin] #visits > :is(h2,p) { grid-column: 1 / -1; }
  body[data-ui=admin] .visit-support { margin: 0; padding: 0; border: 0; }
  body[data-ui=staff] #athlete-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (min-width:1024px) {
  body[data-ui=member] .visit-summary > :is(.visit-goal,.visit-weekly,.visit-badge) { grid-column: span 2; }
  body[data-ui=member] :where(#tech-featured,#tech-video-list) { grid-template-columns: repeat(3,minmax(0,1fr)); }
  body[data-ui=member] .tech-video-card { grid-template-columns: 1fr; gap: 10px; }
  body[data-ui=member] .tech-thumbnail { height: auto; aspect-ratio: 16 / 9; }
  body[data-ui=member] .tech-video-card { padding: 6px; }
}
@media (min-width:1200px) {
  body[data-ui=staff] #athlete-list { grid-template-columns: repeat(3,minmax(0,1fr)); }
  body[data-ui=member] #schedule-content { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width:767px) {
  body[data-ui=member] :where(.app,.nav) { max-width: 100%; }
  body[data-ui=member] .top-actions { gap: 6px; }
  body[data-ui=member] .app-name { font-size: 11px; }
  body[data-ui=member] .app-name small { font-size: 10px; }
  body[data-ui=member] .brand { gap: 7px; }
  body[data-ui=member] .member-card-button { min-height: 44px; }
  body[data-ui=admin] .tools { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width:560px) {
  body[data-ui=join] .grid { grid-template-columns: minmax(0,1fr); }
  body[data-ui=admin] .field { grid-template-columns: minmax(0,1fr); gap: 7px; }
  body[data-ui=admin] .field > strong, body[data-ui=admin] .field select { text-align: left; }
  body[data-ui=admin] :where(.notice-row,.history-item) { grid-template-columns: minmax(0,1fr); }
  body[data-ui=admin] :where(.notice-actions,.history-actions) { width: 100%; max-width: 240px; justify-self: end; }
  body[data-ui=member] .bjj-record-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
