/* =========================================================
   개발자 페이지 — 格斗馆 본 화면(WebSite)과 같은 결로 맞춘다.
   크림 배경 + 흰 카드 + 파스텔 핑크 + 알약 버튼.
   (별도 프레임워크 없이 손으로 쓴 CSS — 파일 하나로 끝난다)
   ========================================================= */

:root {
  --bg: #fdf8f3;
  --surface: #ffffff;
  --surface-2: #fbf6f0;
  --border: #f3eae2;
  --border-strong: #e8dbd0;
  --text: #3a3336;
  --text-dim: #a89e99;
  --accent: #e9778f;
  --accent-weak: #fdeef2;
  --pos: #3f9d6a;
  --neg: #e0655f;
  --radius: 20px;
  --radius-sm: 14px;
  --radius-pill: 999px;
  --shadow: 0 2px 10px rgba(150, 110, 90, 0.05);
  --shadow-lg: 0 6px 22px rgba(150, 110, 90, 0.08);
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;

  font-family: 'Pretendard', system-ui, -apple-system, 'Segoe UI', 'Malgun Gothic', Roboto,
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  color-scheme: light;
}

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

/* [hidden] 은 어떤 요소에서도 항상 숨긴다.
   (.btn{display:...} / .form-error{display:block} 가 hidden 속성을 덮어써서
    #logout 버튼·오류 상자가 로그아웃/오류가 없어도 계속 보이던 문제를 막는다) */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
}

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 18px 60px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- 상단 ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand strong {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand span {
  display: block;
  font-size: 0.85rem;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dim {
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ---------- 위험 안내 ---------- */
.warn {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #7c4a03;
  background: color-mix(in srgb, #a16207 10%, transparent);
}

/* ---------- 카드 ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 20px 12px;
}

.card-head h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-body {
  padding: 18px 20px 20px;
}

.card-body.flush {
  padding: 0;
}

/* ---------- 폼 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 16px;
}

.field {
  display: block;
  margin-bottom: 12px;
  min-width: 0;
}

.field > span {
  display: block;
  margin-bottom: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
}

.field.is-req > span::after {
  content: ' *';
  color: var(--neg);
  font-weight: 700;
}

input[type='text'],
input[type='password'] {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

input[type='text']:focus,
input[type='password']:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

/* 잘못된 칸 — 본 화면과 같은 방식 */
.field.has-error > input {
  border-color: var(--neg);
  background: color-mix(in srgb, var(--neg) 6%, var(--surface));
}

.field.has-error > span {
  color: var(--neg);
}

.field-msg {
  display: block;
  margin-top: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--neg);
}

.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-dim);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.875rem;
  color: var(--text-dim);
  cursor: pointer;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.form-error {
  display: block;
  margin-bottom: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--neg);
  background: color-mix(in srgb, var(--neg) 10%, transparent);
}

/* ---------- 탭 ---------- */
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tab {
  padding: 9px 18px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.tab.active {
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow);
}

.note.ok {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--pos);
  background: color-mix(in srgb, var(--pos) 10%, transparent);
}

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #d95f79;
}

.btn-sm {
  padding: 7px 13px;
  font-size: 0.8rem;
}

.btn-danger {
  color: var(--neg);
  border-color: color-mix(in srgb, var(--neg) 40%, transparent);
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--neg) 10%, transparent);
}

/* ---------- 표 ---------- */
.table-scroll {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data th,
table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data th {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--surface-2);
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

.right {
  text-align: right;
}

.mono {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-dim);
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
}

.tag.yes {
  color: var(--pos);
  background: color-mix(in srgb, var(--pos) 14%, transparent);
}

.tag.no {
  color: var(--text-dim);
  background: color-mix(in srgb, var(--text-dim) 14%, transparent);
}

.tag.me {
  color: var(--accent);
  background: var(--accent-weak);
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--text-dim);
}

.facts {
  margin: 0;
  padding-left: 20px;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-dim);
}

.facts code,
.field-hint code {
  padding: 1px 6px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-2);
  color: var(--text);
}

/* ---------- 폰 ---------- */
@media (max-width: 640px) {
  .wrap {
    padding: 16px 12px 48px;
  }

  /* 표를 카드로 접는다 (본 화면과 같은 방식) */
  table.data,
  table.data tbody,
  table.data tr,
  table.data td {
    display: block;
    width: 100%;
  }

  table.data thead {
    display: none;
  }

  table.data tbody {
    padding: 12px;
    background: var(--bg);
  }

  table.data tbody tr {
    padding: 14px 16px;
    margin-bottom: 10px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
  }

  table.data tbody tr:last-child {
    margin-bottom: 0;
  }

  table.data td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    border: 0;
    white-space: normal;
  }

  table.data td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-dim);
  }

  table.data td.cell-actions {
    justify-content: flex-end;
    gap: 8px;
    padding-top: 10px;
    margin-top: 6px;
    border-top: 1px dashed var(--border);
  }

  table.data td.cell-actions::before {
    display: none;
  }
}

/* =========================================================
   데이터 초기화 (초기화) — 위험 구역
   ---------------------------------------------------------
   위험한 버튼은 눈에 띄게, 나머지와 확실히 분리한다.
   ========================================================= */

.danger-zone {
  border: 2px solid color-mix(in srgb, var(--neg) 45%, transparent);
  background: color-mix(in srgb, var(--neg) 4%, var(--surface));
}

.danger-zone .card-head h2 {
  color: var(--neg);
}

.reset-head {
  margin: 16px 0 6px;
  font-size: 0.9rem;
  font-weight: 700;
}

.reset-head.del {
  color: var(--neg);
}

.reset-head.keep {
  color: var(--pos);
}

.reset-list {
  margin: 0;
  padding-left: 20px;
  font-size: 0.85rem;
  line-height: 1.7;
}

.reset-list.del {
  color: color-mix(in srgb, var(--neg) 80%, var(--text));
}

.reset-list.keep {
  color: color-mix(in srgb, var(--pos) 80%, var(--text));
}

.reset-list code {
  padding: 1px 6px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-2);
  color: var(--text);
}

.reset-hr {
  margin: 18px 0;
  border: 0;
  border-top: 1px dashed var(--border-strong);
}

/* 위험 버튼 — 채워진 빨강 */
.btn-destroy {
  color: #fff;
  background: var(--neg);
  border-color: var(--neg);
}

.btn-destroy:hover:not(:disabled) {
  background: #c9483f;
}

.btn-destroy:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 진행 로그 — 고정폭 여러 줄 */
.reset-log {
  margin-top: 14px;
  max-height: 280px;
  overflow: auto;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: pre-wrap;
}
/* =========================================================
   数据重置 —— 勾选式清单 (分组 + 行 + 工具条)
   ---------------------------------------------------------
   每个 collection 一行：勾选 + 中文名 + 集合名 + 备注。
   ========================================================= */

.reset-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 6px 0 0;
}

.reset-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}

.reset-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
  border-bottom: 1px solid var(--border);
}

.reset-group-title {
  font-size: 0.9rem;
}

.reset-group-head .dim {
  margin-left: auto;
  font-weight: 400;
  font-size: 0.78rem;
}

.reset-checklist {
  margin: 0;
  padding: 4px 8px;
  list-style: none;
}

.reset-item {
  margin: 0;
}

.reset-item > label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

.reset-item > label:hover {
  background: var(--accent-weak);
}

.reset-item-label {
  font-weight: 600;
}

.reset-item code {
  padding: 1px 6px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.8em;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.reset-item-note {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.reset-group-head input[type='checkbox'],
.reset-item input[type='checkbox'] {
  flex: none;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.reset-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 0;
}

.reset-count {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
}

.reset-hint {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  line-height: 1.5;
  color: color-mix(in srgb, var(--neg) 75%, var(--text));
  background: color-mix(in srgb, var(--neg) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--neg) 20%, transparent);
}