/* Guild member list editor (js/guild-roster.js) on tools.html + counter.html,
   and counter.html's "ใช้แล้ววันนี้" card row + name picker (js/counter.js).
   Lime = used / done, rose = over the limit. Mono everywhere else. */

/* ===== Shared popup frame ===== */
.home-v2 .gr-box {
  position: relative; overflow: hidden; max-width: none; padding: 26px;
  background: linear-gradient(160deg, #161616 0%, #0b0b0b 55%); border: 1px solid var(--h-line); border-radius: 28px;
  box-shadow: 0 40px 90px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .05);
}
/* faint lime glow behind the header icon */
.home-v2 .gr-box::before {
  content: ""; position: absolute; inset: -120px auto auto -80px; width: 320px; height: 320px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(190, 242, 100, .10), transparent);
}
.home-v2 .roster-box { width: min(760px, calc(100vw - 32px)); }
.home-v2 .used-pick-box { width: min(560px, calc(100vw - 32px)); }

.gr-head { position: relative; display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.gr-head-ico {
  flex-shrink: 0; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px;
  background: linear-gradient(145deg, #1f1f1f, #0e0e0e); border: 1px solid var(--h-line); color: var(--h-lime);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 0 24px rgba(190, 242, 100, .10);
}
.gr-head-text { min-width: 0; flex: 1; }
.gr-head-text .picker-kicker { display: block; margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-title { margin: 0; font: 800 24px/1.2 'Anuphan', sans-serif; color: var(--h-fg); letter-spacing: -.01em; }
.home-v2 .gr-close { align-self: flex-start; width: 40px; height: 40px; border: 1px solid var(--h-line); color: #d4d4d4; }
.home-v2 .gr-close:is(:hover, :focus-visible) .ico-x { rotate: 90deg; }

.gr-foot { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--h-line); }
.gr-foot-hint { margin: 0; flex: 1 1 220px; font: 500 12.5px/1.6 'Anuphan', sans-serif; color: var(--h-muted); }
.gr-foot-hint b { color: var(--h-fg); }
.gr-actions { display: flex; gap: 8px; margin-left: auto; }
.home-v2 .gr-actions .btn { display: inline-flex; align-items: center; gap: 7px; padding-inline: 20px; }
.ico-tick { stroke-dasharray: 1; stroke-dashoffset: 0; }
.gr-actions .btn:is(:hover, :focus-visible) .ico-tick { animation: ico-draw .55s cubic-bezier(.23, 1, .32, 1); }

/* round letter avatar used by the preview, the picker and the card chips */
.gr-avatar {
  flex-shrink: 0; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: #1c1c1c; border: 1px solid rgba(250, 250, 250, .14); color: var(--h-fg);
  font: 800 12px/1 'Anuphan', 'Inter', sans-serif;
}

/* ===== Member list editor ===== */
.gr-meter {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px 16px;
  margin-bottom: 18px; padding: 14px 18px; border-radius: 18px; background: rgba(255, 255, 255, .03); border: 1px solid var(--h-line);
}
.gr-meter-num { display: flex; align-items: baseline; gap: 6px; font: 600 13px 'Anuphan', sans-serif; color: var(--h-muted); }
.gr-meter-num b { font: 800 28px/1 'Inter', sans-serif; color: var(--h-fg); font-variant-numeric: tabular-nums; }
.gr-meter-bar { height: 6px; border-radius: 99px; background: #1f1f1f; overflow: hidden; }
.gr-meter-bar i {
  display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--h-lime);
  transform-origin: left; scale: var(--fill, 0) 1; transition: scale .45s cubic-bezier(.23, 1, .32, 1), background .2s;
}
.gr-meter-note { font: 600 12.5px 'Anuphan', sans-serif; color: var(--h-muted); text-align: right; min-width: 7em; }
.gr-meter.is-full .gr-meter-note { color: var(--h-lime); }
.gr-meter.is-over { border-color: rgba(244, 63, 94, .4); background: rgba(244, 63, 94, .06); }
.gr-meter.is-over .gr-meter-num b, .gr-meter.is-over .gr-meter-note { color: #fb7185; }
.gr-meter.is-over .gr-meter-bar i { background: #fb7185; }

.gr-cols { position: relative; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; }
.gr-pane { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.gr-pane-label { font: 700 12.5px 'Anuphan', sans-serif; color: var(--h-muted); }
.gr-pane-label em { font-style: normal; color: var(--h-fg); }
.gr-text {
  flex: 1; display: block; width: 100%; box-sizing: border-box; height: 320px; min-height: 200px; resize: vertical;
  padding: 14px 16px; border-radius: 18px; background: #090909; border: 1px solid var(--h-line);
  color: var(--h-fg); font: 500 14.5px/1.85 'Anuphan', sans-serif; color-scheme: dark;
  scrollbar-color: #3a3a3a transparent; scrollbar-width: thin; transition: border-color .2s, box-shadow .2s;
}
.gr-text::placeholder { color: #525252; }
.gr-text:focus { outline: none; border-color: var(--h-lime-line); box-shadow: 0 0 0 4px rgba(190, 242, 100, .08); }
.gr-text:disabled { opacity: .45; }

.gr-preview {
  list-style: none; margin: 0; padding: 8px; height: 320px; box-sizing: border-box; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px; border-radius: 18px; background: rgba(255, 255, 255, .02); border: 1px dashed var(--h-line);
  scrollbar-color: #3a3a3a transparent; scrollbar-width: thin;
}
.gr-chip { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border-radius: 12px; background: #121212; border: 1px solid rgba(250, 250, 250, .06); }
.gr-chip-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 13.5px 'Anuphan', sans-serif; color: var(--h-fg); }
.gr-chip-no { font-size: 11px; color: #5c5c5c; }
.gr-chip.is-over { border-color: rgba(244, 63, 94, .35); background: rgba(244, 63, 94, .06); }
.gr-chip.is-over .gr-avatar, .gr-chip.is-over .gr-chip-no { color: #fb7185; border-color: rgba(244, 63, 94, .4); }
.gr-preview-empty { margin: auto; text-align: center; font: 500 13px/1.7 'Anuphan', sans-serif; color: #5c5c5c; }

/* ===== Name picker (counter.html) ===== */
.gr-search-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.gr-search {
  flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 42px; border-radius: 999px;
  background: #090909; border: 1px solid var(--h-line); color: var(--h-muted); transition: border-color .2s;
}
.gr-search:focus-within { border-color: var(--h-lime-line); color: var(--h-fg); }
.gr-search input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: none; color: var(--h-fg); font: 500 14px 'Anuphan', sans-serif; color-scheme: dark; }
.gr-search input:focus { outline: none; }
.gr-search input::placeholder { color: #5c5c5c; }
.gr-search-count { flex-shrink: 0; font: 600 12.5px 'Anuphan', sans-serif; color: var(--h-muted); }
.gr-search-count b { color: var(--h-lime); font-family: 'Inter', sans-serif; }

.gr-names {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px;
  max-height: min(46vh, 380px); overflow-y: auto; padding: 2px; scrollbar-color: #3a3a3a transparent; scrollbar-width: thin;
}
.gr-name {
  position: relative; display: flex; align-items: center; gap: 9px; min-width: 0; padding: 8px 10px 8px 8px; border-radius: 14px;
  background: #111; border: 1px solid var(--h-line); cursor: pointer;
  transition: border-color .2s, background .2s, translate .25s cubic-bezier(.23, 1, .32, 1);
}
.gr-name[hidden] { display: none; }
.gr-name input { position: absolute; opacity: 0; pointer-events: none; }
.gr-name-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 13.5px 'Anuphan', sans-serif; color: var(--h-fg); }
.gr-name:hover:not(.is-taken) { border-color: rgba(250, 250, 250, .24); background: #171717; translate: 0 -2px; }
.gr-name:has(input:focus-visible) { outline: 2px solid var(--h-lime); outline-offset: 2px; }
.gr-name:has(input:checked) { border-color: var(--h-lime-line); background: rgba(190, 242, 100, .08); box-shadow: 0 0 20px rgba(190, 242, 100, .08); }
.gr-name:has(input:checked) .gr-avatar { background: var(--h-lime); border-color: var(--h-lime); color: #0a0a0a; }
.gr-name.is-taken { cursor: not-allowed; opacity: .42; }
.gr-tag { flex-shrink: 0; padding: 2px 7px; border-radius: 999px; background: #1f1f1f; color: var(--h-muted); font: 700 10.5px 'Anuphan', sans-serif; }
.gr-tag.is-last { background: rgba(56, 189, 248, .12); color: var(--h-sky); }
.gr-names-none { grid-column: 1 / -1; margin: 0; padding: 18px; text-align: center; font: 500 13px 'Anuphan', sans-serif; color: var(--h-muted); }
.gr-names-none[hidden] { display: none; }

.gr-empty { display: flex; flex-direction: column; gap: 6px; padding: 26px 20px; border-radius: 18px; text-align: center; background: rgba(255, 255, 255, .02); border: 1px dashed var(--h-line); }
.gr-empty > b { font: 800 16px 'Anuphan', sans-serif; color: var(--h-fg); }
.gr-empty span { font: 500 13px/1.7 'Anuphan', sans-serif; color: var(--h-muted); }
.gr-empty span b { color: var(--h-fg); }

.gr-link {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px;
  background: transparent; border: 1px dashed var(--h-line); color: #d4d4d4; cursor: pointer;
  font: 700 12.5px 'Anuphan', sans-serif; transition: border-color .2s, color .2s;
}
.gr-link:is(:hover, :focus-visible) { border-color: var(--h-lime-line); color: var(--h-lime); outline: none; }
.gr-link:is(:hover, :focus-visible) .ico-plus { rotate: 90deg; }
.gr-link .ico-plus { transform-box: fill-box; transform-origin: center; }

/* ===== tools.html: member-list button on each guild card ===== */
.tc-roster-btn { width: 100%; justify-content: center; margin-top: 10px; }
.tc-roster-btn b { font-family: 'Inter', sans-serif; color: var(--h-lime); }
.tc-roster-btn .ico-users-back { transition: translate .35s cubic-bezier(.34, 1.56, .64, 1); }
.tc-roster-btn:is(:hover, :focus-visible) .ico-users-back { translate: 1.5px 0; }

/* ===== counter.html: "ใช้แล้ววันนี้" row on each card ===== */
.counter-page .cu-row {
  display: flex; flex-direction: column; gap: 10px; margin-top: 12px; padding: 10px 10px 10px 14px; border-radius: 16px;
  background: rgba(255, 255, 255, .02); border: 1px dashed var(--h-line); transition: border-color .3s, background .3s;
}
.counter-page .cu-row.has-used { border-style: solid; border-color: rgba(190, 242, 100, .22); background: linear-gradient(135deg, rgba(190, 242, 100, .06), rgba(190, 242, 100, .01) 60%); }
.counter-page .cu-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.counter-page .cu-label { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font: 700 13px 'Anuphan', sans-serif; color: var(--h-muted); }
.counter-page .cu-dot { width: 7px; height: 7px; border-radius: 50%; background: #3a3a3a; }
.counter-page .cu-row.has-used .cu-label { color: var(--h-fg); }
.counter-page .cu-row.has-used .cu-dot { background: var(--h-lime); box-shadow: 0 0 0 3px rgba(190, 242, 100, .15); animation: cu-pulse 2.4s ease-in-out infinite; }
@keyframes cu-pulse { 50% { box-shadow: 0 0 0 6px rgba(190, 242, 100, 0); } }
.counter-page .cu-count { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--h-lime); color: #0a0a0a; font: 800 12px/1.5 'Inter', sans-serif; text-align: center; }
.counter-page .cu-add-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px;
  background: var(--h-pill-bg, #fafafa); border: 1px solid transparent; color: var(--h-pill-fg, #0a0a0a); cursor: pointer;
  font: 700 12.5px 'Anuphan', sans-serif; transition: background .2s, scale .2s;
}
.counter-page .cu-add-btn:hover { background: #e5e5e5; scale: 1.04; }
.counter-page .cu-add-btn:active { scale: .96; }
.counter-page .cu-add-btn:focus-visible { outline: 2px solid var(--h-lime); outline-offset: 2px; }
.ico-user-check { stroke-dasharray: 1; stroke-dashoffset: 0; }
:is(.cu-add-btn, .tools-step):is(:hover, :focus-visible) .ico-user-check { animation: ico-draw .55s cubic-bezier(.23, 1, .32, 1); }

.counter-page .cu-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.counter-page .cu-chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 3px 10px 3px 3px; border-radius: 999px;
  background: #121212; border: 1px solid rgba(190, 242, 100, .18);
}
.counter-page .cu-chip .gr-avatar { width: 22px; height: 22px; font-size: 11px; background: rgba(190, 242, 100, .14); border-color: rgba(190, 242, 100, .35); color: var(--h-lime); }
.counter-page .cu-chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 12.5px 'Anuphan', sans-serif; color: var(--h-fg); }
.counter-page .cu-chip:has(.cu-chip-x) { padding-right: 3px; }
.counter-page .cu-chip-x {
  display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--h-muted); cursor: pointer; transition: background .2s, color .2s;
}
.counter-page .cu-chip-x:is(:hover, :focus-visible) { background: rgba(244, 63, 94, .15); color: #fb7185; outline: none; }
.counter-page .cu-chip-x:is(:hover, :focus-visible) .ico-x { rotate: 90deg; }
/* spin the × around its own centre, not the svg's top-left corner */
:is(.cu-chip-x, .gr-close) .ico-x { transform-box: fill-box; transform-origin: center; }

/* เวิร์ค / ไม่เวิร์ค on each name + the tally beside the count */
.counter-page .cu-chip.is-win { border-color: rgba(52, 211, 153, .45); }
.counter-page .cu-chip.is-lose { border-color: rgba(251, 113, 133, .45); }
.counter-page .cu-chip.is-lose .gr-avatar { background: rgba(251, 113, 133, .12); border-color: rgba(251, 113, 133, .35); color: #fb7185; }
.counter-page .cu-res { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; }
.counter-page .cu-res.is-win { background: rgba(52, 211, 153, .16); color: #34d399; }
.counter-page .cu-res.is-lose { background: rgba(251, 113, 133, .16); color: #fb7185; }
.counter-page .cu-res-btns { display: inline-flex; gap: 2px; padding: 2px; border-radius: 999px; background: rgba(255, 255, 255, .04); }
.counter-page .cu-res-btn {
  display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: #5a5a5a; cursor: pointer; transition: background .2s, color .2s, scale .2s;
}
.counter-page .cu-res-btn.is-win:is(:hover, :focus-visible) { color: #34d399; background: rgba(52, 211, 153, .12); outline: none; }
.counter-page .cu-res-btn.is-lose:is(:hover, :focus-visible) { color: #fb7185; background: rgba(251, 113, 133, .12); outline: none; }
.counter-page .cu-res-btn.is-win.active { background: #34d399; color: #0a0a0a; }
.counter-page .cu-res-btn.is-lose.active { background: #fb7185; color: #0a0a0a; }
.counter-page .cu-res-btn:active { scale: .88; }
/* the remove button is a bin behind a hairline, so it never reads as ✗ ไม่เวิร์ค */
.counter-page .cu-res-btns + .cu-chip-x { position: relative; margin-left: 5px; }
.counter-page .cu-res-btns + .cu-chip-x::before { content: ""; position: absolute; left: -4px; top: 4px; bottom: 4px; width: 1px; background: var(--h-line); }
.counter-page .cu-chip-x .ico-bin-lid { transform-box: fill-box; transform-origin: right bottom; transition: rotate .2s; }
.counter-page .cu-chip-x:is(:hover, :focus-visible) .ico-bin-lid { rotate: 14deg; }
.counter-page .cu-tally { display: inline-flex; gap: 6px; margin-left: 2px; }
.counter-page .cu-tally > span { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font: 700 11.5px/1.6 'Anuphan', sans-serif; }
.counter-page .cu-tally-win { background: rgba(52, 211, 153, .12); color: #34d399; }
.counter-page .cu-tally-lose { background: rgba(251, 113, 133, .12); color: #fb7185; }

/* ===== Phones ===== */
@media (max-width: 640px) {
  .home-v2 .gr-box { padding: 20px; border-radius: 24px; }
  .gr-title { font-size: 21px; }
  .gr-cols { grid-template-columns: 1fr; }
  .gr-text { flex: none; height: 200px; }
  .gr-preview { height: auto; max-height: 180px; }
  .gr-meter { grid-template-columns: auto 1fr; }
  .gr-meter-note { grid-column: 1 / -1; text-align: left; }
  .gr-names { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .gr-meter-bar i, .gr-name, .gr-text, .gr-search, .gr-link, .counter-page .cu-row,
  .counter-page .cu-add-btn, .counter-page .cu-chip-x, .counter-page .cu-res-btn, .tc-roster-btn .ico-users-back { transition: none; }
  .counter-page .cu-row.has-used .cu-dot { animation: none; }
  .gr-name:hover:not(.is-taken) { translate: none; }
  .gr-actions .btn .ico-tick, .ico-user-check { animation: none !important; }
}
