/* 조합원 화면 기초(휴대전화 우선). 고령 조합원이 휴대전화로 읽는 것이 기준이다(DESIGN.md).
   색은 lm-tokens.css의 --lm- 변수만 쓴다. 이 파일에 hex를 두지 않는다. 크기·글자 단계는 아래 --rd- 변수다.
   읽는 순서: lm-tokens.css → fonts/pretendard/…dynamic-subset.css → fonts/brand-fonts.css → base.css (→ 관리 화면은 ops.css).
   CSP가 style 속성을 막으므로 크기·상태는 모두 클래스와 aria 속성으로 준다. */

/* ── 글자 단계. html.fs-l(크게)·html.fs-xl(아주 크게)는 ui.js가 기기에 기억해 붙인다 ── */

:root {
  --rd-fs-body: 18px;
  --rd-fs-h1: 26px;
  --rd-fs-h2: 20px;
  --rd-fs-small: 16px;
  --rd-fs-control: 20px;
  --rd-fs-tab: 15px;
  --rd-lh-body: 1.75;
  --rd-tap: 56px;
  --rd-tap-primary: 60px;
  --rd-page-max: 560px;
  --rd-gutter: 20px;
  --rd-bar-height: 68px;
  --rd-duration-color: 150ms;
  --rd-sheet-radius: var(--lm-radius-card);
}

html.fs-l {
  --rd-fs-body: 21px;
  --rd-fs-h1: 30px;
  --rd-fs-h2: 23px;
  --rd-fs-small: 18px;
  --rd-fs-control: 22px;
  --rd-fs-tab: 16px;
}

html.fs-xl {
  --rd-fs-body: 24px;
  --rd-fs-h1: 34px;
  --rd-fs-h2: 26px;
  --rd-fs-small: 20px;
  --rd-fs-control: 24px;
  --rd-fs-tab: 17px;
}

/* ── 기초 ── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--lm-bg-page);
  color: var(--lm-text);
  font-family: var(--lm-font-ui);
  font-size: var(--rd-fs-body);
  line-height: var(--rd-lh-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-synthesis: none;
  word-break: keep-all;
  overflow-wrap: anywhere;
  caret-color: var(--lm-primary);
  accent-color: var(--lm-primary);
}

::selection {
  background: var(--lm-bg-selected);
  color: var(--lm-text-strong);
}

[hidden] {
  display: none !important;
}

:where(button, input, textarea, select) {
  font: inherit;
  color: inherit;
}

:where(h1, h2, h3, p, ul, ol, figure, blockquote) {
  margin: 0;
}

:where(img, svg) {
  max-width: 100%;
}

:where(h1, h2, h3, strong) {
  color: var(--lm-text-strong);
}

h1 {
  font-size: var(--rd-fs-h1);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h2 {
  font-size: var(--rd-fs-h2);
  font-weight: 700;
  line-height: 1.45;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

/* 쪽수·날짜·안내 같은 보조 글. muted는 네 바탕 모두에서 4.5:1을 넘는다(lm-tokens.css) */
.small {
  font-size: var(--rd-fs-small);
  line-height: 1.6;
  color: var(--lm-text-muted);
}

/* 화면에서만 tabular. 인쇄본(크롬 PDF)에서 tabular 숫자는 복사·검색에서 사라진다 */
@media screen {
  .num {
    font-variant-numeric: tabular-nums;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── 링크·포커스 ── */

:where(a) {
  color: inherit;
}

.link {
  color: var(--lm-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color var(--rd-duration-color) var(--lm-ease-out);
}

.link:hover {
  color: var(--lm-primary-hover);
}

:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: var(--lm-focus-ring);
  outline-offset: 3px;
}

/* ── 한 열 페이지. 360px 화면에서도 가로로 넘치지 않는다 ── */

.page {
  width: 100%;
  max-width: var(--rd-page-max);
  margin: 0 auto;
  padding: var(--lm-space-24) var(--rd-gutter) var(--lm-space-48);
}

/* 아래 고정 막대가 있는 화면은 마지막 줄이 막대 뒤에 숨지 않게 띄운다 */
body.has-bar .page {
  padding-bottom: calc(var(--rd-bar-height) + var(--lm-safe-bottom) + var(--lm-space-32));
}

.stack {
  display: grid;
  align-content: start;
  gap: var(--lm-space-16);
}

/* ── 아이콘(icons.svg 스프라이트) ── */

.icon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon.is-20 {
  width: 20px;
  height: 20px;
}

/* ── 단추. 주 단추(primary)는 한 화면에 하나. 누르는 자리 56px, 주 단추 60px, 단추 사이 12px ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--lm-space-8);
  min-height: var(--rd-tap);
  min-width: var(--rd-busy-width, auto);
  padding: var(--lm-space-8) var(--lm-space-20);
  border: 1px solid var(--lm-border-strong);
  border-radius: var(--lm-radius);
  background: var(--lm-bg-surface);
  color: var(--lm-text-strong);
  font-size: var(--rd-fs-control);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition:
    background-color var(--rd-duration-color) var(--lm-ease-out),
    border-color var(--rd-duration-color) var(--lm-ease-out),
    color var(--rd-duration-color) var(--lm-ease-out);
}

.btn.primary {
  min-height: var(--rd-tap-primary);
  border-color: var(--lm-primary);
  background: var(--lm-primary);
  color: var(--lm-on-primary);
}

.btn.secondary {
  border-color: var(--lm-border-strong);
  background: var(--lm-bg-surface);
  color: var(--lm-text-strong);
}

/* 테두리 없는 단추. 글자는 링크처럼 보이되 누르는 자리는 56px을 지킨다 */
.btn.quiet {
  border-color: transparent;
  background: transparent;
  color: var(--lm-primary);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn.block {
  width: 100%;
}

@media (hover: hover) {
  .btn:hover {
    border-color: var(--lm-text);
    background: var(--lm-bg-subtle);
  }

  .btn.primary:hover {
    border-color: var(--lm-primary-hover);
    background: var(--lm-primary-hover);
  }

  .btn.quiet:hover {
    border-color: transparent;
    background: var(--lm-bg-selected);
  }
}

.btn.primary:active {
  border-color: var(--lm-primary-pressed);
  background: var(--lm-primary-pressed);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
}

/* 고른 상태가 있는 단추(글자 크기 보통·크게·아주 크게). 화면 읽기 프로그램은 aria-pressed로 읽는다 */
.btn[aria-pressed="true"],
.btn[aria-pressed="true"]:hover {
  border-color: var(--lm-primary);
  background: var(--lm-bg-selected);
  color: var(--lm-text-strong);
  box-shadow: inset 0 0 0 1px var(--lm-primary);
}

.btn[aria-busy="true"] {
  cursor: progress;
  opacity: 1;
}

.actions {
  display: grid;
  gap: var(--lm-space-12);
}

/* ── 입력. 글자 20px(16px보다 작으면 iOS가 화면을 확대한다) ── */

.field {
  display: grid;
  gap: var(--lm-space-8);
}

.field > label,
.label {
  color: var(--lm-text-strong);
  font-size: var(--rd-fs-body);
  font-weight: 600;
  line-height: 1.5;
}

:where(input:not([type="checkbox"]):not([type="radio"]), textarea, select) {
  width: 100%;
  min-height: var(--rd-tap);
  padding: var(--lm-space-12) var(--lm-space-16);
  border: 1px solid var(--lm-border-strong);
  border-radius: var(--lm-radius);
  background: var(--lm-bg-surface);
  color: var(--lm-text-strong);
  font-size: var(--rd-fs-control);
  line-height: 1.5;
  transition: border-color var(--rd-duration-color) var(--lm-ease-out);
}

:where(textarea) {
  min-height: 168px;
  resize: vertical;
}

:where(input, textarea, select):focus-visible {
  border-color: var(--lm-primary);
}

:where(input, textarea, select)[aria-invalid="true"] {
  border-color: var(--lm-danger);
}

:where(input, textarea)::placeholder {
  color: var(--lm-text-muted);
  opacity: 1;
}

:where(input, textarea, select):disabled {
  background: var(--lm-bg-subtle);
  color: var(--lm-text-muted);
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--lm-space-8);
  color: var(--lm-danger);
  font-size: var(--rd-fs-small);
  line-height: 1.6;
}

/* 열람 코드 6자리. 칸 하나에 숫자를 크게, 자리마다 간격을 둔다(inputmode="numeric" autocomplete="one-time-code"는 HTML에서) */
.code-input {
  max-width: 340px;
  min-height: 76px;
  padding: var(--lm-space-8) var(--lm-space-16);
  font-family: "JetBrains Mono", var(--lm-font-mono);
  font-size: 36px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.4em;
  text-align: center;
  text-indent: 0.4em;
}

/* ── 아래에서 올라오는 창(<dialog class="sheet">). 원문 창·확인 창이 쓴다 ── */

dialog.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: var(--rd-page-max);
  max-height: 88dvh;
  margin: 0 auto;
  padding: 0;
  border: 1px solid var(--lm-border);
  border-bottom: 0;
  border-radius: var(--rd-sheet-radius) var(--rd-sheet-radius) 0 0;
  background: var(--lm-bg-surface);
  color: var(--lm-text);
  box-shadow: var(--lm-shadow-sheet);
  overflow: hidden;
}

dialog.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: rd-sheet-up var(--lm-duration) var(--lm-ease-out);
}

dialog.sheet::backdrop {
  background: var(--lm-scrim);
}

@keyframes rd-sheet-up {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.sheet-head {
  padding: var(--lm-space-20) var(--rd-gutter) var(--lm-space-12);
  border-bottom: 1px solid var(--lm-hairline);
}

.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--lm-space-16) var(--rd-gutter);
}

.sheet-actions {
  display: grid;
  gap: var(--lm-space-12);
  padding: var(--lm-space-12) var(--rd-gutter) calc(var(--lm-space-16) + var(--lm-safe-bottom));
  border-top: 1px solid var(--lm-hairline);
}

/* ── 아래 고정 막대 [질문하기][우리 집][인쇄본]. 모든 조합원 화면에서 같은 자리 ── */

.bottom-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: var(--lm-z-bar);
  padding-bottom: var(--lm-safe-bottom);
  border-top: 1px solid var(--lm-border);
  background: var(--lm-bg-surface);
}

.bottom-bar > ul {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: var(--rd-page-max);
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.bottom-bar a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--lm-space-4);
  min-height: var(--rd-bar-height);
  color: var(--lm-text);
  font-size: var(--rd-fs-tab);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: color var(--rd-duration-color) var(--lm-ease-out);
}

.bottom-bar a[aria-current="page"] {
  color: var(--lm-primary);
}

.bottom-bar a[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 0;
  right: 20%;
  left: 20%;
  height: 3px;
  background: var(--lm-primary);
}

/* ── 예시 띠. 화면 맨 위, 실제 조합 자료가 아님을 밝힌다 ── */

.example-banner {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: var(--lm-space-8);
  padding: var(--lm-space-12) var(--rd-gutter);
  border-bottom: 1px solid var(--lm-warning-accent);
  background: var(--lm-warning-surface);
  color: var(--lm-warning-text);
  font-size: var(--rd-fs-small);
  font-weight: 600;
  line-height: 1.5;
}

/* ── 안내 바닥. "이 화면의 어떤 표시도 동의나 의결이 아닙니다…" 읽혀야 하므로 muted가 아니라 text ── */

.notice-foot {
  margin-top: var(--lm-space-48);
  padding-top: var(--lm-space-20);
  border-top: 1px solid var(--lm-hairline);
  color: var(--lm-text);
  font-size: var(--rd-fs-small);
  line-height: 1.6;
}

/* ── 로고 ── */

.brand-logo {
  display: block;
  width: auto;
  height: 20px;
}

/* ── 움직임 줄이기: 색 전환·창 올라오기 모두 끈다 ── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
