/* ---- Avatars ---------------------------------------------------------------- */
.avatar {
  position: relative; flex-shrink: 0; display: inline-grid; place-items: center; border-radius: 50%;
  font-weight: 600; color: #fff; overflow: visible; user-select: none; line-height: 1;
}
.avatar > img, .avatar > .avatar-fill { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; display: grid; place-items: center; }
.avatar.square { border-radius: 28%; }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 30%; height: 30%; min-width: 9px; min-height: 9px; border-radius: 50%; background: var(--text-3); border: 2px solid var(--surface); }
.avatar .dot.on { background: var(--online); }
button.avatar-btn { border: none; background: none; padding: 0; border-radius: 50%; }

/* ---- Menus and popovers ----------------------------------------------------- */
.popover {
  position: fixed; z-index: 80; min-width: 220px; max-width: min(320px, calc(100vw - 16px)); padding: 6px;
  background: var(--glass); border: 1px solid var(--glass-brd); border-radius: 14px; box-shadow: var(--shadow-lg);
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
  animation: pop .14s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: none; background: none;
  border-radius: var(--r-sm); color: var(--text); font-size: 13px; text-align: left; white-space: nowrap;
}
.menu-item svg { width: 17px; height: 17px; color: var(--text-2); flex-shrink: 0; }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); box-shadow: none; }
.menu-item.danger, .menu-item.danger svg { color: var(--danger); }
.menu-item .menu-right { margin-left: auto; color: var(--text-3); font-size: 12px; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-label { padding: 8px 10px 4px; font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.menu-head { display: flex; align-items: center; gap: 11px; padding: 8px 10px 10px; }

/* ---- Dialogs and sheets ----------------------------------------------------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: var(--overlay); display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.dialog {
  width: 100%; max-width: 480px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  animation: rise .18s var(--ease); overflow: hidden;
}
.dialog.wide { max-width: 640px; }
.dialog.xwide { max-width: 860px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.dialog-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 6px; }
.dialog-title { font-family: var(--font-display); font-size: 21px; font-weight: 400; line-height: 1.2; }
.dialog-sub { font-size: 13.5px; color: var(--text-2); margin-top: 4px; }
.dialog-body { padding: 14px 22px 18px; overflow-y: auto; }
.dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); }
@media (max-width: 560px) {
  .scrim { padding: 0; align-items: end; }
  .dialog { max-width: none; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92dvh; }
}

/* A full-screen page that sits over the app: settings, details, IDE, slides */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg); animation: sheetIn .2s var(--ease); overflow: hidden; }
.sheet > :not(.mesh) { position: relative; z-index: 1; }
@keyframes sheetIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.sheet-head { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 16px; border-bottom: 1px solid var(--glass-brd); flex-shrink: 0; background: var(--glass); backdrop-filter: blur(var(--glass-blur)) saturate(150%); -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; }
.sheet-inner { max-width: 880px; margin: 0 auto; padding: 28px 24px 60px; }
@media (max-width: 600px) { .sheet-inner { padding: 20px 16px 48px; } }

/* ---- Cards, lists, empty states --------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.list-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: none; background: none;
  border-radius: var(--r); text-align: left; color: var(--text); transition: background .12s; position: relative;
}
button.list-item:hover, a.list-item:hover { background: var(--hover); text-decoration: none; }
.list-item.active { background: var(--surface); box-shadow: var(--shadow-sm); }
.list-item .li-title { font-weight: 500; font-size: 13.5px; }
.list-item .li-sub { font-size: 12.5px; color: var(--text-3); }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 48px 24px; color: var(--text-2); }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-3); margin-bottom: 4px; }
.empty-icon svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); font-family: var(--font-display); font-size: 21px; font-weight: 400; }
.empty p { margin: 0; max-width: 360px; font-size: 13.5px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; }
.tab { position: relative; border: none; background: none; padding: 12px 10px; font-size: 13px; font-weight: 500; color: var(--text-2); display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); }
.tab.on::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); }
.progress { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .2s; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.notice svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.notice.warn { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.notice.warn svg { color: var(--accent); }
.notice.error { background: var(--danger-soft); border-color: var(--danger); color: var(--text); }
.notice.error svg { color: var(--danger); }
.notice.info svg { color: var(--info); }

/* ---- Toasts ----------------------------------------------------------------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 12px; width: 360px; max-width: calc(100vw - 32px);
  padding: 12px 14px; background: var(--glass); color: var(--text); border: 1px solid var(--glass-brd); border-radius: 14px;
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: var(--shadow-lg); animation: toastIn .22s var(--ease);
}
.toast.simple { width: auto; align-items: center; padding: 10px 16px; font-size: 13.5px; font-weight: 500; background: var(--text); color: var(--bg); border-color: transparent; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
/* Phones: pop-ups drop from the top so they never cover the message box or
   the tab bar, and only the newest one shows. */
@media (max-width: 760px) {
  .toasts { left: 10px; right: 10px; top: calc(10px + env(safe-area-inset-top)); bottom: auto; align-items: stretch; flex-direction: column-reverse; }
  .toast { width: auto; padding: 10px 12px; }
  .toasts > .toast:not(:last-child) { display: none; }
  .toast.simple { align-self: center; }
  @keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
}

/* ---- Profile card ------------------------------------------------------------- */
.profile-cover { height: 96px; background: linear-gradient(135deg, var(--text), var(--accent)); }
.profile-main { padding: 0 22px 20px; margin-top: -44px; }
.profile-main .avatar { box-shadow: 0 0 0 4px var(--surface); }

/* ---- Tour --------------------------------------------------------------------- */
.tour-ring { position: fixed; z-index: 96; border-radius: 12px; box-shadow: 0 0 0 4px var(--accent), 0 0 0 9999px rgba(0,0,0,.5); pointer-events: none; transition: all .25s var(--ease); }
.tour-card { position: fixed; z-index: 97; width: 320px; max-width: calc(100vw - 24px); padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); animation: rise .2s var(--ease); }

/* ---- Developer mode ------------------------------------------------------------ */
body.dev-mode [data-dev-copy]:hover { outline: 1.5px dashed var(--accent); outline-offset: 2px; cursor: text; }
.dev-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 99; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; background: var(--text); color: var(--bg); border-radius: var(--r-full); box-shadow: var(--shadow-lg); font-size: 12.5px; }
.dev-bar .btn { height: 28px; }
