/* Cards, pills, lists, overlays (drawer, sheet, dialog, menu), toasts, empty and loading states.
   Tokens come from theme.css. See docs/FRONTEND.md for the markup each one expects. */

/* ---------- cards ---------- */
.card {
  position: relative; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-lg);
  box-shadow: var(--card-shadow); padding: 22px; backdrop-filter: blur(6px);
}
.card.is-flat { box-shadow: none; }
.card.is-link { cursor: pointer; text-decoration: none; display: block; transition: transform .15s, box-shadow .15s; }
.card.is-link:hover { transform: translateY(-1px); }
.card-head { display: flex; align-items: center; gap: 14px; }
.card-title { font-size: var(--title-card); font-weight: 600; line-height: 1.25; }
.card-title.is-sm { font-size: var(--title-card-sm); line-height: 1.3; }
/* Sentence-case section label (replaces uppercase letter-spaced eyebrows). */
.label { display: block; font-size: var(--label-size); font-weight: 600; color: var(--text-2); letter-spacing: 0; text-transform: none; }
.label.is-sm { font-size: 13px; }
.card-text { margin-top: 10px; color: var(--text-2); font-size: 15px; line-height: 1.38; }
.card-more { margin-left: auto; }
.card-foot {
  display: flex; align-items: center; gap: 14px; margin-top: 14px; min-height: 42px; padding: 0 14px;
  border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); font-size: 15px;
  text-decoration: none; border: 0; width: 100%; cursor: pointer; text-align: left;
}
.card-foot > .ico:last-child { margin-left: auto; width: 18px; height: 18px; }
.card-foot:hover { background: color-mix(in srgb, var(--surface-2) 85%, var(--text) 6%); }
.icon-circle {
  display: grid; place-items: center; flex: none; width: 50px; height: 50px; border-radius: 50%;
  background: var(--icon-circle); color: var(--text);
}
.icon-circle .ico { width: 26px; height: 26px; }
.icon-circle.is-sm { width: 34px; height: 34px; }
.icon-circle.is-sm .ico { width: 18px; height: 18px; }
.icon-circle.is-lg { width: 70px; height: 70px; }
.icon-circle.is-lg .ico { width: 34px; height: 34px; }
.icon-circle.is-soft { background: var(--soft-circle); }
.icon-circle.is-done { background: var(--olive-strong); color: var(--on-solid); }
.tile {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: var(--r-sm);
  background: var(--surface-3); color: var(--text); overflow: hidden;
}
.tile .ico { width: 24px; height: 24px; }

/* ---------- pills ---------- */
/* One status look everywhere (the mock's): a bordered pill with a coloured dot. ok / warn / bad
   get the dot from ::before when the markup has none. .is-muted (filled grey) is only for counts
   and tags, never for a state. */
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.pill.is-ok, .pill.is-warn, .pill.is-bad { background: var(--surface); border-color: var(--border); color: var(--text); }
.pill.is-ok:not(:has(> .dot))::before, .pill.is-warn:not(:has(> .dot))::before, .pill.is-bad:not(:has(> .dot))::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--success);
}
.pill.is-warn:not(:has(> .dot))::before { background: var(--amber); }
.pill.is-bad:not(:has(> .dot))::before { background: var(--danger); }
.pill.is-attn { background: var(--surface); border-color: var(--border); color: var(--text); }
.pill.is-attn:not(:has(> .dot))::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--attn); flex: none; }
.pill.is-muted { background: var(--surface-2); border-color: transparent; color: var(--text-2); }
button.pill, a.pill { cursor: pointer; text-decoration: none; }
button.pill:hover, a.pill:hover { border-color: color-mix(in srgb, var(--border) 60%, var(--text) 25%); }

/* ---------- segmented control (filters, tabs, either/or choices) ----------
   <div class="seg" role="group|tablist|radiogroup">
     <button class="seg-btn" aria-pressed|aria-selected|aria-checked="true">All <span class="seg-n">6</span></button>
   </div>
   .seg.is-block stretches the buttons to fill the row. */
.seg {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; max-width: 100%; align-self: flex-start;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 9px; background: none; color: var(--text-2);
  font: inherit; font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer; text-decoration: none;
}
.seg-btn:hover { background: var(--nav-hover); color: var(--text); }
.seg-btn[aria-pressed="true"], .seg-btn[aria-selected="true"], .seg-btn[aria-checked="true"], .seg-btn.is-on {
  background: var(--nav-active); border-color: var(--nav-active-border); color: var(--selected-text); font-weight: 600;
}
.seg-btn:focus-visible { outline-offset: 0; }
.seg-n { color: var(--text-3); font-weight: 500; font-variant-numeric: tabular-nums; }
.seg-btn[aria-pressed="true"] .seg-n, .seg-btn[aria-selected="true"] .seg-n { color: var(--text-2); }
.seg.is-block { display: flex; align-self: stretch; }
.seg.is-block .seg-btn { flex: 1 1 0; }
@media (max-width: 820px) {
  .seg { display: flex; align-self: stretch; }
  .seg-btn { flex: 1 1 auto; height: 44px; padding: 0 10px; }
}

/* ---------- lists and tables ---------- */
.list { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-lg); overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 12px 18px; color: inherit;
  text-decoration: none; border-top: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left;
}
.list-row:first-child { border-top: 0; }
a.list-row:hover, button.list-row:hover { background: var(--nav-hover); cursor: pointer; }
.list-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row > .ico:last-child { width: 18px; height: 18px; color: var(--text-3); }
.table-wrap { overflow-x: auto; border: 1px solid var(--card-border); border-radius: var(--r-lg); background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 13px; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.is-link { cursor: pointer; }
.table tbody tr.is-link:hover { background: var(--nav-hover); }

/* ---------- overlays ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 60; opacity: 0; transition: opacity .2s; }
.scrim.is-open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); z-index: 61; display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .22s ease;
}
.drawer.is-open { transform: none; }
.drawer.is-wide { width: min(720px, 100vw); }
.overlay-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.overlay-head .h2 { flex: 1 1 auto; min-width: 0; }
.overlay-body { flex: 1 1 auto; overflow: auto; padding: 22px; }
.overlay-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 86dvh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(100%); transition: transform .22s ease;
}
.sheet.is-open { transform: none; }
.sheet-grip { width: 42px; height: 5px; border-radius: 3px; background: var(--border); margin: 10px auto 0; flex: none; }
.dialog {
  position: fixed; left: 50%; top: 50%; z-index: 71; width: min(440px, calc(100vw - 32px));
  transform: translate(-50%, -48%); opacity: 0; transition: opacity .15s, transform .15s;
  background: var(--card-solid); border: 1px solid var(--card-border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 24px;
}
.dialog.is-open { opacity: 1; transform: translate(-50%, -50%); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.scrim.is-dialog { z-index: 70; }
.menu {
  position: fixed; z-index: 80; min-width: 220px; padding: 6px; border-radius: var(--r);
  background: var(--card-solid); border: 1px solid var(--card-border); box-shadow: var(--shadow-lg);
}
.menu-label { padding: 8px 10px 4px; font-size: 12px; color: var(--text-3); font-weight: 500; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--r-sm);
  background: none; text-align: left; cursor: pointer; font-size: 14px; color: var(--text); text-decoration: none;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--nav-hover); }
.menu-item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
@media (max-width: 820px) { .menu-item { min-height: 44px; } }
.menu-item .ico { width: 18px; height: 18px; }
.menu-item .menu-check { margin-left: auto; visibility: hidden; }
.menu-item[aria-checked="true"] .menu-check { visibility: visible; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(460px, calc(100vw - 32px)); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px 12px 16px;
  border-radius: var(--r); background: var(--card-solid); color: var(--text); border: 1px solid var(--card-border);
  box-shadow: var(--shadow-lg); font-size: 14px; animation: toast-in .18s ease;
}
.toast .dot { width: 10px; height: 10px; flex: none; }
.toast-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.toast.is-error { border-color: color-mix(in srgb, var(--danger) 45%, var(--card-border)); }
.toast-action { flex: none; white-space: nowrap; }
/* Dismiss: a 44px target that does not make the toast taller. */
.toast .toast-dismiss { width: 44px; height: 44px; margin: -10px -10px -10px -4px; color: var(--text-2); }
.toast .toast-dismiss .ico { width: 16px; height: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- empty, error, loading ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 48px 20px; color: var(--text-2); }
.empty .icon-circle { margin-bottom: 6px; }
.empty-title { font-size: var(--title-card); font-weight: 600; color: var(--text); }
.empty-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--info-bg); font-size: 14px; }
.notice.is-bad { background: var(--danger-bg); color: var(--danger); }
.notice.is-warn { background: var(--warning-bg); }
.notice.is-ok { background: var(--success-bg); }
.notice .ico { width: 18px; height: 18px; margin-top: 1px; }
/* Loading: ai.chat2.com's typing indicator, exactly (three 6 px dots, 4 px apart, keyframes ks-dot in theme.css).
   Markup: typingDots() in lib/ui.js -> <span class="spinner"><span></span><span></span><span></span></span>. */
.spinner { display: inline-flex; gap: 4px; padding: 4px 0; flex: none; align-items: center; }
.spinner > span { width: 6px; height: 6px; background: var(--text-3); border-radius: 50%; animation: ks-dot 1.4s infinite; }
.spinner > span:nth-child(2) { animation-delay: 0.2s; }
.spinner > span:nth-child(3) { animation-delay: 0.4s; }
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 48px 20px; color: var(--text-2); }
.skeleton {
  display: block; height: 14px; border-radius: 6px;
  background: var(--skeleton) linear-gradient(90deg, var(--skeleton), var(--skeleton-shine), var(--skeleton)) no-repeat;
  background-size: 200px 100%; animation: shine 2s ease-in-out infinite;
}
.skeleton.is-block { height: 64px; border-radius: var(--r); }
.skeleton.is-circle { width: 44px; height: 44px; border-radius: 50%; }

/* ---------- touch: small interactive things get a 44px tall hit area without growing ----------
   Add .hit-44 to any small link or button; pages use the same rule for their own small links. */
@media (pointer: coarse) {
  .hit-44, button.pill, a.pill { position: relative; }
  .hit-44::after, button.pill::after, a.pill::after {
    content: ""; position: absolute; left: -2px; right: -2px; top: 50%; height: 44px; min-width: 44px; transform: translateY(-50%);
  }
}

/* A service with no logo file (lib/brand.js): the calm tile with a line icon for what it does. */
.brand-tile.is-generic { color: var(--text-2); }
.brand-tile.is-generic .ico { stroke-width: 1.6; }

/* One line under an object page's tabs saying what this tab is for (lib/shell.js object header). */
.page-intro { margin: 0 0 16px; font-weight: 600; color: var(--text-2); font-size: 15px; }

/* infoTip: a small "i" with a one-line explanation on hover, focus or tap. */
.info-tip { position: relative; display: inline-flex; vertical-align: middle; margin-left: 6px; }
.info-tip-btn { display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--text-3); cursor: help; }
.info-tip-btn .ico { width: 16px; height: 16px; }
.info-tip-btn:hover, .info-tip-btn:focus-visible { color: var(--text); }
.info-tip-bubble { position: fixed; left: 0; top: 0; z-index: 2000;
  width: max-content; max-width: 300px; padding: 8px 12px; border-radius: var(--r); background: var(--surface-3, var(--surface-2));
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); color: var(--text); font-size: 13px; font-weight: 400; line-height: 1.4;
  white-space: normal; text-align: left; visibility: hidden; opacity: 0; transition: opacity .15s; pointer-events: none; }
.info-tip.is-open .info-tip-bubble, .info-tip-bubble.is-open { visibility: visible; opacity: 1; }

/* Page pictures (lib/thumb.js): 16:10 like the 1280 x 800 capture. Without one, the file type icon. */
.thumb { position: relative; flex: none; aspect-ratio: 16 / 10; overflow: hidden; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); }
.thumb.is-row { width: 144px; }
.thumb.is-card { width: 96px; border-radius: 8px; }
.thumb.is-feature { width: min(400px, 100%); border-radius: 14px; }
.thumb-pic { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.thumb.is-empty { background: var(--surface-2); }
.thumb-icon { position: absolute; inset: 0; margin: auto; height: 100%; width: auto; display: block; }   /* the icon scaled up (it is SVG), never stretched */
@media (max-width: 820px) {
  .thumb.is-row { width: 96px; }
  .thumb.is-card { width: 72px; }
  .thumb.is-feature { width: 100%; }
}
.thumb.is-tree { width: 64px; border-radius: 6px; }
.thumb.is-tree-kid { width: 48px; border-radius: 5px; }
.thumb-pic.is-loading { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
/* a picture being taken right now (lib/thumb.js, now) */
.thumb.is-taking .thumb-icon { animation: thumb-pulse 1.4s ease-in-out infinite; }
.thumb-taking { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px; font-size: 12px; color: var(--text-2);
  background: linear-gradient(transparent, color-mix(in srgb, var(--surface) 92%, transparent) 40%); text-align: center; }
@keyframes thumb-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .thumb.is-taking .thumb-icon { animation: none; } }
