/* Shared components: toasts, dialogs/sheets, popovers/menus, segmented controls, avatars, fields, cards, auth. */

/* toasts */
.toasts {
  position: fixed; z-index: 100; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(460px, calc(100vw - 24px));
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 100%; padding: 8px 8px 8px 16px;
  background: var(--toast-bg); color: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  font: var(--t-subhead); animation: toast-in var(--dur-3) var(--ease-spring) both;
}
.toast-text { flex: 1; min-width: 0; }
.toast-error { background: var(--red-fill); }
.toast-action { border: 0; background: rgb(255 255 255 / 16%); color: #fff; font-weight: 600; border-radius: var(--r-sm); padding: 6px 12px; min-height: 32px; }
.toast-close { border: 0; background: transparent; color: rgb(255 255 255 / 70%); width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; }
.toast-out { animation: toast-out var(--dur-2) ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* dialogs */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: var(--overlay); display: grid; place-items: center; padding: 24px;
  animation: fade-in var(--dur-2) both;
}
.overlay.is-closing { animation: fade-out var(--dur-2) both; }
@keyframes fade-out { to { opacity: 0; } }
.modal {
  --drag: 0px;
  width: min(480px, 100%); max-height: min(88vh, 900px); display: flex; flex-direction: column; overflow: hidden;
  background: var(--sheet-bg); border-radius: var(--r-sheet); box-shadow: var(--shadow-sheet); outline: none;
  animation: pop-in var(--dur-3) var(--ease-out) both;
}
.modal-wide { width: min(680px, 100%); }
.modal-small { width: min(400px, 100%); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 8px 20px; position: relative; }
.modal-head h2 { flex: 1; min-width: 0; font: var(--t-title3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 6px 20px 20px; overflow-y: auto; overscroll-behavior: contain; }
.modal-body > .stack, .modal-body > form { margin: 0; }
.grabber { display: none; }

/* popovers & menus */
.popover {
  position: fixed; z-index: 70; min-width: 220px; max-width: min(360px, calc(100vw - 16px)); max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 6px;
  animation: pop-in var(--dur-2) var(--ease-out) both;
}
.menu { display: flex; flex-direction: column; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 10px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--label); text-align: left; font: var(--t-body);
}
.menu-item .icon { color: var(--label-2); }
.menu-item.is-danger, .menu-item.is-danger .icon { color: var(--red); }
.menu-item.is-checked > .icon:last-child { color: var(--tint); }
.menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-hint { color: var(--label-2); font: var(--t-footnote); }
.menu-icon-space { width: 17px; flex: none; }
.menu-sep { height: 1px; background: var(--separator); margin: 5px 8px; }
.menu-heading { padding: 10px 10px 4px; font: 600 11px/14px var(--font-text); color: var(--label-2); text-transform: uppercase; letter-spacing: .04em; }
.menu-item:focus-visible { outline: none; background: var(--accent-fill); color: #fff; }
.menu-item:focus-visible .icon, .menu-item:focus-visible .menu-hint { color: #fff; }
@media (hover: hover) { .menu-item:hover { background: var(--fill-3); } }
.prio-flag { display: inline-flex; }
.prio-flag.prio-1, .prio-value.prio-1 { color: var(--p1); }
.prio-flag.prio-2, .prio-value.prio-2 { color: var(--p2); }
.prio-flag.prio-3, .prio-value.prio-3 { color: var(--p3); }
.prio-flag.prio-4, .prio-value.prio-4 { color: var(--label-2); }
.prio-flag .icon { color: inherit !important; }

/* date picker */
.date-picker { display: flex; flex-direction: column; gap: 6px; min-width: 260px; }
.date-picker-custom { display: flex; flex-direction: column; gap: 8px; padding: 8px 6px 4px; border-top: 1px solid var(--separator); }
.date-picker-row { display: flex; align-items: center; gap: 8px; color: var(--label-2); }

/* segmented control */
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--fill-3); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: transparent; color: var(--label);
  min-height: 28px; padding: 0 12px; border-radius: 7px; font: 500 13px/1 var(--font-text); white-space: nowrap; flex: none;
}
.seg-btn.is-on { background: var(--seg-thumb); box-shadow: 0 1px 3px rgb(0 0 0 / 12%), 0 0 0 .5px rgb(0 0 0 / 4%); font-weight: 600; }
.seg-tabs { margin-bottom: 14px; display: flex; width: 100%; }
.seg-tabs .seg-btn { flex: 1; }
.seg-small .seg-btn { min-height: 26px; font-size: 12.5px; }

/* avatars */
.avatar {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%; color: #fff; font-weight: 600;
  background: var(--cc, var(--c9)); user-select: none; letter-spacing: 0;
}
.avatar-xs { width: 18px; height: 18px; font-size: 8.5px; }
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar-md { width: 30px; height: 30px; font-size: 12px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }
.avatar-empty, .avatar-icon { background: var(--fill-2); color: var(--label-2); }
.avatar-more { background: var(--fill-1); color: var(--label); }
.avatar-stack { display: inline-flex; align-items: center; border: 0; background: transparent; padding: 2px 4px; border-radius: var(--r-pill); }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--bg); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }

/* fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font: 600 13px/16px var(--font-text); color: var(--label-2); }
.field-hint { font: var(--t-footnote); color: var(--label-2); margin: 0; }
.field-error { color: var(--red); font: var(--t-footnote); margin: 0; }
.input-prefix { display: flex; align-items: center; gap: 0; }
.input-prefix > span { padding: 0 8px 0 2px; color: var(--label-2); font-weight: 600; }
.copy-row { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-row input { flex: 1 1 220px; font-family: var(--font-mono); font-size: 13px; }

.palette { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--cc); color: #fff; display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 8%); transition: transform var(--dur-2) var(--ease-spring);
}
.swatch.is-on { box-shadow: 0 0 0 2px var(--sheet-bg), 0 0 0 4px var(--cc); transform: scale(1.04); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.emoji-btn { height: 38px; border: 0; border-radius: var(--r-md); background: var(--fill-4); font-size: 19px; display: grid; place-items: center; color: var(--label-2); }
.emoji-btn.is-on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--tint); }

/* pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 11px; border-radius: var(--r-pill); border: 0;
  background: var(--fill-3); color: var(--label); font: 500 13px/1 var(--font-text); white-space: nowrap;
}
.pill.is-on { background: var(--accent-soft); color: var(--tint-text); }
.pill-sun.is-on { background: color-mix(in srgb, var(--sun) 18%, transparent); color: color-mix(in srgb, var(--sun) 70%, var(--label)); }

/* cards, pages */
.page { display: flex; flex-direction: column; gap: 16px; padding-top: 8px; }
.card { background: var(--surface); border-radius: var(--r-xl); padding: 18px 20px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 14px; }
.card-title { font: var(--t-title3); }
.section-title { font: 600 13px/18px var(--font-text); color: var(--label-2); margin: 6px 0 0; }
.page-heading { font: var(--t-headline); color: var(--label-2); margin: 8px 4px 6px; }
.inset-list { background: var(--surface); border-radius: var(--r-xl); padding: 4px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; }
.profile-row { display: flex; align-items: center; gap: 14px; }
.danger-zone { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--separator); }
.help-card { background: var(--fill-4); border-radius: var(--r-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.cmd-list, .steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font: var(--t-subhead); }
.tg-linked { display: flex; align-items: center; gap: 12px; color: var(--green-text); }
.tg-linked .grow { color: var(--label); }

/* tip card */
.tip-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: var(--r-lg);
  background: var(--accent-soft); color: var(--label); margin: 4px 0 12px;
}
.tip-icon { color: var(--tint); display: inline-flex; }
.tip-text { flex: 1; display: flex; flex-direction: column; gap: 2px; font: var(--t-subhead); }

/* empty / loading */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 16px 32px; color: var(--label-2); gap: 4px; }
.empty-icon { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--fill-4); color: var(--label-3); margin-bottom: 10px; }
.empty-title { font: var(--t-headline); color: var(--label); margin: 0; }
.empty-text { font: var(--t-subhead); margin: 0; max-width: 340px; }
.small-empty { padding: 28px 16px; }
.loading { padding: 32px 16px; text-align: center; color: var(--label-2); font: var(--t-subhead); }
.skeleton { display: flex; flex-direction: column; gap: 12px; padding: 24px 4px; }
.skeleton span { height: 18px; border-radius: 6px; background: var(--fill-3); animation: shimmer 1.2s ease-in-out infinite alternate; }
.skeleton span:nth-child(2) { width: 80%; } .skeleton span:nth-child(3) { width: 60%; }
@keyframes shimmer { from { opacity: .5; } to { opacity: 1; } }

/* notifications */
.bell-btn { position: relative; }
.bell-badge {
  position: absolute; top: 2px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-pill);
  background: var(--red-fill); color: #fff; font: 700 10px/16px var(--font-text); text-align: center; pointer-events: none;
}
.popover-notif { width: 380px; padding: 0; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 16px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.notif-list { display: flex; flex-direction: column; padding: 0 6px 6px; }
.notif {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px; border: 0; background: transparent; border-radius: var(--r-md);
  text-align: left; width: 100%; color: var(--label);
}
.notif.is-unread { background: color-mix(in srgb, var(--tint) 7%, transparent); }
.notif-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-text { font: var(--t-subhead); }
.notif-time { font: var(--t-footnote); color: var(--label-2); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tint); margin-top: 6px; flex: none; }
@media (hover: hover) { .notif:hover { background: var(--fill-4); } }

/* members / invites / activity */
.member-list, .invite-list, .tg-chats { display: flex; flex-direction: column; gap: 2px; }
.member, .invite-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--separator); }
.member:last-child, .invite-row:last-child { border-bottom: 0; }
.member-main, .invite-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.member-name { font: var(--t-headline); }
.member-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font: var(--t-footnote); }
.member-tg, .member-tg-edit { display: inline-flex; align-items: center; gap: 3px; color: var(--tint-text); }
.tg-inline { width: 130px; min-height: 26px; padding: 2px 6px; font-size: 13px; background: var(--fill-4); border-color: transparent; }
.role-select { width: auto; min-height: 30px; font-size: 13px; }
.role-badge { font: var(--t-footnote); color: var(--label-2); background: var(--fill-3); padding: 4px 8px; border-radius: var(--r-pill); }
.invite-create { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-create > select, .invite-create > input { flex: 1 1 220px; width: auto; }
.invite-result { background: var(--green-soft); border-radius: var(--r-lg); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.activity-feed { display: flex; flex-direction: column; }
.activity-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 2px; font: var(--t-subhead); }
.activity-item time { margin-left: auto; color: var(--label-2); font: var(--t-footnote); white-space: nowrap; padding-left: 8px; }
.activity-text { flex: 1; min-width: 0; }
.activity-task { color: var(--label-2); }
.activity-link { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; text-align: left; color: inherit; font: inherit; }
.activity-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--fill-3); color: var(--label-2); flex: none; }
.shortcuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 24px; }
.kbd-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 8px 0; align-items: center; }
.kbd-list dd { margin: 0; font: var(--t-subhead); }

/* auth */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; padding-top: calc(24px + var(--safe-top));
  background: radial-gradient(1200px 600px at 20% -10%, var(--mesh-1), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, var(--mesh-2), transparent 60%), var(--bg);
}
.auth-card {
  width: min(400px, 100%); background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-sheet); padding: 32px 28px 28px;
  display: flex; flex-direction: column; gap: 14px; animation: pop-in var(--dur-4) var(--ease-out) both;
}
.auth-logo { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; color: #fff; margin: 0 auto 4px;
  background: linear-gradient(135deg, #2f8cff, #0060df); box-shadow: 0 8px 20px rgb(0 113 227 / 30%); }
.auth-title { text-align: center; font: var(--t-title1); }
.auth-sub { text-align: center; color: var(--label-2); margin: -6px 0 6px; }
.auth-error { color: var(--red); background: var(--red-soft); border-radius: var(--r-md); padding: 8px 12px; margin: 0; font: var(--t-subhead); }
.auth-me { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--label-2); }
.auth input { min-height: 44px; }
.warn-note { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--orange-soft); color: var(--orange-text); font: var(--t-footnote); }
.warn-note .icon { margin-top: 1px; }
