:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --muted: #71717a;
  --accent: #18181b;
  --accent-text: #ffffff;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090b;
    --surface: #18181b;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --muted: #a1a1aa;
    --accent: #fafafa;
    --accent-text: #18181b;
    --danger: #fca5a5;
    --danger-bg: #2a1515;
    --danger-border: #4c1d1d;
    --ok: #86efac;
    --ok-bg: #14251a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Apple SD Gothic Neo',
    'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); }

.shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 16px;
}

.card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}

.card-head { text-align: center; margin-bottom: 24px; }

.mark {
  width: 36px;
  height: 36px;
  margin: 0 auto 14px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
}

.card-head h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.card-head .sub { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }

input[type='text'],
input[type='email'],
input[type='password'] {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.field { margin-bottom: 14px; }

button {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
}

button[disabled] { opacity: 0.55; cursor: default; }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: var(--accent-text);
}

.btn-outline {
  width: 100%;
  background: transparent;
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 13px;
}

.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }

.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }
/* 목록 바로 아래 오는 버튼 줄. CSP(style-src 'self')상 인라인 style은 못 쓴다. */
.btn-row.spaced { margin-top: 12px; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  font-size: 12px;
  color: var(--muted);
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg); padding: 3px; border-radius: var(--radius); }
.tab { flex: 1; background: transparent; border: none; color: var(--muted); font-size: 13px; padding: 7px; border-radius: 7px; }
.tab[aria-selected='true'] { background: var(--surface); color: var(--text); border: 1px solid var(--border); font-weight: 500; }

.msg {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid;
}
.msg.error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.msg.ok { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.msg[hidden] { display: none; }

.note { font-size: 12px; color: var(--muted); margin: 12px 0 0; text-align: center; }
.foot { font-size: 12px; color: var(--muted); }

/* 계정 화면 — 사이드바(카테고리) + 내용 */
.account {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  padding: 40px 16px;
}

.side {
  position: sticky;
  top: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 12px;
}

.side-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.side-head .mark { margin: 0; flex: none; width: 32px; height: 32px; font-size: 15px; }
.side-head .who { min-width: 0; }
.side-head .who strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-head .who .mail { display: flex; align-items: center; font-size: 12px; color: var(--muted); }
/* 긴 주소가 배지를 밀어내지 않도록 주소만 줄이고 배지는 그대로 둔다. */
.side-head .who .addr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-head .who .badge { flex: none; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item[aria-current='page'] { background: var(--bg); color: var(--text); font-weight: 600; }
.nav-item:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.nav-item.danger { color: var(--danger); }
.nav-item.danger:hover, .nav-item.danger[aria-current='page'] { background: var(--danger-bg); color: var(--danger); }
.nav-icon { width: 18px; height: 18px; flex: none; }

.side-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.side-foot .btn-ghost { width: 100%; text-align: left; padding: 8px 10px; }
.side-foot .btn-ghost:hover { background: var(--bg); color: var(--text); }

.content { min-width: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}
.panel[hidden] { display: none; }
.panel-head { margin-bottom: 18px; }
.panel-head h2 { font-size: 17px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.panel-head .hint { font-size: 13px; color: var(--muted); margin: 0; }

/* 폼 아래 덧붙는 안내 줄 — 폼과 붙어 보이지 않게 떼어 둔다. */
#verify-row { margin-top: 18px; border-top: 1px solid var(--border); border-bottom: none; }

@media (max-width: 720px) {
  .account {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 16px 12px 32px;
  }

  /* 계정 정보와 로그아웃이 한 줄, 카테고리가 그 아래 한 줄. */
  .side {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 12px 12px 0;
  }

  .side-head { grid-area: 1 / 1; border-bottom: none; margin-bottom: 0; padding: 2px 8px 10px 0; }

  /* 좁은 화면에서는 카테고리를 가로 탭으로 눕힌다. */
  .nav {
    grid-area: 2 / 1 / 3 / -1;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    border-top: 1px solid var(--border);
    margin: 0 -12px;
    padding: 8px 12px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { white-space: nowrap; }
  .nav-icon { display: none; }

  .side-foot { grid-area: 1 / 2; border-top: none; margin: 0; padding: 0 0 10px; }
  .side-foot .btn-ghost { width: auto; padding: 4px 8px; }

  .panel { padding: 20px 16px; }
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row .meta { min-width: 0; }
.row .meta strong { display: block; font-size: 14px; font-weight: 500; }
.row .meta span { font-size: 12px; color: var(--muted); word-break: break-all; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  margin-left: 6px;
  vertical-align: 1px;
}
.badge.on { color: var(--ok); border-color: currentColor; }
.badge.warn { color: var(--danger); border-color: currentColor; }

.empty { font-size: 13px; color: var(--muted); padding: 12px 0; }

.danger-zone { border-color: var(--danger-border); background: var(--danger-bg); }
.danger-zone h2 { color: var(--danger); }
.danger-zone .hint { color: var(--danger); opacity: 0.85; }

dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 24px;
  max-width: 400px;
  width: calc(100% - 32px);
}
dialog::backdrop { background: rgb(0 0 0 / 0.4); }
dialog h2 { margin: 0 0 8px; font-size: 16px; }
dialog p { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
