/* KD design system v2 (2026-11-20, canvas "KD Essence App Redesign"), on top of kd-ui.css.
   Same brand; raised: 8-point spacing, a clear type scale (title 22/28, heading 18/24, body 16/24, label 14/20),
   18 px panels, 48 px touch targets, secondary text #4B5568, success #15803D, warning #B45309, gold only for earned.
   Loaded by hub/partials/kd-ui right after kd-ui.css (same "New hub look" switch). Dark mode: the kd2 variables
   are redefined under html[data-bs-theme=dark], which kd-ui sets only where dark mode is allowed. */

:root{
  --kd2-page: #F7F8FB;
  --kd2-panel: #FFFFFF;
  --kd2-ink: #0F1729;
  --kd2-muted: #4B5568;
  --kd2-line: #E5E8EF;
  --kd2-fill: #F1F3F7;
  --kd2-good: #15803D;  --kd2-good-bg: #DCFCE7;
  --kd2-warn: #B45309;  --kd2-warn-bg: #FFFBEB;  --kd2-warn-line: #FDE68A;
  --kd2-bad: #DC2626;   --kd2-bad-bg: #FEF2F2;
  --kd2-gold: #F1B24C;  --kd2-gold-bg: #FEF3C7;  --kd2-gold-ink: #78350F;
  --kd2-tint: color-mix(in srgb, var(--hub-accent) 10%, white);
  --kd-muted: var(--kd2-muted);
  --kd-good: var(--kd2-good);
  --kd-r: 18px;
}
html[data-bs-theme=dark]{
  --kd2-page: #0B0F18;
  --kd2-panel: #141A24;
  --kd2-ink: #E7EBF2;
  --kd2-muted: #9EA5B2;
  --kd2-line: #263040;
  --kd2-fill: #1B2230;
  --kd2-good: #4ADE80;  --kd2-good-bg: rgba(74,222,128,.14);
  --kd2-warn: #FBBF24;  --kd2-warn-bg: rgba(251,191,36,.12);  --kd2-warn-line: rgba(251,191,36,.35);
  --kd2-bad: #F87171;   --kd2-bad-bg: rgba(248,113,113,.12);
  --kd2-gold-bg: rgba(241,178,76,.18); --kd2-gold-ink: #F1B24C;
  --kd2-tint: color-mix(in srgb, var(--hub-accent) 22%, #141A24);
}

/* Inside the apps: a plain page (no dot grid) and no page header panel: the app's own title bar already
   names the page, so the page's big title is hidden and only its one-line explanation stays. */
html.kd-app body{ background-image: none !important; }
html.kd-app .page-header:not([data-kd2]):not([data-kd2-x]){
  background: transparent !important; border: 0 !important; padding: 0 0 .75rem !important; margin-bottom: .5rem !important;
}
html.kd-app .page-header .page-title{ display: none !important; }
html.kd-app .page-subtitle{ font-size: 1rem; line-height: 1.5rem; margin-top: 0 !important; color: var(--kd2-muted) !important; }

/* Inside the apps: feel like the app, not a browser: no grey flash on tap, no link preview or text
   selection on long-press of buttons and links, no page bounce/glow past the ends. */
html.kd-app{ -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
html.kd-app a, html.kd-app button, html.kd-app .btn, html.kd-app label, html.kd-app [role=button]{
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* Inside the apps: 48 px touch targets, 14 px corners, heavy labels (the website keeps its denser admin buttons). */
html.kd-app .btn:not(.btn-sm):not(.btn-link){ min-height: 48px; border-radius: 14px !important; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }

/* ---------- v2 components (kd2-*) ---------- */
.kd2-panel{ background: var(--kd2-panel); border: 1px solid var(--kd2-line); border-radius: 18px; padding: 1rem; margin-bottom: 1rem; color: var(--kd2-ink); }
.kd2-panel.kd2-now{ border: 1.5px solid var(--hub-accent); }
.kd2-eyebrow{ font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--kd2-muted); margin: 0; }
.kd2-h2{ font-size: 1.125rem; line-height: 1.5rem; font-weight: 700; margin: 0 0 .5rem; color: var(--kd2-ink); }
.kd2-muted{ color: var(--kd2-muted); font-size: .875rem; line-height: 1.25rem; }
.kd2-mono{ font-family: var(--kd-f-mono); font-variant-numeric: tabular-nums; }

/* subject chips (tabs that jump to a section) */
.kd2-chips{ display: flex; gap: .5rem; overflow-x: auto; padding: 0 0 .25rem; margin: 0 0 1rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.kd2-chips::-webkit-scrollbar{ display: none; }
.kd2-chip{ flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--kd2-line);
  background: var(--kd2-panel); color: var(--kd2-ink) !important; font-weight: 700; font-size: .875rem; text-decoration: none !important; }
.kd2-chip[aria-current=true], .kd2-chip:active{ background: var(--hub-accent); border-color: var(--hub-accent); color: #fff !important; }

/* pills */
.kd2-pill{ display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .65rem; border-radius: 999px; font-size: .75rem; font-weight: 800;
  background: var(--kd2-tint); color: var(--hub-accent); white-space: nowrap; }
.kd2-pill.good{ background: var(--kd2-good-bg); color: var(--kd2-good); }
.kd2-pill.warn{ background: var(--kd2-warn-bg); color: var(--kd2-warn); }
.kd2-pill.bad{ background: var(--kd2-bad-bg); color: var(--kd2-bad); }
.kd2-pill.gold{ background: var(--kd2-gold-bg); color: var(--kd2-gold-ink); }
.kd2-pill.muted{ background: var(--kd2-fill); color: var(--kd2-muted); }

/* unit rows: number, title + note, actions */
.kd2-units{ display: flex; flex-direction: column; }
.kd2-unit{ display: flex; align-items: center; gap: .75rem; padding: .75rem 0; border-top: 1px solid var(--kd2-line); flex-wrap: wrap; }
.kd2-unit:first-child{ border-top: 0; padding-top: .25rem; }
.kd2-num{ flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--kd2-fill); color: var(--kd2-ink); font-family: var(--kd-f-mono); font-weight: 700; font-size: .875rem; }
.kd2-unit-main{ flex: 1 1 160px; min-width: 0; }
.kd2-unit-title{ font-weight: 700; font-size: 1rem; line-height: 1.375rem; color: var(--kd2-ink); }
.kd2-unit-note{ display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-top: .2rem; font-size: .8125rem; color: var(--kd2-muted); }
.kd2-unit-acts{ display: flex; gap: .4rem; flex-wrap: wrap; margin-left: auto; }
.kd2-unit-acts form{ margin: 0; }

/* notices */
.kd2-note{ border-radius: 14px; padding: .85rem 1rem; margin-bottom: 1rem; font-size: 1rem; line-height: 1.5; }
.kd2-note.warn{ background: var(--kd2-warn-bg); border: 1px solid var(--kd2-warn-line); color: var(--kd2-ink); }
.kd2-note.good{ background: var(--kd2-good-bg); color: var(--kd2-ink); }
.kd2-note.bad{ background: var(--kd2-bad-bg); color: var(--kd2-ink); }

/* score ring (mock result) */
.kd2-score{ display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.kd2-ring{ --p: 0; --c: var(--hub-accent); flex: 0 0 auto; width: 132px; height: 132px; border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--kd2-fill) 0); display: grid; place-items: center; }
.kd2-ring > div{ width: 104px; height: 104px; border-radius: 50%; background: var(--kd2-panel); display: grid; place-items: center; text-align: center; }
.kd2-ring b{ font-family: var(--kd-f-mono); font-size: 1.6rem; line-height: 1; font-weight: 700; color: var(--kd2-ink); }
.kd2-ring small{ display: block; font-family: var(--kd-f-mono); font-size: .8rem; color: var(--kd2-muted); margin-top: .2rem; }
.kd2-score-text{ flex: 1 1 180px; min-width: 0; }
.kd2-grade{ font-size: 1.375rem; line-height: 1.75rem; font-weight: 800; margin: .15rem 0 .25rem; }

/* two big actions */
.kd2-actions{ display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 0 0 1rem; }
@media (max-width: 360px){ .kd2-actions{ grid-template-columns: 1fr; } }
.kd2-action{ display: flex; flex-direction: column; gap: .2rem; min-height: 88px; padding: .9rem; border-radius: 18px; border: 1px solid var(--kd2-line);
  background: var(--kd2-panel); color: var(--kd2-ink) !important; text-decoration: none !important; }
.kd2-action b{ font-size: 1rem; }
.kd2-action span{ font-size: .8125rem; color: var(--kd2-muted); }
.kd2-action.primary{ background: var(--hub-accent); border-color: var(--hub-accent); color: #fff !important; }
.kd2-action.primary span{ color: rgba(255,255,255,.85); }

/* plain links that should look like a full-width secondary button */
.kd2-back{ display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 14px; border: 1px solid var(--kd2-line);
  background: var(--kd2-panel); color: var(--kd2-ink) !important; font-weight: 700; text-decoration: none !important; }
