    :root{
      --bg:#0f0f10; --fg:#e8e8ea; --muted:#a9adb7; --card:#15161a; --border:#2b2f36; --accent:#4c8df6; --good:#42b883; --danger:#e66; --warn:#f4b400; --header-h:54px;
    }
    *{box-sizing:border-box}
    html,body{height:100%}
    body{margin:0;background:var(--bg);color:var(--fg);font:14px/1.4 system-ui,-apple-system,Segoe UI,Roboto,Inter,Arial,sans-serif;display:flex;flex-direction:column;overflow:hidden}
    header{display:flex;gap:8px;align-items:center;padding:10px;border-bottom:1px solid var(--border);position:sticky;top:0;background:var(--bg);z-index:5}
    input,select,button{background:var(--card);color:var(--fg);border:1px solid var(--border);border-radius:8px;padding:8px 10px;outline:none}
    button{cursor:pointer}
    button.primary{background:rgba(76,141,246,.16);border-color:rgba(76,141,246,.45)}
    button.primary:hover{background:rgba(76,141,246,.24)}
    .pill{padding:2px 8px;border:1px solid var(--border);border-radius:999px;font-size:12px}
    .hint{font-size:12px;color:var(--muted)}
    .hr{height:1px;background:var(--border);margin:8px 0}

    #wrap{--side-w:320px;height:calc(100dvh - var(--header-h));display:grid;grid-template-columns:var(--side-w) 1fr;min-height:0}
    #side{position:relative;border-right:1px solid var(--border);padding:12px;display:flex;flex-direction:column;gap:10px;width:var(--side-w);overflow:auto}
    .panel{background:var(--card);border:1px solid var(--border);border-radius:12px;padding:10px}

    #main{display:flex;flex-direction:column;min-height:0}
    #main-header{flex:0 0 auto;position:sticky;top:0;z-index:1;background:var(--bg);border-bottom:1px solid var(--border);padding:12px}
    #main-scroll{flex:1 1 auto;overflow:auto;padding:12px}

    .toolrow{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:10px}

    /* Spinner */
    #loading{position:fixed;left:0;right:0;top:var(--header-h);bottom:0;display:none;align-items:center;justify-content:center;background:rgba(15,15,16,.45);z-index:6}
    #loading .spinner{width:22px;height:22px;border-radius:50%;border:2px solid var(--border);border-top-color:var(--fg);animation:spin .8s linear infinite}
    @keyframes spin{to{transform:rotate(360deg)}}
    body[data-loading="true"] #loading{display:flex}

    /* Cards */
    .grid{display:grid;gap:12px}
    .grid.cols-2{grid-template-columns:1.2fr .8fr}
    .grid.cols-3{grid-template-columns:repeat(3,1fr)}
    @media (max-width:1000px){.grid.cols-2,.grid.cols-3{grid-template-columns:1fr}}

    .card{background:var(--card);border:1px solid var(--border);border-radius:14px;padding:12px}
    .card h3{margin:0 0 6px 0;font-size:16px}

    /* Gauge */
    .gauge-wrap{display:flex;align-items:center;gap:16px}
    .gauge{--p:0;--size:130px;--track:#222831;--fill:var(--warn);width:var(--size);height:var(--size);border-radius:50%;background:conic-gradient(var(--fill) calc(var(--p)*1%), var(--track) 0)}
    .gauge::after{content:"";display:block;width:calc(var(--size) - 20px);height:calc(var(--size) - 20px);background:var(--card);border-radius:50%;margin:10px}
    .gauge-num{position:relative;left:-calc(var(--size) + 8px);font-size:26px;min-width:64px;text-align:center}
    .gauge-num small{display:block;font-size:11px;color:var(--muted)}

    /* Milestone ladder */
    .ladder{position:relative;margin-top:8px}
    .ladder .bar{height:14px;border-radius:999px;background:#1b1f27;border:1px solid var(--border);position:relative;overflow:hidden}
    .ladder .fill{position:absolute;left:0;top:0;bottom:0;width:0;background:linear-gradient(90deg,var(--warn),#ffd166)}
    .ladder .labels{display:flex;justify-content:space-between;margin-top:6px;font-size:12px;color:#cfcfcf}

    /* Stars */
    .level-stars{display:inline-flex;gap:2px;align-items:center}
    .level-stars .s{opacity:.28}
    .level-stars .s.on{opacity:1;color:var(--warn)}

    /* Small list */
    .kv{display:grid;grid-template-columns:auto 1fr;gap:4px 10px;font-size:13px}
    .kv .k{color:var(--muted)}

    /* All-languages grid */
    .lang-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
    @media (max-width:1100px){.lang-grid{grid-template-columns:repeat(2,1fr)}}
    @media (max-width:700px){.lang-grid{grid-template-columns:1fr}}
    .lang-item{background:var(--card);border:1px solid var(--border);border-radius:12px;padding:10px}
    .lang-item h4{margin:0 0 6px 0}
    .bar-sm{height:8px;border-radius:999px;background:#1b1f27;border:1px solid var(--border);position:relative;overflow:hidden}
    .bar-sm .fill{position:absolute;left:0;top:0;bottom:0;width:0;background:linear-gradient(90deg,var(--accent),#8fb7ff)}
    .bar-sm .fill2{position:absolute;left:0;top:0;bottom:0;width:0;background:rgba(143,183,255,.35)}

    /* Potential stack (known vs backlog within current stage) */
    .stack{height:12px;border-radius:999px;border:1px solid var(--border);background:#1b1f27;display:flex;overflow:hidden}
    .stack .seg{height:100%}
    .stack .seg.known{background:linear-gradient(90deg,var(--good),#6dd6a9)}
    .stack .seg.backlog{background:linear-gradient(90deg,var(--accent),#8fb7ff)}

    /* Controls sizing */
    input,select{font-size:14px;line-height:1.2;height:34px;padding:6px 10px}
    button{font-size:14px;line-height:1.2;padding:6px 10px}

    /* Mobile sidebar */
    @media (max-width:900px){
      #wrap{grid-template-columns:1fr}
      #side{position:fixed;left:0;top:var(--header-h);bottom:0;width:min(86vw,360px);transform:translateX(-100%);transition:transform .2s ease;box-shadow:0 10px 24px rgba(0,0,0,.4);z-index:6}
      body.sidebar-open #side{transform:translateX(0)}
      #backdrop{position:fixed;inset:var(--header-h) 0 0 0;background:rgba(0,0,0,.4);opacity:0;pointer-events:none;transition:opacity .2s ease;z-index:5}
      body.sidebar-open #backdrop{opacity:1;pointer-events:auto}
      #open-side{display:inline-flex !important;align-items:center;justify-content:center;width:28px;height:28px;margin-right:6px;border-radius:999px;background:var(--card);border:1px solid var(--border)}
    }
    @media (min-width:901px){#open-side{display:none !important}}

    /* Icon button */
    .iconbtn{width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--border);border-radius:8px;background:var(--card);color:var(--fg);padding:0}
    .iconbtn svg{width:16px;height:16px}

    .muted{color:var(--muted)}

    /* Main header toggle: hide on mobile to avoid duplicate with #open-side */
    @media (max-width:900px){ #btnSideToggleMain{ display:none } }

    /* Top bar inside sidebar with right-aligned toggle */
    #sideTopBar{
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 8px;
    /* subtle bg so the button doesn't scroll under content */
    background: linear-gradient(var(--bg) 85%, transparent);
    }



    @media (min-width:901px){
  /* Collapse to a 40px rail but keep #side present */
  body.sidebar-collapsed #wrap{ grid-template-columns:40px 1fr !important; }
  body.sidebar-collapsed #side{
    display:flex !important;   /* ensure it stays in the grid */
    width:auto !important;     /* override width: var(--side-w) */
    padding:8px 6px;
    border-right:1px solid var(--border);
    overflow:visible;
  }
  body.sidebar-collapsed #sideTopBar{
    justify-content:center;
    background:transparent;
    padding-bottom:0;
  }
  body.sidebar-collapsed #side .panel{ display:none; }
}

/* Desktop: overlay toggle pinned to the sidebar corner */
@media (min-width:901px){
  #side{ position:relative; }

  /* make the bar disappear so it doesn't offset the button */
  #sideTopBar{
    position:static;     /* was sticky */
    height:0;
    padding:0;
    background:transparent;
  }

  /* the actual round button */
  #btnSideToggleMain{
    position:absolute;
    top:18px;
    right:8px;
    width:28px;
    height:28px;
    border-radius:999px;
    background:var(--card);
    border:1px solid var(--border);
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    z-index:7;
  }

  /* minor nudge when collapsed rail is only 40px wide (optional) */
  body.sidebar-collapsed #btnSideToggleMain{
    top:6px;
    right:6px;
  }
}



