/* ============================================================
   PIPSDEX — Components
   ============================================================ */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; position: relative;
}
.card.flat { background: var(--panel-2); }
.card.tight { padding: 12px; }
.card-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; color: var(--accent); font-family: var(--mono); }
.card-title svg { width: 15px; height: 15px; }
.card-title.white { color: var(--text); font-family: var(--font); }
.card-sub { color: var(--muted); font-size: 12px; font-family: var(--mono); margin-top: 3px; }
.card-help { color: var(--muted); font-size: 11.5px; font-family: var(--mono); margin-top: 8px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-kicker { display: flex; align-items: center; gap: 7px; color: var(--accent); font-family: var(--mono); font-weight: 700; font-size: 12.5px; }
.section-title { font-family: var(--mono); font-size: 21px; font-weight: 800; margin: 6px 0 4px; }
.section-desc { color: var(--muted); font-family: var(--mono); font-size: 12.5px; }
.bottom-line {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px;
  font-family: var(--mono); font-size: 12.5px; margin: 10px 0;
}
.bottom-line b:first-child { color: var(--muted); margin-right: 6px; }
.updated { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px) { .g2, .g3, .g4, .g5 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--border-2);
  background: var(--panel-2); color: var(--text); cursor: pointer; font-weight: 600; font-size: 13px;
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); background: var(--panel-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent-soft); border-color: rgba(34,211,238,.5); color: var(--accent); }
.btn.primary:hover { background: rgba(34,211,238,.2); }
.btn.white { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 800; letter-spacing: .06em; }
.btn.white:hover { opacity: .9; }
.btn.green { background: var(--green-soft); border-color: rgba(31,224,138,.45); color: var(--green); }
.btn.red { background: var(--red-soft); border-color: rgba(244,63,94,.45); color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.xs { height: 24px; padding: 0 8px; font-size: 11px; border-radius: 6px; }
.btn.block { width: 100%; }
.btn.loading { pointer-events: none; opacity: .7; }
.btn.loading::before { content: ""; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); cursor: pointer;
  font-size: 12.5px; color: var(--text-2); font-family: var(--mono); user-select: none;
}
.chip:hover { color: var(--text); border-color: var(--border-2); }
.chip.active { color: var(--text); background: var(--panel-3); border-color: var(--muted); font-weight: 700; }
.chip.active.accent { color: var(--accent); background: var(--accent-soft); border-color: rgba(34,211,238,.5); }
.chip.active.purple { color: var(--purple); background: var(--purple-soft); border-color: rgba(167,139,250,.5); }
.chip.active.red { color: var(--red); background: var(--red-soft); border-color: rgba(244,63,94,.5); }
.chip.active.green { color: var(--green); background: var(--green-soft); border-color: rgba(31,224,138,.5); }
.chip.active.amber { color: var(--amber); background: var(--amber-soft); border-color: rgba(245,183,59,.5); }
.chip .n { color: var(--muted); font-weight: 400; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 700; font-family: var(--mono); letter-spacing: .03em;
  background: var(--panel-3); color: var(--text-2); border: 1px solid var(--border);
}
.tag.green { background: var(--green-soft); color: var(--green); border-color: rgba(31,224,138,.3); }
.tag.red { background: var(--red-soft); color: var(--red); border-color: rgba(244,63,94,.3); }
.tag.amber { background: var(--amber-soft); color: var(--amber); border-color: rgba(245,183,59,.3); }
.tag.accent { background: var(--accent-soft); color: var(--accent); border-color: rgba(34,211,238,.3); }
.tag.purple { background: var(--purple-soft); color: var(--purple); border-color: rgba(167,139,250,.3); }
.tag.outline { background: transparent; }

.input, .select, .textarea {
  height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); outline: none; width: 100%;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.label { font-size: 11px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; font-weight: 700; margin-bottom: 6px; display: block; }
.field { margin-bottom: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.switch { position: relative; width: 38px; height: 21px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-2); border-radius: 20px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent-2); }
.switch input:checked + span::before { transform: translateX(17px); }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); font-family: var(--mono); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-family: var(--mono); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--panel-2); }
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text); }
.table .r { text-align: right; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }

/* stat */
.stat .k { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.stat .v { font-size: 22px; font-weight: 700; font-family: var(--mono); margin: 4px 0 2px; }
.stat .d { font-size: 11.5px; font-family: var(--mono); color: var(--muted); }
.stat-box { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }

/* bars */
.bar { height: 6px; background: var(--panel-3); border-radius: 6px; overflow: hidden; position: relative; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: var(--accent); transition: width .5s; }
.bar.thin { height: 4px; }
.bar.gauge-grad { background: linear-gradient(90deg, rgba(31,224,138,.25), rgba(245,183,59,.2), rgba(244,63,94,.25)); }
.bar .knob { position: absolute; top: -3px; width: 3px; height: 12px; background: #fff; border-radius: 2px; }

/* spinner / empty */
.spinner { width: 34px; height: 34px; border: 3px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto; }
.loading-box { display: grid; place-items: center; gap: 12px; padding: 40px; color: var(--muted); font-size: 12px; letter-spacing: .15em; text-transform: uppercase; font-weight: 700; min-height: 160px; }
.empty { text-align: center; color: var(--muted); padding: 30px; font-family: var(--mono); font-size: 12.5px; }
.err-box { background: var(--red-soft); border: 1px solid rgba(244,63,94,.3); color: var(--text-2); padding: 10px 12px; border-radius: 9px; font-size: 12px; font-family: var(--mono); }
.note-box { background: var(--amber-soft); border: 1px solid rgba(245,183,59,.3); color: var(--text-2); padding: 10px 12px; border-radius: 9px; font-size: 12px; font-family: var(--mono); }
.src-badge { font-size: 10px; font-family: var(--mono); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-2); color: var(--muted); }
.src-badge.live { color: var(--green); border-color: rgba(31,224,138,.35); }
.src-badge.cache { color: var(--amber); border-color: rgba(245,183,59,.35); }
.src-badge.model { color: var(--purple); border-color: rgba(167,139,250,.35); }

/* dropdown */
.dd { position: relative; }
.dd-menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 200px; z-index: 60;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px; max-height: 380px; overflow: auto; animation: slideIn .15s;
}
.dd-menu.right { left: auto; right: 0; }
.dd-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.dd-item:hover { background: var(--panel-3); color: var(--text); }
.dd-item .box { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--c, var(--border-2)); display: grid; place-items: center; flex-shrink: 0; }
.dd-item.on .box { background: var(--c, var(--accent)); }
.dd-item.on .box::after { content: "✓"; color: #07111a; font-size: 11px; font-weight: 900; }
.dd-item.on { color: var(--text); }
.dd-seg { display: flex; border-bottom: 1px solid var(--border); margin: -6px -6px 6px; }
.dd-seg button { flex: 1; background: none; border: none; padding: 10px; cursor: pointer; font-weight: 700; color: var(--muted); }
.dd-seg button:first-child { color: var(--text); }
.dd-seg button:hover { color: var(--accent); }
.dd-group { font-size: 10px; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); padding: 8px 10px 4px; font-weight: 700; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(3,6,10,.65); backdrop-filter: blur(5px); z-index: 80; display: grid; place-items: center; padding: 20px; animation: fadeIn .15s; }
.modal { width: min(560px, 100%); max-height: 88vh; overflow: auto; background: var(--panel); border: 1px solid var(--border-2); border-radius: 16px; box-shadow: var(--shadow); animation: slideIn .2s; }
.modal.wide { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--border); }
.x-btn { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; }
.x-btn:hover { color: var(--text); }

/* toast */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 380px; }
.toast { background: var(--panel); border: 1px solid var(--border-2); border-left: 3px solid var(--accent); border-radius: 10px; padding: 11px 14px; box-shadow: var(--shadow); animation: slideIn .2s; font-size: 13px; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
.toast b { display: block; margin-bottom: 2px; }

/* command palette */
.cmdk { width: min(620px, 100%); background: var(--panel); border: 1px solid var(--border-2); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; align-self: start; margin-top: 10vh; }
.cmdk input { width: 100%; height: 52px; padding: 0 18px; border: none; border-bottom: 1px solid var(--border); background: transparent; outline: none; font-size: 16px; }
.cmdk-list { max-height: 420px; overflow: auto; padding: 6px; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; cursor: pointer; }
.cmdk-item .ic { width: 28px; height: 28px; border-radius: 7px; background: var(--panel-3); display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--accent); }
.cmdk-item .meta { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.cmdk-item.sel, .cmdk-item:hover { background: var(--panel-3); }

/* gauge */
.gauge { position: relative; width: 150px; height: 84px; }
.gauge svg { width: 100%; height: 100%; overflow: visible; }

/* segmented */
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: none; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 700; font-size: 12.5px; font-family: var(--mono); }
.seg button.active { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 0 var(--border-2) inset; }
.seg button:hover { color: var(--text); }

/* lock / pro badge */
.pro-badge { font-size: 9.5px; font-weight: 800; letter-spacing: .1em; color: #07111a; background: linear-gradient(90deg, var(--accent), var(--purple)); padding: 2px 6px; border-radius: 5px; }

/* sparkline */
.spark { width: 100%; height: 34px; display: block; }
.kv { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-family: var(--mono); font-size: 12.5px; }
.kv:last-child { border-bottom: none; }
.kv span:first-child { color: var(--muted); }
.list-plain { margin: 0; padding-left: 16px; }
.list-plain li { margin: 4px 0; }
.tooltip-i { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--border-2); font-size: 10px; color: var(--muted); cursor: help; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-2); border-radius: 4px; color: var(--muted); }

/* ---------- guided tour ---------- */
.tour-ov { position: fixed; inset: 0; z-index: 9000; }
.tour-hole { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(3, 8, 15, .72), 0 0 0 2px var(--accent), 0 0 24px rgba(34, 211, 238, .45); transition: all .25s ease; pointer-events: none; }
.tour-card { position: fixed; background: var(--panel); border: 1px solid var(--border-2); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); transition: top .25s, left .25s; animation: slideIn .25s; }
.tour-t { display: block; font-size: 16px; margin: 4px 0 6px; }
.tour-langs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.tour-langs .btn { min-width: 110px; }
/* locked page preview */
.lock-preview { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: center; text-align: left; margin-top: 14px; }
.lp-shot { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border-2); box-shadow: var(--shadow); }
.lp-shot img { display: block; width: 100%; height: auto; filter: saturate(1.05); }
.lp-tag { position: absolute; top: 8px; left: 8px; font: 800 10px var(--mono); letter-spacing: .08em; background: rgba(0, 0, 0, .6); color: #fff; padding: 3px 8px; border-radius: 6px; }
.lp-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.lp-list li { display: flex; gap: 8px; font-size: 14px; color: var(--text-2); } .lp-list li::before { content: "✓"; color: var(--green); font-weight: 800; }
@media (max-width: 760px) { .lock-preview { grid-template-columns: 1fr; } }
.amber { color: var(--amber); }
