/* PartWays design tokens and components. Plain CSS, light and dark. */
:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #fcfcfb;
  --panel: #ffffff;
  --panel-2: #f2f1ee;
  --line: #e4e2dc;
  --line-strong: #cfccc4;
  --ink: #17161c;
  --ink-2: #47454f;
  --muted: #6b6975;
  --accent: #3f3a8c;
  --accent-ink: #ffffff;
  --accent-soft: #ecebf7;
  --brand: #0f766e;
  --focus: #2a78d6;
  --good: #0a7a0a;
  --good-soft: #e5f4e5;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
  --bad: #b42323;
  --bad-soft: #fbe9e9;
  --info-soft: #e8f0fb;
  --demo: #9a3412;
  --demo-soft: #fff1e6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-pos: #2a78d6;
  --series-neg: #e34948;
  --series-mixed: #6250d6;
  --series-neutral: #b5b3ad;
  --track: #ecebe7;
  --shadow: 0 1px 2px rgba(20, 18, 30, .06), 0 4px 16px rgba(20, 18, 30, .05);
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text-scale: 1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121215; --surface: #1a1a19; --panel: #1f1f23; --panel-2: #26262b; --line: #34343a; --line-strong: #46464e;
    --ink: #f0efec; --ink-2: #d2d0cb; --muted: #a3a19b; --accent: #9d97f0; --accent-ink: #121215; --accent-soft: #2a2850;
    --focus: #6da7ec; --good: #5fc95f; --good-soft: #1c2e1c; --warn: #f0c060; --warn-soft: #33290f; --bad: #f08080; --bad-soft: #3a1d1d;
    --info-soft: #1c2738; --demo: #f6a26b; --demo-soft: #36231a;
    --series-1: #3987e5; --series-2: #d95926; --series-pos: #3987e5; --series-neg: #e66767; --series-mixed: #9085e9; --series-neutral: #5f5e59; --track: #2c2c31;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121215; --surface: #1a1a19; --panel: #1f1f23; --panel-2: #26262b; --line: #34343a; --line-strong: #46464e;
  --ink: #f0efec; --ink-2: #d2d0cb; --muted: #a3a19b; --accent: #9d97f0; --accent-ink: #121215; --accent-soft: #2a2850;
  --focus: #6da7ec; --good: #5fc95f; --good-soft: #1c2e1c; --warn: #f0c060; --warn-soft: #33290f; --bad: #f08080; --bad-soft: #3a1d1d;
  --info-soft: #1c2738; --demo: #f6a26b; --demo-soft: #36231a;
  --series-1: #3987e5; --series-2: #d95926; --series-pos: #3987e5; --series-neg: #e66767; --series-mixed: #9085e9; --series-neutral: #5f5e59; --track: #2c2c31;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(16px * var(--text-scale)); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.5; font-feature-settings: "cv11", "ss01"; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); text-underline-offset: 2px; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; padding: .5rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); font: inherit; font-weight: 550; font-size: .95rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { min-height: 32px; padding: .25rem .65rem; font-size: .85rem; }
.btn.lg { min-height: 48px; padding: .75rem 1.4rem; font-size: 1rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.ico { width: 1.2em; height: 1.2em; flex: none; vertical-align: -0.2em; }
.btn .ico { width: 1.1em; height: 1.1em; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* Forms */
label { font-weight: 550; font-size: .9rem; }
.field { display: grid; gap: .3rem; margin-bottom: .9rem; }
.field .hint { font-size: .82rem; color: var(--muted); font-weight: 400; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: .55rem .7rem; width: 100%; min-height: 40px; }
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 450; }
.check input { margin-top: .25rem; width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.otp { letter-spacing: .5em; font-size: 1.4rem; text-align: center; font-variant-numeric: tabular-nums; max-width: 14rem; }

/* Layout */
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: .75rem; }
.grid { display: grid; gap: 1rem; }
.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)); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.spacer { flex: 1; }

/* Surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin-bottom: .35rem; }
.card.flat { box-shadow: none; }
.card.soft { background: var(--panel-2); box-shadow: none; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* Badges and notices */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.demo { background: var(--demo-soft); color: var(--demo); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--ink-2); border-color: transparent; }
.notice { border-radius: var(--radius-sm); padding: .7rem .9rem; background: var(--info-soft); color: var(--ink); font-size: .92rem; display: flex; gap: .6rem; align-items: flex-start; }
.notice.warn { background: var(--warn-soft); }
.notice.bad { background: var(--bad-soft); }
.notice.good { background: var(--good-soft); }
.notice.demo { background: var(--demo-soft); }
.notice .ico { flex: none; margin-top: .15rem; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--ink-2); background: var(--panel-2); font-size: .82rem; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs button, .tabs a { background: none; border: 0; border-bottom: 2px solid transparent; padding: .6rem .8rem; font: inherit; font-weight: 550; color: var(--muted); cursor: pointer; text-decoration: none; white-space: nowrap; }
.tabs [aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

/* Modal */
dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: min(640px, calc(100vw - 32px)); width: 100%; background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20, 18, 30, .45); }
dialog .dlg-head { padding: 1rem 1.2rem .4rem; }
dialog .dlg-body { padding: .4rem 1.2rem 1rem; max-height: 70vh; overflow: auto; }
dialog .dlg-foot { padding: .8rem 1.2rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
dialog.wide { max-width: min(900px, calc(100vw - 32px)); }

/* Toast */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 1000; width: min(520px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: .7rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: .92rem; display: flex; gap: .6rem; align-items: center; }
.toast.bad { background: var(--bad); color: #fff; }

/* Loading */
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--panel-2), var(--line), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; min-height: 1rem; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty h3 { color: var(--ink); }

/* Charts (HTML bars) */
.chart { display: grid; gap: .5rem; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 34%) 1fr auto; gap: .6rem; align-items: center; font-size: .88rem; position: relative; }
.bar-row .lbl { color: var(--ink); overflow-wrap: anywhere; }
.bar-row .val { color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 6.5rem; text-align: right; font-size: .84rem; }
.bar-track { height: 14px; background: var(--track); border-radius: 0 4px 4px 0; position: relative; }
.bar { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar.s2 { background: var(--series-2); }
.bar-pair { display: grid; gap: 2px; }
.bar-pair .bar-track { height: 10px; }
.stackbar { display: flex; height: 14px; gap: 2px; border-radius: 0 4px 4px 0; overflow: hidden; background: var(--track); }
.stackbar > span { display: block; height: 100%; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); }
.legend .key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--bg); padding: .4rem .6rem; border-radius: 6px; font-size: .8rem; z-index: 2000; max-width: 280px; box-shadow: var(--shadow); }
.unavailable { border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: .9rem; color: var(--ink-2); font-size: .9rem; background: var(--panel-2); }

/* Brand header pieces */
.pw-mark { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.pw-mark .dot { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-grid; place-items: center; color: var(--accent-ink); font-size: .8rem; }
.org-chip { display: inline-flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--ink-2); }
.org-chip .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--brand); }

.quote { border-left: 3px solid var(--line-strong); padding: .1rem 0 .1rem .8rem; margin: .4rem 0; }
.quote .kind { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kbd { font-family: ui-monospace, monospace; font-size: .8rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 .3rem; }

/* Segmented controls and chips */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--panel); padding: .55rem .9rem; font: inherit; cursor: pointer; color: var(--ink); min-height: 40px; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 999px; padding: .35rem .8rem; font: inherit; font-size: .88rem; cursor: pointer; color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

[tabindex="-1"]:focus { outline: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em; }
.update-bar { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1100; width: min(640px, calc(100vw - 32px)); display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; background: var(--ink); color: var(--bg); padding: .65rem .8rem .65rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow); font-size: .92rem; }
.update-bar > span { flex: 1 1 220px; }
.update-bar .muted-on-ink { opacity: .75; }
.update-bar .btn.ghost { color: var(--bg); }
[hidden] { display: none !important; }
