/* ZamamQA component (prototype v2) — styles for `.tool-qa.zq` (any page: tools, articles).
   Theme: dark by default, light under [data-theme="light"]. Page skins override --zq-* only. */
.zq {
  --zq-ink: #f4efe2; --zq-muted: #c9bfe6; --zq-soft: #9d93bd;
  --zq-card: rgba(26, 19, 58, .72); --zq-card-2: rgba(255, 255, 255, .035); --zq-brd: rgba(242, 196, 109, .2); --zq-brd-hi: rgba(242, 196, 109, .5);
  --zq-accent: #f2c46d; --zq-accent-ink: #1d0f2e; --zq-ok: #34d399; --zq-hot: #fb923c; --zq-wait: #a5b4fc;
  --zq-best: rgba(242, 196, 109, .1); --zq-field: rgba(9, 6, 26, .55); --zq-skel: rgba(255, 255, 255, .07); --zq-skel-hi: rgba(255, 255, 255, .14);
  --zq-r: 20px; --zq-av-l: 62%; --zq-av-s: 55%;
  max-width: 980px; margin: 0 auto; color: var(--zq-ink);
}
[data-theme="light"] .zq {
  --zq-ink: #24160a; --zq-muted: #5b4528; --zq-soft: #85704f;
  --zq-card: rgba(255, 252, 244, .94); --zq-card-2: rgba(150, 104, 30, .045); --zq-brd: rgba(150, 104, 30, .2); --zq-brd-hi: rgba(150, 104, 30, .48);
  --zq-accent: #a8741a; --zq-accent-ink: #fffaf0; --zq-ok: #047857; --zq-hot: #c2410c; --zq-wait: #4338ca;
  --zq-best: rgba(168, 116, 26, .08); --zq-field: #fffdf7; --zq-skel: rgba(120, 90, 40, .08); --zq-skel-hi: rgba(120, 90, 40, .16); --zq-av-l: 42%;
}
.zq .zq-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* toolbar + bar */
.zq .tool-qa__toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.zq .tool-qa__sort-label { display: flex; align-items: center; gap: 8px; color: var(--zq-muted); font-size: .88rem; }
.zq .tool-qa__sort-label select { min-height: 40px; padding: 0 12px; border-radius: 12px; font: inherit; color: var(--zq-ink); background: var(--zq-field); border: 1px solid var(--zq-brd); }
.zq-bar { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; align-items: center; margin: 0 0 16px; padding: 12px 14px; border-radius: 16px; background: var(--zq-card-2); border: 1px solid var(--zq-brd); }
.zq-stats { font-size: .86rem; color: var(--zq-muted); }
.zq-stats b { color: var(--zq-accent); font-weight: 800; }
.zq-filters { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; order: 3; }
.zq-chip { flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px; font: inherit; font-size: .84rem; font-weight: 700; cursor: pointer;
  color: var(--zq-muted); background: transparent; border: 1px solid var(--zq-brd); transition: background .2s, color .2s, border-color .2s; }
.zq-chip b { font-size: .74rem; min-width: 1.6em; padding: 1px 6px; border-radius: 999px; background: var(--zq-card-2); color: var(--zq-soft); }
.zq-chip:hover { border-color: var(--zq-brd-hi); color: var(--zq-ink); }
.zq-chip[aria-pressed="true"] { color: var(--zq-accent-ink); background: var(--zq-accent); border-color: var(--zq-accent); }
.zq-chip[aria-pressed="true"] b { background: rgba(0, 0, 0, .14); color: inherit; }
.zq-search { position: relative; display: flex; align-items: center; min-width: min(260px, 100%); }
.zq-search svg { position: absolute; inset-inline-start: 12px; width: 18px; height: 18px; color: var(--zq-soft); pointer-events: none; }
.zq-search input { width: 100%; min-height: 40px; padding: 0 14px; padding-inline-start: 38px; border-radius: 12px; font: inherit; font-size: .88rem; color: var(--zq-ink); background: var(--zq-field); border: 1px solid var(--zq-brd); }
.zq :focus-visible { outline: 2px solid var(--zq-accent); outline-offset: 2px; }

/* ask panel (static form, restyled) */
.zq .tool-qa__ask-panel { padding: 20px; border-radius: var(--zq-r); background: var(--zq-card); border: 1px solid var(--zq-brd-hi); margin-bottom: 16px; }
.zq .tool-qa__ask-panel h3 { margin: 0 0 12px; color: var(--zq-accent); font-size: 1.05rem; }
.zq .tool-qa__form { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.zq .tool-qa__form .form-field { display: grid; gap: 6px; }
.zq .tool-qa__form .form-field:nth-of-type(1), .zq .tool-qa__form .form-field:nth-of-type(2), .zq .tool-qa__captcha, .zq .tool-qa__form > .btn { grid-column: 1 / -1; }
.zq .tool-qa__form label { font-weight: 700; font-size: .86rem; color: var(--zq-ink); }
.zq .tool-qa__form input:not([type="hidden"]), .zq .tool-qa__form textarea, .zq-composer textarea, .zq-composer input { width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 12px; font: inherit; color: var(--zq-ink); background: var(--zq-field); border: 1px solid var(--zq-brd); box-sizing: border-box; }
.zq .tool-qa__hint { font-size: .76rem; color: var(--zq-soft); }
.zq .tool-qa__captcha { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.zq .tool-qa__captcha input { width: 110px !important; }
.zq .tool-qa__form > .btn { justify-self: start; }
.zq .tool-qa__toast { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; font-size: .88rem; background: var(--zq-card); border: 1px solid var(--zq-brd-hi); }
.zq .tool-qa__toast--ok { border-color: color-mix(in srgb, var(--zq-ok) 60%, transparent); }
.zq .tool-qa__toast--err { border-color: #f87171; }

/* list + cards */
.zq .tool-qa__list { display: grid; gap: 14px; }
.zq .tool-qa__item { position: relative; padding: 18px 20px 14px; border-radius: var(--zq-r); background: var(--zq-card); border: 1px solid var(--zq-brd); transition: border-color .2s, transform .2s; }
.zq .tool-qa__item:hover { border-color: var(--zq-brd-hi); }
.zq .tool-qa__item[hidden] { display: none; }
.zq .tool-qa__item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.zq .tool-qa__title { margin: 0; font-size: 1.04rem; line-height: 1.8; color: var(--zq-ink); }
.zq .tool-qa__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin: 8px 0 2px; font-size: .8rem; color: var(--zq-soft); }
.zq .tool-qa__meta strong { color: var(--zq-muted); }
.zq .tool-qa__body { color: var(--zq-muted); line-height: 2; margin: 6px 0 0; overflow-wrap: anywhere; }

/* avatars: letter avatars get a stable hue from the name */
.zq .tool-qa__avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; object-fit: cover; }
.zq .tool-qa__avatar--letter { display: inline-grid; place-items: center; font-weight: 800; font-size: .9rem; color: #fff;
  background: radial-gradient(circle at 32% 28%, hsl(var(--zq-h, 40) 80% 72%), hsl(var(--zq-h, 40) var(--zq-av-s) var(--zq-av-l)) 70%); box-shadow: 0 0 0 2px var(--zq-card), 0 0 0 3px hsl(var(--zq-h, 40) 60% 55% / .45); }
[data-theme="light"] .zq .tool-qa__avatar--letter { color: #fff; }
.zq .tool-qa__avatar--brand { background: #fff; padding: 3px; box-shadow: 0 0 0 2px var(--zq-accent); }

/* votes */
.zq .tool-qa__votes { display: flex; align-items: center; gap: 2px; flex: none; padding: 3px; border-radius: 12px; border: 1px solid var(--zq-brd); background: var(--zq-card-2); }
.zq .tool-qa__vote { display: inline-flex; align-items: center; gap: 4px; font: inherit; font-size: .76rem; padding: 5px 9px; min-height: 30px; border-radius: 9px; cursor: pointer; color: var(--zq-muted); background: transparent; border: 0; }
.zq .tool-qa__vote:hover { color: var(--zq-ink); background: var(--zq-card-2); }
.zq .tool-qa__vote.is-active { color: var(--zq-accent-ink); background: var(--zq-accent); }
.zq .tool-qa__vote--down.is-active { background: #94a3b8; color: #0f172a; }
.zq .tool-qa__score { min-width: 2.2ch; text-align: center; font-weight: 800; color: var(--zq-accent); font-variant-numeric: tabular-nums; }
.zq-bump { animation: zqBump .35s ease; }
@keyframes zqBump { 40% { transform: scale(1.35); } }

/* badges */
.zq-badges { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.zq-badge, .zq .tool-qa__badge, .zq-best-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800; line-height: 1.7; white-space: nowrap; }
.zq-badge svg, .zq-best-badge svg { width: 13px; height: 13px; }
.zq .tool-qa__badge { color: var(--zq-accent); background: color-mix(in srgb, var(--zq-accent) 14%, transparent); border: 1px solid color-mix(in srgb, var(--zq-accent) 35%, transparent); }
.zq-badge--ok { color: var(--zq-ok); background: color-mix(in srgb, var(--zq-ok) 12%, transparent); }
.zq-badge--hot { color: var(--zq-hot); background: color-mix(in srgb, var(--zq-hot) 12%, transparent); }
.zq-badge--wait { color: var(--zq-wait); background: color-mix(in srgb, var(--zq-wait) 14%, transparent); }
.zq-best-badge { color: var(--zq-accent-ink); background: var(--zq-accent); }

/* thread */
.zq .tool-qa__answers.zq-thread { position: relative; display: grid; gap: 10px; margin: 12px 0 8px; padding-inline-start: 22px; }
.zq .zq-thread::before { content: ""; position: absolute; inset-block: 4px 18px; inset-inline-start: 16px; width: 2px; border-radius: 2px; background: linear-gradient(var(--zq-brd-hi), var(--zq-brd) 70%, transparent); }
.zq .tool-qa__answer { position: relative; padding: 12px 14px 8px; border-radius: 16px; background: var(--zq-card-2); border: 1px solid var(--zq-brd); }
.zq .tool-qa__answer::before { content: ""; position: absolute; top: 26px; inset-inline-start: -7px; width: 7px; height: 2px; background: var(--zq-brd-hi); }
.zq .tool-qa__answer[hidden] { display: none; }
.zq .tool-qa__answer.zq-best { background: var(--zq-best); border-color: var(--zq-brd-hi); border-inline-start: 3px solid var(--zq-accent); }
.zq .tool-qa__answer.zq-nested { margin-inline-start: 26px; }
.zq .tool-qa__answer.zq-pending, .zq .tool-qa__item.zq-pending { border-style: dashed; }
.zq .tool-qa__answer-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.zq .tool-qa__author-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; flex: 1; min-width: 0; font-size: .8rem; color: var(--zq-soft); }
.zq .tool-qa__author-meta strong { color: var(--zq-ink); font-size: .86rem; }
.zq .tool-qa__answer .tool-qa__votes { padding: 2px; }
.zq-mention { color: var(--zq-accent); font-weight: 700; }
.zq-acts { display: flex; gap: 4px; margin-top: 4px; }
.zq-act { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 10px; border-radius: 9px; font: inherit; font-size: .76rem; color: var(--zq-soft); background: transparent; border: 0; cursor: pointer; }
.zq-act svg { width: 15px; height: 15px; }
.zq-act:hover { color: var(--zq-ink); background: var(--zq-card-2); }
.zq-show-all, .zq-more { justify-self: start; min-height: 32px; padding: 0 12px; border-radius: 9px; font: inherit; font-size: .8rem; font-weight: 700; color: var(--zq-accent); background: transparent; border: 1px dashed var(--zq-brd-hi); cursor: pointer; }
.zq-more { border: 0; padding: 0; min-height: 28px; text-decoration: underline; text-underline-offset: 4px; }
.zq .zq-clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.zq .zq-clamp.zq-open { display: block; -webkit-line-clamp: unset; }
.zq .tool-qa__reply-btn.zq-reply { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: .82rem; }
.zq .tool-qa__reply-btn svg { width: 16px; height: 16px; }

/* composer */
.zq-composer { display: grid; gap: 10px; margin: 10px 0 4px; padding: 14px; border-radius: 16px; background: var(--zq-card-2); border: 1px solid var(--zq-brd-hi); animation: zqIn .25s ease; }
.zq-composer--nested { margin-inline-start: 0; }
.zq-composer__head { display: flex; align-items: center; gap: 10px; font-size: .86rem; }
.zq-composer textarea { min-height: 88px; resize: vertical; line-height: 1.9; }
.zq-composer__row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.zq-composer__row > input { flex: 1 1 180px; width: auto; }
.zq-cap { display: inline-flex; align-items: center; gap: 8px; font-size: .84rem; color: var(--zq-muted); }
.zq-cap input { width: 90px !important; min-height: 40px !important; }
.zq-icon { width: 40px; height: 40px; border-radius: 10px; font: inherit; color: var(--zq-ink); background: transparent; border: 1px solid var(--zq-brd); cursor: pointer; }
.zq-composer__foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.zq-count { margin-inline-end: auto; font-size: .74rem; color: var(--zq-soft); font-variant-numeric: tabular-nums; }
.zq-err { color: #f87171; font-size: .8rem; }
[data-theme="light"] .zq-err { color: #b91c1c; }
@keyframes zqIn { from { opacity: 0; transform: translateY(-4px); } }

/* empty + skeleton + pager */
.zq-empty { display: grid; justify-items: center; gap: 6px; padding: 36px 16px; margin-top: 4px; text-align: center; border-radius: var(--zq-r); border: 1px dashed var(--zq-brd-hi); color: var(--zq-accent); }
.zq-empty[hidden] { display: none; }
.zq-empty svg { width: 140px; height: auto; }
.zq-empty strong { color: var(--zq-ink); font-size: 1rem; }
.zq-empty p { margin: 0 0 8px; color: var(--zq-muted); font-size: .88rem; }
.zq-skel { display: grid; gap: 14px; margin-bottom: 14px; }
.zq-loading .tool-qa__list { display: none; }
.zq-skel__card { display: grid; grid-template-columns: 34px 1fr; gap: 10px 12px; padding: 18px 20px; border-radius: var(--zq-r); border: 1px solid var(--zq-brd); background: var(--zq-card); }
.zq-skel__card i { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--zq-skel) 25%, var(--zq-skel-hi) 50%, var(--zq-skel) 75%); background-size: 300% 100%; animation: zqShim 1.3s linear infinite; }
.zq-skel__card .zq-skel__av { width: 34px; height: 34px; border-radius: 50%; grid-row: span 3; }
.zq-skel__l1 { width: 70%; height: 16px !important; } .zq-skel__l2 { width: 92%; } .zq-skel__l3 { width: 45%; }
@keyframes zqShim { from { background-position: 100% 0; } to { background-position: -200% 0; } }
.zq-loadmore { display: flex; margin: 16px auto 0; min-height: 44px; gap: 6px; align-items: center; }
.zq-loadmore small { color: var(--zq-soft); }
.zq-end { text-align: center; color: var(--zq-soft); font-size: .84rem; }
.zq .tool-qa__pager { display: none; }

@media (max-width: 640px) {
  .zq-bar { grid-template-columns: 1fr; }
  .zq-filters { order: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -4px; padding: 2px 4px; }
  .zq .tool-qa__item { padding: 14px 14px 10px; }
  .zq .tool-qa__item-head { flex-direction: column; gap: 8px; }
  .zq .tool-qa__answers.zq-thread { padding-inline-start: 14px; }
  .zq .zq-thread::before { inset-inline-start: 6px; }
  .zq .tool-qa__answer-head .tool-qa__votes { margin-inline-start: auto; }
  .zq .tool-qa__form { grid-template-columns: 1fr; }
  .zq .tool-qa__answer.zq-nested { margin-inline-start: 12px; }
}
@media (prefers-reduced-motion: reduce) { .zq * { animation: none !important; transition: none !important; } }
