/* Study buddies panel and the username dialog. Light by default; dark follows html[data-theme="dark"]. */
.abd-root, .abd-modal-wrap {
  --b-bg: #ffffff; --b-bg-2: #f6f6f6; --b-bg-3: #ececec; --b-text: #111111; --b-text-2: #555555; --b-text-3: #8a8a8a;
  --b-line: #e7e7e7; --b-accent: #111111; --b-on-accent: #ffffff; --b-ok: #15803d; --b-ok-soft: #dcfce7; --b-bad: #dc2626;
  --b-shadow: 0 18px 50px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.06); --b-ease: cubic-bezier(0.32, 0.72, 0, 1);
  font-family: var(--ag-font, "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif);
  color: var(--b-text); -webkit-font-smoothing: antialiased;
}
html[data-theme="dark"] .abd-root, html[data-theme="dark"] .abd-modal-wrap {
  --b-bg: #121212; --b-bg-2: #1b1b1b; --b-bg-3: #262626; --b-text: #f4f4f5; --b-text-2: #b4b4b8; --b-text-3: #7c7c82;
  --b-line: #2a2a2a; --b-accent: #ffffff; --b-on-accent: #111111; --b-ok: #4ade80; --b-ok-soft: rgba(74, 222, 128, 0.14); --b-bad: #f87171;
  --b-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
.abd-root *, .abd-modal-wrap * { box-sizing: border-box; }
.abd-root button, .abd-modal-wrap button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

.abd-btn { height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--b-line) !important; background: var(--b-bg) !important; color: var(--b-text) !important; font-size: 14px !important; font-weight: 600 !important; white-space: nowrap; transition: background-color 0.15s ease, transform 0.15s ease; }
.abd-btn:hover { background: var(--b-bg-2) !important; }
.abd-btn:active { transform: scale(0.97); }
.abd-btn.sm { height: 34px; padding: 0 13px; font-size: 13px !important; }
.abd-btn.is-primary { background: var(--b-accent) !important; color: var(--b-on-accent) !important; border-color: var(--b-accent) !important; }
.abd-btn.is-bad { color: var(--b-bad) !important; }
.abd-btn:disabled { opacity: 0.45; cursor: default; }
.abd-link { background: none !important; border: 0 !important; padding: 8px 2px; color: var(--b-text-2) !important; font-size: 13px !important; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* Panel */
.abd-scrim { position: fixed; inset: 0; z-index: 1210; background: rgba(0, 0, 0, 0.32); opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.abd-root.is-open .abd-scrim { opacity: 1; pointer-events: auto; }
.abd-panel { position: fixed; z-index: 1220; top: 12px; right: 12px; bottom: 12px; width: 420px; max-width: calc(100vw - 24px); display: flex; flex-direction: column; overflow: hidden; background: var(--b-bg); border: 1px solid var(--b-line); border-radius: 24px; box-shadow: var(--b-shadow); transform: translateX(calc(100% + 24px)); visibility: hidden; transition: transform 0.38s var(--b-ease), visibility 0s linear 0.38s; }
.abd-root.is-open .abd-panel { transform: none; visibility: visible; transition: transform 0.38s var(--b-ease), visibility 0s; }
.abd-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 8px 20px; }
.abd-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--b-text); }
.abd-x { width: 38px; height: 38px; border-radius: 999px; border: 0 !important; background: none !important; color: var(--b-text-2) !important; font-size: 16px; }
.abd-x:hover { background: var(--b-bg-2) !important; }
.abd-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 24px; }

.abd-me { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-radius: 18px; background: var(--b-bg-2); }
.abd-me small { display: block; font-size: 12px; color: var(--b-text-3); }
.abd-me b { font-size: 18px; letter-spacing: -0.01em; }
.abd-me.is-empty b { font-size: 15px; }
.abd-me-actions { display: flex; gap: 6px; }

.abd-find { position: relative; display: flex; gap: 8px; margin: 12px 0 4px; }
.abd-at { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--b-text-3); font-weight: 600; pointer-events: none; }
.abd-root .abd-find input { padding-left: 32px !important; }
.abd-find input { flex: 1; min-width: 0; height: 44px; padding: 0 12px 0 32px; border-radius: 999px; border: 1px solid var(--b-line); background: var(--b-bg-2); color: var(--b-text); font: 15px inherit; font-family: inherit; outline: none; }
.abd-find input:focus { border-color: var(--b-text); background: var(--b-bg); }
.abd-find .abd-btn { height: 44px; }
.abd-found { margin-top: 8px; padding: 6px 8px; border: 1px solid var(--b-line); border-radius: 16px; }
.abd-found > .abd-dim { display: block; padding: 8px; }

.abd-h { display: flex; align-items: center; gap: 8px; margin: 20px 2px 6px; font-size: 13px; font-weight: 700; color: var(--b-text-2); text-transform: uppercase; letter-spacing: 0.06em; }
.abd-pill { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--b-accent); color: var(--b-on-accent); font-size: 11px; display: inline-grid; place-items: center; letter-spacing: 0; }
.abd-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 14px; }
.abd-row:hover { background: var(--b-bg-2); }
.abd-av { flex: none; width: 42px; height: 42px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--b-bg-3); font-size: 14px; font-weight: 700; color: var(--b-text-2); }
.abd-av img { width: 100%; height: 100%; object-fit: cover; }
.abd-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.abd-row-text b { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.abd-row-text small { font-size: 12.5px; color: var(--b-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.abd-row-actions { display: flex; gap: 6px; flex: none; }
.abd-more { width: 36px; height: 36px; border-radius: 999px; border: 0 !important; background: none !important; color: var(--b-text-2) !important; font-size: 20px; line-height: 1; }
.abd-more:hover { background: var(--b-bg-3) !important; }
.abd-more.abd-msg { font-size: 17px; }
.abd-tag { padding: 4px 10px; border-radius: 99px; background: var(--b-bg-3); font-size: 12px; font-weight: 700; color: var(--b-text-2); }
.abd-tag.ok { background: var(--b-ok-soft); color: var(--b-ok); }
.abd-dim { color: var(--b-text-3); font-size: 13.5px; }
.abd-empty { margin: 6px 4px 0; font-size: 14px; color: var(--b-text-3); line-height: 1.5; }
.abd-soon { margin: 22px 0 6px; padding: 12px 14px; border-radius: 16px; background: linear-gradient(135deg, rgba(251, 146, 60, 0.14), rgba(239, 68, 68, 0.1)); font-size: 13.5px; color: var(--b-text-2); line-height: 1.45; }
.abd-soon b { color: var(--b-text); }

.abd-toast { position: fixed; z-index: 1400; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 999px; background: var(--b-accent); color: var(--b-on-accent); font-size: 14px; font-weight: 600; box-shadow: var(--b-shadow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.abd-toast[hidden] { display: none; }

/* Streaks */
.abd-streak { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 12px 14px; border-radius: 18px; background: linear-gradient(135deg, rgba(251, 146, 60, 0.16), rgba(239, 68, 68, 0.1)); }
.abd-streak.is-zero { background: var(--b-bg-2); }
.abd-flame { font-size: 30px; line-height: 1; }
.abd-streak-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.abd-streak-text b { font-size: 17px; letter-spacing: -0.01em; }
.abd-streak-text small { font-size: 12.5px; color: var(--b-text-2); }
.abd-freeze { flex: none; padding: 5px 10px; border-radius: 99px; background: rgba(56, 189, 248, 0.16); color: #0369a1; font-size: 12px; font-weight: 700; white-space: nowrap; }
html[data-theme="dark"] .abd-freeze { color: #7dd3fc; }
.abd-freeze.is-used { background: var(--b-bg-3); color: var(--b-text-3); }
.abd-count { display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 10px; border-radius: 99px; background: rgba(251, 146, 60, 0.16); color: #c2410c; font-size: 13px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
html[data-theme="dark"] .abd-count { color: #fdba74; }
.abd-count.is-zero { background: var(--b-bg-3); color: var(--b-text-3); }
.abd-count.is-warn { animation: abd-pulse 1.6s ease-in-out infinite; }
@keyframes abd-pulse { 50% { box-shadow: 0 0 0 4px rgba(251, 146, 60, 0.25); } }
.abd-dim.sm { font-size: 12px; align-self: center; }
@media (max-width: 420px) { .abd-row-actions .abd-btn.sm[data-a="nudge"] { padding: 0 9px; font-size: 12px !important; } .abd-freeze { font-size: 11px; padding: 4px 8px; } }

/* Username dialog */
.abd-modal-wrap { position: fixed; inset: 0; z-index: 1500; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.4); animation: abd-fade 0.2s ease; }
.abd-modal { width: 100%; max-width: 400px; padding: 26px 22px 20px; border-radius: 26px; background: var(--b-bg); box-shadow: var(--b-shadow); text-align: center; animation: abd-pop 0.3s var(--b-ease); }
.abd-modal-emoji { font-size: 40px; line-height: 1; }
.abd-modal h2 { margin: 10px 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--b-text); }
.abd-modal p { margin: 0 0 16px; font-size: 14.5px; color: var(--b-text-2); line-height: 1.5; }
.abd-u-field { display: flex; align-items: center; height: 52px; padding: 0 16px; border-radius: 16px; border: 1.5px solid var(--b-line); background: var(--b-bg-2); text-align: left; }
.abd-u-field:focus-within { border-color: var(--b-text); background: var(--b-bg); }
.abd-u-field span { color: var(--b-text-3); font-weight: 700; font-size: 18px; }
.abd-u-field input:focus, .abd-u-field input:focus-visible { outline: none !important; box-shadow: none !important; }
.abd-u-field input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; color: var(--b-text); font: 600 18px inherit; font-family: inherit; padding-left: 2px; }
.abd-u-hint { min-height: 20px; margin: 8px 2px 0; font-size: 13px; color: var(--b-text-3); text-align: left; }
.abd-u-hint.is-ok { color: var(--b-ok); }
.abd-u-hint.is-bad { color: var(--b-bad); }
.abd-modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.abd-modal-actions .abd-btn { flex: 1; height: 46px; }
@keyframes abd-fade { from { opacity: 0; } }
@keyframes abd-pop { from { transform: translateY(12px) scale(0.98); opacity: 0; } }

@media (max-width: 767px) {
  .abd-panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-width: none; height: calc(100% - 48px); border-radius: 24px 24px 0 0; border-bottom: 0; transform: translateY(100%); }
  .abd-row-actions .abd-btn.sm { padding: 0 11px; }
}
@media (prefers-reduced-motion: reduce) { .abd-panel, .abd-scrim, .abd-modal, .abd-modal-wrap { transition: none !important; animation: none !important; } }

/* ---------- On the Buddies page (#abd-page): cards, two columns, room to breathe ---------- */
.abd-inline { display: block; --abd-card-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 22px 50px -30px rgba(15, 23, 42, 0.3); }
html[data-theme="dark"] .abd-inline { --abd-card-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 22px 50px -30px rgba(0, 0, 0, 0.85); }
.abd-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.abd-side, .abd-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
/* One column on phones and tablets: your buddies come straight after your streak, the extras after them. */
@media (max-width: 959px) {
  .abd-inline .abd-grid { display: flex; flex-direction: column; gap: 16px; }
  .abd-inline .abd-side, .abd-inline .abd-main { display: contents; }
  .abd-inline .abd-me { order: 1; }
  .abd-inline .abd-streak { order: 2; }
  .abd-inline .abd-main > * { order: 3; }
  .abd-inline .abd-find-card { order: 4; }
  .abd-inline .abd-soon { order: 5; }
  .abd-inline .abd-link { order: 6; }
  .abd-inline .abd-h { margin-top: 12px; }
}
@media (min-width: 960px) {
  .abd-inline .abd-grid { grid-template-columns: 370px minmax(0, 1fr); gap: 36px; align-items: start; }
  .abd-inline .abd-side { position: sticky; top: var(--abd-sticky, 160px); }
}
.abd-card { padding: 20px; border-radius: 24px; background: var(--b-bg); border: 1px solid var(--b-line); box-shadow: var(--abd-card-shadow, none); }
.abd-card-h { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: var(--b-text); }
.abd-card-sub { margin: 3px 0 14px; font-size: 13.5px; color: var(--b-text-3); }
.abd-inline .abd-find { margin: 0; }
.abd-inline .abd-find-card .abd-found { margin-top: 12px; }
.abd-inline .abd-me { padding: 18px 20px; border-radius: 24px; background: var(--b-bg); border: 1px solid var(--b-line); box-shadow: var(--abd-card-shadow); }
.abd-inline .abd-me b { font-size: 22px; letter-spacing: -0.02em; }
.abd-inline .abd-streak { position: relative; overflow: hidden; margin: 0; padding: 22px 20px; border-radius: 24px; gap: 16px; box-shadow: var(--abd-card-shadow); background: radial-gradient(120% 140% at 0% 0%, rgba(251, 146, 60, 0.28), transparent 55%), radial-gradient(120% 140% at 100% 100%, rgba(239, 68, 68, 0.2), transparent 60%), var(--b-bg); border: 1px solid rgba(251, 146, 60, 0.28); flex-wrap: wrap; }
.abd-inline .abd-streak.is-zero { background: var(--b-bg); border-color: var(--b-line); }
.abd-inline .abd-streak { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 18px; row-gap: 12px; align-items: center; }
.abd-inline .abd-streak .abd-freeze { grid-column: 2; justify-self: start; }
.abd-inline .abd-flame { font-size: 46px; filter: drop-shadow(0 6px 14px rgba(239, 68, 68, 0.35)); animation: abd-flicker 2.6s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes abd-flicker { 0%, 100% { transform: scale(1) rotate(0); } 30% { transform: scale(1.06) rotate(-3deg); } 60% { transform: scale(0.97) rotate(2deg); } }
.abd-inline .abd-streak-text b { font-size: 22px; letter-spacing: -0.02em; }
.abd-inline .abd-streak-text small { font-size: 13.5px; margin-top: 2px; }
.abd-inline .abd-h { margin: 10px 4px 2px; }
.abd-inline .abd-h:first-child { margin-top: 0; }
.abd-list { display: flex; flex-direction: column; gap: 10px; }
.abd-list.is-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.abd-inline .abd-list .abd-row { padding: 14px 16px; border-radius: 22px; background: var(--b-bg); border: 1px solid var(--b-line); box-shadow: var(--abd-card-shadow); transition: transform 0.35s var(--b-ease), box-shadow 0.35s var(--b-ease), border-color 0.2s ease; }
.abd-inline .abd-list .abd-row:hover { background: var(--b-bg); transform: translateY(-2px); border-color: var(--b-line); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 26px 50px -24px rgba(15, 23, 42, 0.35); }
.abd-inline .abd-list.is-cards .abd-row { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "av text" "act act"; column-gap: 14px; row-gap: 14px; align-items: center; }
.abd-inline .abd-list.is-cards .abd-row > .abd-av { grid-area: av; width: 52px; height: 52px; font-size: 16px; }
.abd-inline .abd-list.is-cards .abd-row-text { grid-area: text; }
.abd-inline .abd-list.is-cards .abd-row-text b { font-size: 16px; }
.abd-inline .abd-list.is-cards .abd-row-text small { white-space: normal; line-height: 1.4; margin-top: 2px; }
.abd-inline .abd-list.is-cards .abd-row-actions { grid-area: act; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--b-line); }
.abd-inline .abd-list.is-cards .abd-row-actions .abd-msg { flex: 1; min-width: 120px; }
.abd-inline .abd-list.is-cards .abd-row-actions .abd-btn.sm { height: 36px; }
.abd-inline .abd-row-actions .abd-msg { background: var(--aria-blue, #0a7cff) !important; border-color: transparent !important; color: #fff !important; }
.abd-inline .abd-empty-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 24px; text-align: center; }
.abd-inline .abd-empty-card b { font-size: 18px; }
.abd-inline .abd-empty-card .abd-empty { margin: 0; max-width: 42ch; }
.abd-empty-art { font-size: 48px; line-height: 1; animation: abd-float 3.4s ease-in-out infinite; }
@keyframes abd-float { 50% { transform: translateY(-6px); } }
.abd-inline .abd-soon { margin: 0; padding: 16px 18px; border-radius: 22px; }
.abd-inline .abd-link { align-self: flex-start; padding-left: 4px; }
/* First appearance: cards rise in one after another (not on every refresh). */
.abd-inline:not(.is-settled) .abd-card, .abd-inline:not(.is-settled) .abd-me, .abd-inline:not(.is-settled) .abd-streak, .abd-inline:not(.is-settled) .abd-list .abd-row { animation: abd-rise 0.6s var(--b-ease) both; }
.abd-inline .abd-side > :nth-child(2), .abd-inline .abd-list > :nth-child(2) { animation-delay: 0.05s; }
.abd-inline .abd-side > :nth-child(3), .abd-inline .abd-list > :nth-child(3) { animation-delay: 0.1s; }
.abd-inline .abd-side > :nth-child(4), .abd-inline .abd-list > :nth-child(4) { animation-delay: 0.15s; }
.abd-inline .abd-list > :nth-child(n+5) { animation-delay: 0.2s; }
@keyframes abd-rise { from { opacity: 0; transform: translateY(14px) scale(0.99); } }
/* Loading */
.abd-skel-card { display: flex; flex-direction: column; gap: 12px; }
.abd-skel { height: 14px; border-radius: 99px; background: linear-gradient(90deg, var(--b-bg-2), var(--b-bg-3), var(--b-bg-2)); background-size: 200% 100%; animation: abd-shimmer 1.3s linear infinite; }
@keyframes abd-shimmer { to { background-position: -200% 0; } }
.abd-inline .abd-toast { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
@media (prefers-reduced-motion: reduce) { .abd-inline *, .abd-inline { animation: none !important; transition: none !important; } }
