/* ============================================================
   Hi5GoodBuddy — 모임 원우수첩 웹앱
   모바일 우선 / 데스크톱 겸용 / WCAG 2.2 AA 지향
   ============================================================ */

/* ---------- 1. 디자인 토큰 ---------- */
:root {
  color-scheme: light dark;

  /* 남색 계열.
     대비는 눈대중이 아니라 계산으로 맞췄다(WCAG 2.2). 아래 괄호는 흰 카드 위 대비다.
     색을 손볼 때는 이 숫자가 기준 아래로 내려가지 않는지 먼저 확인할 것. */
  --brand: #1F3F73;         /* 큰 버튼 배경 · 선택된 탭 글자 (10.4) */
  --brand-strong: #16305A;  /* 링크 · 눌렀을 때 (13.1) */
  --brand-soft: #E7EDF8;    /* 옅은 남색 바탕 — 배지·고정 공지 */
  --brand-ink: #FFFFFF;     /* 남색 위 글자 (10.4) */

  /* 보조색 — 관리진 표시처럼 '주의가 아닌 구분'에 쓴다 */
  --teal: #0F766E;
  --teal-soft: #E1F0EE;

  /* 바탕은 남색과 같은 계열의 아주 옅은 회청색이다.
     따뜻한 베이지 위에 남색을 올리면 색이 서로 밀어낸다. */
  --bg: #F5F7FA;
  --bg-elev: #FFFFFF;
  --bg-sunken: #EEF1F6;
  --line: #E1E6EF;
  --line-strong: #C7CFDC;

  --ink: #101828;           /* 본문 (17.8) */
  --ink-2: #48566A;         /* 보조 (7.5) */
  --ink-3: #58636F;         /* 힌트 — 대리석 결이 가장 진하게 겹친 자리에서도 4.9 */

  /* 내 모임 목록의 수첩 표지 — 베이지 바탕 + 남색 테두리 */
  --book: #EFE7D9;
  --book-ink: #16305A;      /* 표지 위 글자 (10.7) */

  --ok: #146B4C;
  --ok-soft: #E4F2EB;
  --warn: #7A5405;
  --warn-soft: #FBF0DA;
  --danger: #A32720;
  --danger-soft: #FAE9E7;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-full: 999px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* 그림자도 남색을 머금게 한다. 회색 그림자는 남색 위에서 탁해 보인다. */
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-2: 0 4px 14px rgba(16, 24, 40, .08);
  --shadow-3: 0 12px 32px rgba(16, 24, 40, .18);

  --tap: 44px;                /* 최소 터치 타깃 */
  --rail: 264px;              /* 데스크톱 사이드바 */
  --maxw: 1080px;
  --safe-b: env(safe-area-inset-bottom, 0px);

  --font: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont,
          "Apple SD Gothic Neo", "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* 어두운 화면에서는 남색을 배경이 아니라 글자색으로 쓴다.
       진한 남색을 그대로 두면 바탕에 묻혀 글자가 사라진다. */
    --brand: #9BB8E8;         /* 카드 위 대비 8.3 */
    --brand-strong: #C3D5F2;  /* 11.2 */
    --brand-soft: #1C2740;
    --brand-ink: #0B1526;     /* 밝은 남색 버튼 위 글자 9.1 */

    --teal: #6FD5C6;
    --teal-soft: #0E2B28;

    --bg: #0E1420;
    --bg-elev: #161E2D;
    --bg-sunken: #090E17;
    --line: #263043;
    --line-strong: #3A4659;

    --ink: #EAF0F8;
    --ink-2: #C0CADA;
    --ink-3: #909CAE;         /* 6.0 */

    /* 어두운 화면에서는 베이지를 그대로 쓰면 혼자 튄다. 가라앉은 모래색으로 */
    --book: #2A2620;
    --book-ink: #EAF0F8;    /* 13.1 */

    --ok: #6BD79B;      --ok-soft: #0F2A1E;
    --warn: #E9B44C;    --warn-soft: #2C2208;
    --danger: #FF9089;  --danger-soft: #331413;

    --shadow-1: 0 1px 2px rgba(0,0,0,.5);
    --shadow-2: 0 4px 14px rgba(0,0,0,.5);
    --shadow-3: 0 12px 32px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --brand: #9BB8E8; --brand-strong: #C3D5F2; --brand-soft: #1C2740; --brand-ink: #0B1526;
  --teal: #6FD5C6; --teal-soft: #0E2B28;
  --bg: #0E1420; --bg-elev: #161E2D; --bg-sunken: #090E17;
  --line: #263043; --line-strong: #3A4659;
  --ink: #EAF0F8; --ink-2: #C0CADA; --ink-3: #909CAE;
  --book: #2A2620; --book-ink: #EAF0F8;
  --ok: #6BD79B; --ok-soft: #0F2A1E; --warn: #E9B44C; --warn-soft: #2C2208;
  --danger: #FF9089; --danger-soft: #331413;
  --shadow-1: 0 1px 2px rgba(0,0,0,.5);
  --shadow-2: 0 4px 14px rgba(0,0,0,.5);
  --shadow-3: 0 12px 32px rgba(0,0,0,.6);
}

/* ---------- 2. 리셋 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* 바탕 — 옅은 대리석.
   ------------------------------------------------------------
   글자는 거의 다 카드(단색 --bg-elev) 위에 얹히고, 결은 그 **뒤쪽**에만 깔린다.
   그래서 대비가 흔들리지 않는다. 결의 진하기는 전부 5% 이하다.
   더 진하게 만들지 말 것 — 바탕에 바로 놓인 소제목이 흐려진다. */
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    /* 왼쪽 위에서 들어오는 빛 */
    radial-gradient(120% 85% at 10% -12%, rgba(255, 255, 255, .9), transparent 58%),
    /* 돌의 얼룩 */
    radial-gradient(85% 65% at 88% 2%,  color-mix(in srgb, var(--brand) 6%, transparent), transparent 60%),
    radial-gradient(70% 60% at 25% 104%, color-mix(in srgb, var(--brand) 6%, transparent), transparent 62%),
    /* 결 — 넓게 번지는 사선. 좁고 또렷하게 만들면 대리석이 아니라 긁힌 자국으로 보인다.
       그래서 양쪽으로 6~8%씩 흐려지도록 폭을 넓혔다. */
    linear-gradient(114deg, transparent 38%,
                            color-mix(in srgb, var(--brand) 4%, transparent) 46%,
                            transparent 54%),
    linear-gradient(99deg,  transparent 56%,
                            color-mix(in srgb, var(--brand) 3%, transparent) 63%,
                            transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
img, svg, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--brand-strong); }
[hidden] { display: none !important; }

/* ---------- 3. 접근성 유틸 ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; left: var(--sp-3); top: -100px; z-index: 200;
  background: var(--brand); color: var(--brand-ink);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  font-weight: 700; text-decoration: none; transition: top .15s;
}
.skip-link:focus { top: var(--sp-3); }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
@media (prefers-contrast: more) {
  :root { --line: var(--ink-3); --ink-3: var(--ink-2); }
}

/* ---------- 4. 레이아웃 ---------- */
.app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
/* 그리드 아이템의 자동 최소 크기(min-width:auto)를 끈다.
   긴 이름 하나가 트랙 전체를 늘려 가로 스크롤을 만드는 것을 막는다. */
.app > * { min-width: 0; }

/* DOM 순서는 헤더 → 내비 → 본문(읽기 순서).
   모바일에서는 내비를 화면 맨 아래 행에 배치한다. */
.topbar { grid-row: 1; }
.tabbar { grid-row: 3; }
.main   { grid-row: 2; }

.main {
  width: 100%;
  min-width: 0;
  max-width: var(--maxw);
  margin-inline: auto;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-10) + var(--safe-b));
}
.view { animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

/* 상단바 */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__in {
  max-width: var(--maxw); margin-inline: auto; min-width: 0;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  min-height: 60px;
}
.topbar__title { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; flex: 1;
  background: none; border: 0; padding: 0; cursor: pointer; text-align: left; color: inherit; }
.topbar__title > span { min-width: 0; }
.topbar__name, .topbar__sub {
  display: block; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__name { font-size: 1.0625rem; font-weight: 800; letter-spacing: -.02em; }
.topbar__sub { font-size: .75rem; color: var(--ink-3); }
.topbar__actions { display: flex; align-items: center; gap: var(--sp-1); }

/* 하단 탭 (모바일) */
.tabbar {
  position: sticky; bottom: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar__in {
  max-width: 560px; margin-inline: auto; min-width: 0;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 56px; min-width: 0; padding: var(--sp-2) var(--sp-1);
  background: none; border: 0; cursor: pointer;
  color: var(--ink-3); font-size: .6875rem; font-weight: 600;
  position: relative;
}
.tab[aria-current="page"] { color: var(--brand); }
.tab[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 50%; translate: -50% 0;
  width: 28px; height: 3px; border-radius: var(--r-full); background: var(--brand);
}
.tab svg { width: 22px; height: 22px; }
.tab__badge {
  position: absolute; top: 6px; left: calc(50% + 8px);
  min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: var(--r-full); background: var(--danger); color: #fff;
  font-size: .625rem; font-weight: 800; line-height: 17px; text-align: center;
}

/* 데스크톱: 좌측 레일 */
@media (min-width: 900px) {
  .app { grid-template-columns: var(--rail) 1fr; grid-template-rows: auto 1fr;
         grid-template-areas: "rail top" "rail main"; }
  .topbar { grid-area: top; grid-row: auto; }
  .main { grid-area: main; grid-row: auto; padding: var(--sp-6) var(--sp-6) var(--sp-10); }
  .tabbar {
    grid-area: rail; grid-row: auto; position: sticky; top: 0; align-self: start;
    height: 100dvh; border-top: 0; border-right: 1px solid var(--line);
    background: var(--bg-elev); padding: var(--sp-4) var(--sp-3);
    display: flex; flex-direction: column; gap: var(--sp-4);
  }
  .tabbar__brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2); }
  .tabbar__in { grid-auto-flow: row; grid-auto-columns: auto; gap: 2px; max-width: none; }
  .tab {
    flex-direction: row; justify-content: flex-start; gap: var(--sp-3);
    min-height: var(--tap); padding: 0 var(--sp-3);
    border-radius: var(--r-md); font-size: .9375rem;
  }
  .tab:hover { background: var(--bg-sunken); }
  .tab[aria-current="page"] { background: var(--brand-soft); }
  .tab[aria-current="page"]::before { display: none; }
  .tab__badge { position: static; margin-left: auto; }
}
@media (max-width: 899px) { .tabbar__brand { display: none; } }

/* ---------- 5. 타이포 ---------- */
.page-head { margin-bottom: var(--sp-5); }
.eyebrow { font-size: .8125rem; font-weight: 800; color: var(--brand); letter-spacing: -.01em; }
.h1 { font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 800; letter-spacing: -.03em;
  line-height: 1.25; overflow-wrap: anywhere; }
.h2 { font-size: 1.125rem; font-weight: 800; letter-spacing: -.02em; }
.h3 { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.lede { color: var(--ink-2); margin-top: var(--sp-2); }
.muted { color: var(--ink-3); font-size: .875rem; }
.tiny { font-size: .75rem; color: var(--ink-3); line-height: 1.5; }
.section { margin-top: var(--sp-8); }
.section__head { display: flex; align-items: baseline; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.section__head .h2 { flex: 1; }

/* ---------- 6. 카드/표면 ---------- */
/* 카드는 단색이 원칙이다. 아래쪽에만 3% 결을 얹어 갈아 놓은 돌처럼 보이게 한다
   (이 정도면 가장 옅은 힌트 글자도 대비 4.5 를 넘긴다). */
.card {
  background: var(--bg-elev)
              linear-gradient(180deg, transparent 55%,
                              color-mix(in srgb, var(--brand) 3%, transparent) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-1);
}
.card--flat { box-shadow: none; }
.stack > * + * { margin-top: var(--sp-3); }
.stack-lg > * + * { margin-top: var(--sp-5); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- 7. 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 var(--sp-5);
  border: 1px solid transparent; border-radius: var(--r-md);
  background: var(--bg-elev); color: var(--ink);
  font-weight: 700; font-size: .9375rem; letter-spacing: -.01em;
  cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.btn--lg svg { width: 20px; height: 20px; }
.btn--sm svg { width: 15px; height: 15px; }
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
/* 큰 버튼 — 위가 아주 살짝 밝은 남색이라 눌리는 물체처럼 보인다.
   글자는 언제나 --brand-ink 한 가지다. 배경을 옅게 만들지 않는다. */
.btn--primary {
  background: linear-gradient(180deg,
              color-mix(in srgb, var(--brand) 88%, #FFFFFF) 0%,
              var(--brand) 100%);
  color: var(--brand-ink);
  border-color: color-mix(in srgb, var(--brand) 72%, #000000);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .18),
              inset 0 1px 0 rgba(255, 255, 255, .16);
}
.btn--primary:hover:not([disabled]) {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
}
.btn--primary:active:not([disabled]) {
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .22);
}
/* 작은 버튼 — 남색을 테두리와 글자에만 얹는다. 면으로 칠하면 화면이 시끄럽다 */
.btn--ghost { background: transparent; border-color: var(--line-strong); }
.btn--ghost:hover:not([disabled]) {
  background: var(--bg-sunken);
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line-strong));
}
.btn--quiet { background: transparent; border-color: transparent; color: var(--ink-2); padding: 0 var(--sp-3); }
.btn--quiet:hover:not([disabled]) { background: var(--bg-sunken); color: var(--brand-strong); }
.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn--block { width: 100%; }
.btn--lg { min-height: 54px; font-size: 1.0625rem; border-radius: var(--r-lg); }
.btn--sm { min-height: 36px; padding: 0 var(--sp-3); font-size: .8125rem; border-radius: var(--r-sm); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); flex: 0 0 auto;
  border: 0; border-radius: var(--r-full); background: transparent; color: var(--ink-2);
  cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--bg-sunken); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn__dot {
  position: absolute; top: 8px; right: 8px; width: 9px; height: 9px;
  border-radius: var(--r-full); background: var(--danger);
  border: 2px solid var(--bg);
}

/* ---------- 8. 폼 ---------- */
.field { display: block; }
.field + .field { margin-top: var(--sp-5); }
.field__label {
  display: flex; align-items: baseline; gap: var(--sp-2);
  font-weight: 700; font-size: .9375rem; margin-bottom: var(--sp-2);
}
.field__opt { margin-left: auto; font-size: .75rem; font-weight: 600; color: var(--ink-3); }
.field__req { color: var(--brand); font-size: .75rem; font-weight: 700; }
.field__hint { margin-top: var(--sp-2); font-size: .75rem; color: var(--ink-3); line-height: 1.5; }
.field__err { margin-top: var(--sp-2); font-size: .8125rem; font-weight: 600; color: var(--danger); }

.input, .textarea, .select {
  width: 100%; min-height: 52px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-elev); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: 132px; resize: vertical; line-height: 1.6; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%23857A72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M5 8l5 5 5-5'/></svg>");
  background-repeat: no-repeat; background-position: right var(--sp-4) center;
  padding-right: var(--sp-10);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }

/* 선택 카드 (구분 등) */
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.choice__item { position: relative; }
.choice__item input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice__box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-2); min-height: 96px; padding: var(--sp-4);
  background: var(--bg-elev); border: 2px solid var(--line);
  border-radius: var(--r-lg); font-weight: 700; font-size: .9375rem;
  transition: border-color .15s, background .15s;
}
.choice__emoji { font-size: 1.75rem; line-height: 1; }
.choice__item input:checked + .choice__box { border-color: var(--brand); background: var(--brand-soft); }
.choice__item input:focus-visible + .choice__box { outline: 3px solid var(--brand); outline-offset: 2px; }

/* 체크박스 */
.check { display: flex; align-items: flex-start; gap: var(--sp-3); cursor: pointer; padding: var(--sp-2) 0; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--brand); flex: 0 0 auto; }
.check__text { font-size: .9375rem; line-height: 1.55; }

/* ---------- 9. 아바타 ---------- */
.avatar {
  border-radius: var(--r-full); background: var(--bg-sunken);
  object-fit: cover; flex: 0 0 auto; overflow: hidden;
  display: grid; place-items: center;
  font-weight: 800; color: var(--brand-strong); letter-spacing: -.02em;
  border: 1px solid var(--line);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--xs { width: 28px; height: 28px; font-size: .6875rem; }
.avatar--sm { width: 40px; height: 40px; font-size: .8125rem; }
.avatar--md { width: 56px; height: 56px; font-size: 1.0625rem; }
.avatar--lg { width: 96px; height: 96px; font-size: 1.75rem; }
.avatar--xl { width: 148px; height: 148px; font-size: 2.75rem; }
.avatar--sq { border-radius: var(--r-lg); }

.photo-picker { display: grid; justify-items: center; gap: var(--sp-2); }
.photo-picker__wrap { position: relative; }
.photo-picker__btn {
  position: absolute; right: -2px; bottom: 4px;
  width: 44px; height: 44px; border-radius: var(--r-full);
  background: var(--brand); color: var(--brand-ink);
  border: 3px solid var(--bg); cursor: pointer;
  display: grid; place-items: center;
}
.photo-picker__btn svg { width: 20px; height: 20px; }

/* ---------- 10. 배지/칩 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px var(--sp-2); border-radius: var(--r-full);
  font-size: .6875rem; font-weight: 800; letter-spacing: -.01em;
  background: var(--bg-sunken); color: var(--ink-2);
}
.badge--brand { background: var(--brand-soft); color: var(--brand-strong); }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }

.chips { display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: var(--sp-1);
  scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 38px; padding: 0 var(--sp-4);
  display: inline-flex; align-items: center; gap: var(--sp-2);
  border-radius: var(--r-full); border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--ink-2);
  font-size: .8125rem; font-weight: 700; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg-elev); border-color: var(--ink); }

/* ---------- 11. 명부 목록 ---------- */
/* minmax(0,1fr) — 긴 이름이 트랙을 늘리지 못하게 한다 */
.roster { display: grid; gap: var(--sp-3); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 620px) { .roster { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 980px) { .roster { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.mcard {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-width: 0;
  padding: var(--sp-3); text-align: left; cursor: pointer;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  transition: border-color .15s, transform .08s, box-shadow .15s;
}
.mcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.mcard:active { transform: scale(.99); }
.mcard__body { min-width: 0; flex: 1; }
.mcard__name { font-weight: 800; letter-spacing: -.02em; min-width: 0;
  display: flex; align-items: center; gap: var(--sp-2); }
/* 이름은 줄여서 말줄임, 배지는 원래 크기를 지킨다 */
.mcard__name > span:first-child {
  min-width: 0; flex: 0 1 auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mcard__name > .badge { flex: 0 0 auto; white-space: nowrap; }
.mcard__meta { display: block; min-width: 0; font-size: .8125rem; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 12. 공지 ---------- */
.notice {
  display: flex; gap: var(--sp-3); padding: var(--sp-4);
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.notice--pinned { border-color: var(--brand); background: var(--brand-soft); }
.notice--system { background: var(--bg-sunken); box-shadow: none; }
.notice__ico {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: var(--r-full);
  display: grid; place-items: center; background: var(--brand-soft); font-size: 1.125rem;
}
.notice__body { min-width: 0; flex: 1; }
.notice__title { font-weight: 800; letter-spacing: -.02em; }
.notice__text { margin-top: 2px; color: var(--ink-2); font-size: .9375rem; white-space: pre-wrap;
  overflow-wrap: anywhere; }
.notice__foot { margin-top: var(--sp-2); display: flex; align-items: center;
  gap: var(--sp-2); font-size: .75rem; color: var(--ink-3); flex-wrap: wrap; }
.notice__new { animation: pop .35s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }

/* ---------- 13. 프로필 상세 ---------- */
.profile-hero { display: grid; justify-items: center; text-align: center; gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-4); }
.profile-name { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; }
.deflist { display: grid; gap: 1px; background: var(--line); border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid var(--line); }
.deflist__row { display: grid; grid-template-columns: 96px 1fr; gap: var(--sp-3);
  background: var(--bg-elev); padding: var(--sp-3) var(--sp-4); align-items: baseline; }
.deflist__k { font-size: .8125rem; font-weight: 700; color: var(--ink-3); }
.deflist__v { overflow-wrap: anywhere; }
.contact-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.embed { position: relative; padding-top: 56.25%; border-radius: var(--r-lg); overflow: hidden;
  background: var(--bg-sunken); }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- 14. 모달/시트 ---------- */
dialog.sheet {
  border: 0; padding: 0; background: transparent; color: inherit;
  max-width: 100%; max-height: 100dvh; width: 100%;
  margin: auto auto 0; /* 모바일: 바텀시트 */
}
dialog.sheet::backdrop { background: rgba(16, 12, 9, .55); backdrop-filter: blur(3px); }
.sheet__panel {
  background: var(--bg-elev); border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + var(--safe-b));
  max-height: 90dvh; overflow-y: auto;
  box-shadow: var(--shadow-3);
  animation: sheetin .22s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes sheetin { from { transform: translateY(18px); opacity: 0; } }
.sheet__grip { width: 40px; height: 4px; border-radius: var(--r-full); background: var(--line-strong);
  margin: 0 auto var(--sp-4); }
.sheet__head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.sheet__head .h2 { flex: 1; }
@media (min-width: 720px) {
  dialog.sheet { max-width: 560px; margin: auto; }
  .sheet__panel { border-radius: var(--r-xl); }
}

/* ---------- 15. 토스트 ---------- */
.toasts {
  position: fixed; left: 50%; translate: -50% 0; bottom: calc(76px + var(--safe-b));
  z-index: 120; display: grid; gap: var(--sp-2);
  width: min(440px, calc(100vw - 32px)); pointer-events: none;
}
@media (min-width: 900px) { .toasts { bottom: var(--sp-6); } }
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  background: var(--ink); color: var(--bg-elev);
  box-shadow: var(--shadow-3); font-size: .875rem; font-weight: 600;
  animation: toastin .22s ease both; pointer-events: auto;
}
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }
.toast--ok { background: var(--ok); color: #fff; }
.toast--err { background: var(--danger); color: #fff; }

/* ---------- 16. 빈 상태 / 로딩 ---------- */
.empty { text-align: center; padding: var(--sp-10) var(--sp-4); color: var(--ink-3); }
.empty__emoji { font-size: 2.5rem; margin-bottom: var(--sp-3); }
.skel { background: var(--bg-sunken); border-radius: var(--r-md); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- 17. 상태 표시줄 (연결/모드) ---------- */
.modebar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  background: var(--warn-soft); color: var(--warn);
  font-size: .75rem; font-weight: 700;
}
.modebar--live { background: var(--ok-soft); color: var(--ok); }
.dot { width: 8px; height: 8px; border-radius: var(--r-full); background: currentColor; flex: 0 0 auto; }

/* ---------- 18. 게이트(참여) 화면 ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-5); }
.gate__in { width: min(420px, 100%); }
.gate__logo { display: grid; justify-items: center; gap: var(--sp-3); margin-bottom: var(--sp-6);
  text-align: center; }

/* ---------- 19. 인쇄 ---------- */
@media print {
  .topbar, .tabbar, .toasts, .icon-btn, .btn { display: none !important; }
  body { background: #fff; }
  .card, .mcard, .notice { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .roster { grid-template-columns: repeat(2, 1fr); }
}
