/* 한 단짜리 화면: 위에 검색·필터, 아래에 목록 하나.
   넓은 화면에서는 표처럼, 휴대폰에서는 세 줄짜리 행으로 보인다. */
:root {
  --bg: #f2f3fa;
  --surface: #ffffff;
  --fg: #1a1d38;
  --muted: #5a6085;
  --line: #d9dcee;
  --accent: #4a3fd0;
  --accent-fg: #ffffff;
  --chip: #e6e8f6;
  --tag: #eceefa;
  --warn: #8a5a00;
  --font-display: "Black Han Sans", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --font-body: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1124; --surface: #171a33; --fg: #e8e9f7; --muted: #9a9fc4;
    --line: #2a2e54; --accent: #a99dff; --accent-fg: #14152c;
    --chip: #22264a; --tag: #1e2242; --warn: #e2b866;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1124; --surface: #171a33; --fg: #e8e9f7; --muted: #9a9fc4;
  --line: #2a2e54; --accent: #a99dff; --accent-fg: #14152c;
  --chip: #22264a; --tag: #1e2242; --warn: #e2b866;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}
.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding-block: 28px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---- 머리 ---- */
.top { display: flex; flex-direction: column; gap: 6px; }
.top h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.7rem, 6vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.top h1 span { color: var(--accent); }
.lede { margin: 0; color: var(--muted); max-width: 60ch; }
.updated { margin: 0; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.updated:empty { display: none; }
.status {
  margin: 6px 0 0;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 0.87rem;
  color: var(--muted);
}
.status b { color: var(--warn); font-weight: 600; }

/* ---- 검색·필터 ---- */
.controls { display: flex; flex-direction: column; gap: 14px; }
.searchrow { display: flex; flex-wrap: wrap; gap: 8px; }
.searchrow input,
.searchrow select {
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 0;
}
.searchrow input { flex: 1 1 220px; }
.searchrow select { flex: 0 0 auto; }
.searchrow input:focus-visible,
.searchrow select:focus-visible,
button:focus-visible,
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 멤버·종류 필터: 상자 하나 안에 기수별 한 줄, 칩은 네 칸 격자에 맞춰 줄을 세운다 */
.filters {
  --label: 6.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.members { display: grid; gap: 6px; }
.members .unit {
  display: grid;
  grid-template-columns: var(--label) repeat(4, minmax(0, 7.6rem));
  gap: 6px;
  align-items: center;
}
.kinds {
  display: grid;
  grid-template-columns: var(--label) minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.kinds .unit-label { padding-top: 7px; }
.kchips { display: flex; flex-wrap: wrap; gap: 6px; }
.unit-label {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}
.unit-label .uname { margin-left: 5px; font-weight: 500; }
.chip {
  font: inherit;
  font-size: 0.87rem;
  color: var(--fg);
  background: var(--chip);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.kchips .chip { padding: 6px 11px; }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 4px; font-size: 0.8rem; }
.chip.todo { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.chip[aria-pressed="true"] .n { color: var(--accent-fg); opacity: 0.8; }

/* ---- 목록 ---- */
.count { margin: 0 0 8px; font-size: 0.87rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.count b { color: var(--fg); font-weight: 600; }
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.list:empty { display: none; }
.row, .head {
  display: grid;
  grid-template-columns: 6.2rem minmax(0, 2.2fr) minmax(0, 1.4fr) minmax(0, 1.6fr) 7.6rem;
  column-gap: 14px;
  align-items: baseline;
  padding: 10px 14px;
}
.row + .row { border-top: 1px solid var(--line); }
.head {
  border-bottom: 1px solid var(--line);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.head button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.head button[data-on="1"] { color: var(--accent); }
.row .d { grid-area: 1 / 1; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.87rem; }
.row .t { grid-area: 1 / 2; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.row .o { grid-area: 1 / 3; min-width: 0; color: var(--muted); overflow-wrap: anywhere; }
.row .m { grid-area: 1 / 4; min-width: 0; overflow-wrap: anywhere; font-size: 0.9rem; }
.row .k { grid-area: 1 / 5; justify-self: start; display: flex; flex-wrap: wrap; gap: 4px; }
.row .t a { color: var(--fg); text-decoration: none; }
.row .t a:hover { color: var(--accent); text-decoration: underline; }
.row .t small { margin-left: 6px; font-weight: 400; font-size: 0.74rem; color: var(--muted); white-space: nowrap; }
.row .o small { display: block; font-size: 0.8rem; }
.tag {
  display: inline-block;
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--tag);
  color: var(--muted);
  white-space: nowrap;
}
.tag.duo { color: var(--accent); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty button {
  font: inherit; margin-top: 10px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer;
}

footer { font-size: 0.8rem; color: var(--muted); max-width: 70ch; }
footer p { margin: 0 0 4px; }
footer a { color: var(--accent); }

@media (max-width: 759px) {
  .head { display: none; }
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 2px;
    column-gap: 10px;
    padding: 11px 12px;
  }
  .row .t { grid-area: 1 / 1; }
  .row .k { grid-area: 1 / 2; justify-self: end; justify-content: flex-end; max-width: 46vw; }
  .row .o { grid-area: 2 / 1 / 3 / 3; font-size: 0.87rem; }
  .row .o:empty { display: none; }
  .row .o small { display: inline; margin-left: 6px; }
  .row .m { grid-area: 3 / 1; font-size: 0.87rem; }
  .row .d { grid-area: 3 / 2; justify-self: end; font-size: 0.8rem; }
  /* 휴대폰: 기수 이름은 "1기"처럼 짧게만 보이고, 칩 네 칸이 화면 너비를 나눠 쓴다 */
  .filters { --label: 2.3rem; padding: 10px; }
  .members .unit { grid-template-columns: var(--label) repeat(4, minmax(0, 1fr)); gap: 5px; }
  .unit-label .uname { display: none; }
  .chip { padding: 6px 2px; }
  .chip .n { margin-left: 3px; }
  .kchips { gap: 5px; }
  .kchips .chip { padding: 6px 9px; }
}

/* 좁은 휴대폰: 칩 글자를 조금 줄여서 "마시로 36" 같은 긴 칩이 잘리지 않게 */
@media (max-width: 380px) {
  .filters { --label: 2rem; padding: 10px 8px; }
  .members .unit { gap: 4px; }
  .members .chip { font-size: 0.8rem; padding: 6px 1px; }
  .members .chip .n { font-size: 0.7rem; margin-left: 2px; }
}
