/* 계정 패널 · 친구 · 대화 · 초대 알림. 색과 글꼴은 patch.css 토큰을 씁니다. */

.account-chip {
  position: relative;
  min-height: 36px;
  padding: 0 12px;
  border: 2px solid var(--seam-strong);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 760;
  white-space: nowrap;
}
.account-chip.signed-in { background: var(--indigo); border-color: var(--indigo); color: var(--on-dye); }
.account-chip.signed-in:hover:not(:disabled) { background: var(--indigo-press); }
.account-chip.floating { position: fixed; top: 10px; right: 10px; z-index: 50; }
.account-count {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-small);
  background: var(--gardenia);
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 오른쪽에서 열리는 패널 */
.account-panel {
  width: min(420px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: var(--seam-width) solid var(--seam-strong);
  border-radius: 0;
  background: var(--cloth);
  color: var(--ink);
  overflow: hidden;
}
.account-panel[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); animation: account-slide var(--steady) var(--ease); }
@keyframes account-slide { from { transform: translateX(24px); opacity: 0; } }

.account-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: var(--seam-width) solid var(--seam);
  background: var(--sheet);
}
.account-head h2 { font-size: var(--text-lg); overflow-wrap: anywhere; }
.account-body { display: flex; flex-direction: column; gap: 14px; padding: 16px; overflow-y: auto; overscroll-behavior: contain; }

.account-lead { color: var(--ink-soft); font-size: var(--text-sm); }
.account-note { color: var(--ink-soft); font-size: var(--text-xs); }
.account-error { min-height: 1.2em; color: var(--safflower); font-size: var(--text-sm); font-weight: 650; }
.account-error:empty { min-height: 0; }

.account-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--seam-width);
  padding: 0;
  border: var(--seam-width) solid var(--seam);
  border-radius: var(--radius);
  background: var(--seam);
}
.account-tab { min-height: 40px; border: 0; border-radius: 0; background: var(--sheet); font-weight: 700; }
.account-tab[aria-pressed="true"] { background: var(--ink); color: var(--on-dye); }
.account-tab[aria-pressed="true"]:hover:not(:disabled) { background: var(--ink); }
.account-auth > .account-tabs { margin-top: 12px; margin-bottom: 22px; }
.account-auth > .account-error:empty { display: none; }
.account-auth > .account-error:not(:empty) { margin-bottom: 12px; }

.account-form { display: grid; gap: 12px; }
.account-field { display: grid; gap: 6px; }
.account-field span, .account-field > label { color: var(--ink-soft); font-size: var(--text-xs); font-weight: 700; }

.account-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--seam);
  color: var(--ink-soft);
  font-size: var(--text-xs);
}

/* 플레이타임 */
.stats-total { display: grid; gap: 2px; padding: 16px; border: var(--seam-width) solid var(--ink); border-radius: var(--radius); background: var(--gardenia); }
.stats-total span { font-size: var(--text-sm); font-weight: 700; }
.stats-total b { font-size: clamp(30px, 8vw, 40px); font-weight: 900; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stats-games { grid-template-columns: 1fr; }
.stats-game { position: relative; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 12px 14px 16px; }
.stats-game b { font-variant-numeric: tabular-nums; }
.stats-game i { position: absolute; left: 0; bottom: 0; height: 5px; width: calc(var(--share) * 100%); background: var(--seam-strong); }
.stats-game.stat-blokus i { background: var(--indigo); }
.stats-game.stat-president i { background: var(--safflower); }
.stats-game.stat-davinci i { background: var(--ink); }
.stats-game.stat-halli i { background: var(--gardenia); }

/* 친구 */
.account-friends, .account-threads { display: grid; gap: 8px; }
.account-friends h3 { margin-top: 8px; font-size: var(--text-sm); color: var(--ink-soft); }
.friend-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.friend-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1.5px solid var(--seam);
  border-radius: var(--radius);
  background: var(--sheet);
}
.friend-row.request { grid-template-columns: minmax(0, 1fr) auto auto; border-color: var(--gardenia); background: var(--gardenia-tint); }
.friend-row:not(.request):has(.friend-state) { grid-template-columns: minmax(0, 1fr) auto auto; }
.friend-row .btn { min-height: 34px; padding: 0 10px; }
.friend-who { display: grid; min-width: 0; }
.friend-who b, .friend-row > b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-who span, .friend-state { color: var(--ink-soft); font-size: var(--text-xs); }
.friend-row.online { border-color: var(--mugwort); }
.friend-row.online .friend-who span { color: var(--mugwort); font-weight: 700; }
.friend-row.online .friend-who span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; background: var(--mugwort); }

/* 대화 */
.thread-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  justify-content: stretch;
  gap: 10px;
  min-height: 52px;
  text-align: left;
}
.thread-row span { color: var(--ink-soft); font-size: var(--text-xs); font-weight: 600; }
.thread-row em { min-width: 22px; padding: 0 6px; border-radius: var(--radius-small); background: var(--safflower); color: var(--on-dye); font-style: normal; font-size: var(--text-xs); text-align: center; }
.account-thread { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 10px; min-height: min(60dvh, 520px); }
.thread-top { display: flex; align-items: center; gap: 10px; }
.thread-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 12px;
  list-style: none;
  border: 1.5px solid var(--seam);
  border-radius: var(--radius);
  background: var(--sheet);
  overflow-y: auto;
  max-height: 55dvh;
}
.thread-messages li { display: grid; gap: 2px; max-width: 82%; }
.thread-messages p { padding: 8px 10px; border-radius: var(--radius); font-size: var(--text-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.thread-messages time { color: var(--ink-faint); font-size: 11px; }
.thread-messages .mine { align-self: flex-end; justify-items: end; }
.thread-messages .mine p { background: var(--indigo); color: var(--on-dye); }
.thread-messages .theirs p { background: var(--cloth-deep); }
.thread-messages .thread-empty { max-width: none; align-self: center; color: var(--ink-soft); font-size: var(--text-sm); }
.thread-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.thread-form textarea { min-height: 44px; resize: none; }

/* 초대·안내 알림 */
.account-toasts {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 950;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.account-toast {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: var(--seam-width) solid var(--ink);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  pointer-events: auto;
  animation: patch-in var(--steady) var(--ease);
}
.account-toast:has(.primary) { border-color: var(--indigo); background: var(--indigo-tint); }
.account-toast.error { border-color: var(--safflower); background: var(--safflower-tint); }
.account-toast p { font-size: var(--text-sm); font-weight: 650; }
.account-toast > div { display: flex; flex-wrap: wrap; gap: 6px; }
.account-toast .btn { min-height: 34px; }

@media (max-width: 640px) {
  .account-chip { min-height: 32px; padding: 0 8px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
  /* 게임 화면 머리줄은 좁으므로 닉네임 첫 글자만 담은 작은 칸으로 줄입니다. */
  body:not(.hub-page) .account-chip { flex: none; width: 40px; min-width: 40px; height: 36px; padding: 0; overflow: visible; font-size: 0; }
  body:not(.hub-page) .account-chip::before { content: attr(data-initial); font-size: 14px; font-weight: 850; }
  .friend-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .friend-row > .btn:last-child { grid-column: 1 / -1; justify-self: end; }
  .account-toasts { left: 8px; right: 8px; bottom: 8px; width: auto; }
}

/* 할리갈리 대기실: 내 테마 */
.halli-themes { display: grid; gap: 10px; margin-top: 14px; padding: 14px; border: var(--seam-width) solid var(--seam); border-radius: var(--radius); background: var(--sheet); }
.halli-themes[hidden] { display: none; }
.halli-themes-head { display: grid; gap: 2px; }
.halli-themes-head h3 { font-size: var(--text-md); }
.halli-themes-head p, .halli-theme-note { color: var(--ink-soft); font-size: var(--text-xs); }
.halli-theme-save { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.halli-theme-status { font-size: var(--text-sm); font-weight: 650; color: var(--mugwort); }
.halli-theme-status.error { color: var(--safflower); }
.halli-theme-list { display: grid; gap: var(--seam-width); border: var(--seam-width) solid var(--seam); border-radius: var(--radius); background: var(--seam); }
.halli-theme { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 10px 12px; background: var(--sheet); }
.halli-theme b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.halli-theme-slots { display: flex; gap: 3px; margin-top: 4px; }
.halli-theme-slots i { width: 14px; height: 14px; border: 1.5px solid var(--seam-strong); border-radius: 2px; background: var(--cloth); }
.halli-theme-slots i.photo { background: var(--gardenia); border-color: var(--ink); }
.halli-theme .btn { min-height: 34px; }

/* 비밀번호 보기 · 확인 */
.account-password { position: relative; display: block; min-width: 0; }
.account-password > input { width: 100%; min-width: 0; padding-right: 52px; }
.account-password > input::-ms-reveal { display: none; }
.account-password > .account-reveal {
  position: absolute; top: 50%; right: 2px; transform: translateY(-50%);
  width: 44px; min-width: 44px; height: 40px; min-height: 40px; padding: 0;
  border: 0; background: transparent; color: var(--ink-soft);
}
.account-reveal svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.account-reveal[aria-pressed="false"] svg path:last-child { display: none; }
.account-password > .account-reveal:hover { background: var(--sheet-hover); color: var(--ink); }
.account-password > .account-reveal:focus-visible { outline-offset: -3px; }
.account-match { min-height: 1.2em; font-size: var(--text-xs); font-weight: 700; }
.account-match:empty { min-height: 0; }
.account-match.ok { color: var(--mugwort); }
.account-match.bad { color: var(--safflower); }
.account-field[hidden] { display: none; }
.account-admin-link { min-height: 32px; padding: 0 10px; font-size: var(--text-xs); text-decoration: none; }
.account-name-note { margin-top: 4px; color: var(--ink-soft); font-size: var(--text-xs); }
