:root {
  --max: 1200px;
  --accent: #2563eb; /* blue-600 */
  --bg: #f7fafc;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --chip: #10b981; /* emerald-500 */
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --card: #0f172a; /* slate-900 */
    --border: #1f2937;
    --text: #e5e7eb;
    --muted: #94a3b8;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
main { max-width: var(--max); margin: 2.5rem auto; padding: 0 1rem; }
h2 { margin: 0 0 .75rem; color: var(--accent); letter-spacing: -0.01em; }
.site-header { position: sticky; top: 0; z-index: 100; display:flex; align-items:flex-end; justify-content: space-between; margin-bottom: 1rem; padding: .5rem 0; background: var(--bg); border-bottom: 1px solid var(--border); -webkit-backdrop-filter: none; backdrop-filter: none; isolation: isolate; }
.site-header::before { content:""; position:absolute; left:0; right:0; top:-6px; height: calc(100% + 6px); background: var(--bg); z-index:-1; }
.site-header-right { display:flex; gap:.5rem; align-items:center; }
.header-link { text-decoration: none; color: var(--muted); }
.header-link:hover { text-decoration: underline; }
.pill-link { display:inline-block; padding: .3rem .6rem; border:1px solid var(--border); border-radius: 999px; color: var(--text); text-decoration:none; background: var(--card); }
.pill-link:hover { box-shadow: 0 4px 10px rgba(0,0,0,.06); }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; margin: .6rem 0; }
.row > * { flex: 1 1 200px; }
input, select { padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 10px; font-size: 1rem; background: var(--card); color: var(--text); }
input::placeholder { color: var(--muted); }
label { display: flex; flex-direction: column; gap: .35rem; font-weight: 700; }
.results { margin-top: .75rem; display: grid; grid-template-columns: repeat(auto-fill,minmax(300px,1fr)); gap: 1.25rem; }
.card { border: 1px solid var(--border); border-radius: 14px; padding: 1rem; background: var(--card); box-shadow: 0 8px 22px rgba(0,0,0,.06); display: flex; flex-direction: column; gap: .55rem; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.card:hover { transform: translateY(-1px); box-shadow: 0 16px 34px rgba(0,0,0,.12); border-color: rgba(37,99,235,.25); }
.muted { color: var(--muted); font-size: .92em; margin: .45rem 0; display: block; }
code.copy { cursor: pointer; user-select: all; display: inline-block; word-break: break-all; border-radius: 8px; }
h2 { margin: 0 0 .75rem; color: var(--accent); letter-spacing: -0.01em; }
h3 { margin: 1.4rem 0 .6rem; }
ol { padding-left: 1.2rem; }
button.secondary { background: #e5e7eb; color: #111827; border-color: #e5e7eb; box-shadow: none; }
\.toolbar { position: sticky; top: 0; backdrop-filter: blur(6px); background: color-mix(in srgb, var(--bg) 88%, transparent); padding: .5rem 0; display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin: 1rem 0 .5rem; z-index: 10; border-bottom: 1px solid var(--border); }
.chip { display: inline-block; font-size: .75rem; padding: .18rem .5rem; border-radius: 999px; background: #e6fbf4; color: var(--chip); border: 1px solid rgba(10,167,119,.25); }
.card .header { display:flex; align-items: flex-start; justify-content: space-between; gap: .5rem; position: static; }
.card .header strong { display:block; font-weight:700; line-height:1.2; word-wrap:anywhere; }
.card .actions { display:flex; gap: .5rem; margin-top: .25rem; }
.btn { padding: .55rem .85rem; border: 1px solid var(--border); border-radius: 10px; font-size: .95rem; background: var(--card); color: var(--text); box-shadow: none; cursor: pointer; transition: transform .06s ease, box-shadow .12s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 16px rgba(0,0,0,.08); }
.btn[disabled] { opacity: .6; cursor: not-allowed; box-shadow: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 6px 16px rgba(37,99,235,.25); }
.btn-primary:hover { box-shadow: 0 10px 20px rgba(37,99,235,.28); }
.btn-ghost { background:transparent; color: var(--muted); border-color: var(--border); box-shadow:none; }
.btn-sm, .btn-small { padding: .3rem .5rem; font-size: .85rem; border-radius: 8px; }
.empty { text-align:center; padding: 1.5rem; color: var(--muted); border: 1px dashed var(--border); border-radius: 12px; }
.spinner { width: 18px; height:18px; border-radius:50%; border: 2px solid #cbd5e1; border-top-color: var(--accent); display:inline-block; animation: spin 1s linear infinite; }
[hidden] { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Ensure multi-column layout even if Tailwind utility CSS isn't applied */
#results { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; align-items: stretch; }
/* New layout + footer + clamps */
.layout { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
.layout.full { grid-template-columns: 1fr; }
.sidebar { position: sticky; top: 66px; display:flex; flex-direction: column; gap: .75rem; border: 1px solid var(--border); background: var(--card); border-radius: 12px; padding: 1rem; overflow: hidden; }
.sidebar.hidden { display: none !important; }
.sidebar .chips { display:flex; gap: .75rem; flex-wrap: wrap; margin-top: .5rem; }
.chip-toggle { display:inline-flex; gap:.4rem; align-items:center; padding:.35rem .6rem; border-radius:999px; border:1px solid var(--border); background: var(--bg); font-size:.9rem; }
.snapshot { margin-top:.5rem; border-top:1px solid var(--border); padding-top:.5rem; }
.growth { margin-top:.75rem; border-top:1px dashed var(--border); padding-top:.5rem; }
.spark { height: 48px; width: 100%; display:block; }
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal-backdrop { position:absolute; inset:0; background: rgba(0,0,0,.4); }
.modal-card { position: relative; background: var(--card); color: var(--text); border:1px solid var(--border); border-radius: 12px; padding: 1rem; width: min(720px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.2); display:flex; flex-direction: column; gap:.5rem; }
.modal-header { display:flex; align-items:center; justify-content: space-between; }
.chart { width: 100%; height: 220px; background: var(--bg); border:1px solid var(--border); border-radius: 10px; }
.chart .grid line { stroke: var(--border); stroke-width: 1; opacity: .5; shape-rendering: crispEdges; }
.chart .axis line { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.status { display:flex; justify-content: space-between; align-items:center; min-height: 24px; }
.footer-bar { position: sticky; bottom: 0; display:flex; justify-content: space-between; gap: .75rem; align-items:center; padding:.75rem 0; backdrop-filter: blur(6px); background: color-mix(in srgb, var(--bg) 92%, transparent); border-top:1px solid var(--border); margin-top: 1rem; box-shadow: 0 -6px 12px rgba(0,0,0,.04); z-index: 20; }
.footer-bar .left { display:flex; gap:.5rem; }
.footer-bar .right { display:flex; gap:.5rem; align-items:center; }
.card { height: 100%; }
.card p { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.sentinel { height: 12px; }

/* Accordion for client setup */
.accordion { max-width: var(--max); margin: 0 auto .25rem; padding: 0 1rem; }
.accordion details { border:1px solid var(--border); background: var(--card); border-radius: 8px; margin: 0 0 .4rem; }
.accordion details[open] { }
.accordion summary { display:block; width:100%; cursor: pointer; padding: .35rem .6rem; list-style: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; line-height: 1.2; }
.accordion summary strong { font-weight: 700; font-size: 13px; }
.accordion summary::-webkit-details-marker { display: none; }
.accordion .accordion-body { padding: .6rem .75rem; font-size: 13px; line-height: 1.4; }
.accordion .accordion-body code { font-size: 12.5px; }
.accordion ol { margin: .25rem 0; padding-left: 1.1rem; }
.accordion li { margin: .12rem 0; }
.accordion code.copy { background: var(--bg); border:1px solid var(--border); padding:.15rem .35rem; border-radius: 6px; }

/* Mobile filter behavior: collapsed by default; opens as overlay */
@media (max-width: 900px) {
  .sidebar { display: none; position: fixed; top: 60px; left: 0; right: 0; bottom: 0; height: auto; max-height: calc(100vh - 60px); overflow: auto; z-index: 90; box-shadow: 0 10px 30px rgba(0,0,0,.2); border-radius: 0; border-left: none; border-right: none; }
  .sidebar.open { display: block; }
  .sidebar-topbar { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; background: var(--card); padding: .4rem .25rem .6rem; margin: -1rem -1rem .5rem; border-bottom: 1px solid var(--border); }
  .sidebar-bottombar { position: sticky; bottom: 0; display: flex; gap: .5rem; background: var(--card); padding: .6rem; margin: .5rem -1rem -1rem; border-top: 1px solid var(--border); }
}

/* Backdrop scrim behind mobile drawer */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 80; display: none; }
.scrim.show { display: block; }

/* Modern selects */
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 8l4 4 4-4' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position: right .7rem center; padding-right: 2rem; }
.select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 2px; }

/* Switch (checkbox) */
.switch { display:inline-flex; align-items:center; gap:.5rem; user-select:none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { position: relative; width: 40px; height: 22px; background: #cbd5e1; border-radius: 999px; transition: background .15s ease; border:1px solid var(--border); }
.switch .slider::after { content:""; position:absolute; top:1px; left:1px; width: 18px; height:18px; background: #fff; border-radius:999px; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s ease; }
.switch input:checked + .slider { background: color-mix(in srgb, var(--accent) 75%, #fff); }
.switch input:checked + .slider::after { transform: translateX(18px); }
.switch .switch-label { font-weight: 600; color: var(--text); font-size: .92rem; }

/* Theme toggle overrides */
:root, [data-theme="light"] {
  --bg: #f7fafc;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
}
[data-theme="dark"] {
  --bg: #0b1220;
  --card: #0f172a;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
}
