:root{
    --kepler-pl-w: 300px;
    --kepler-pr-w: 320px;
    --kepler-stage-ml: 300px;
    --kepler-stage-mr: 320px;

    /* Dark stage */
    --bg0:#11121a;
    --bg1:#171a26;
  
    /* Panel palettes (diferit de pendul) */
    --leftA:#28c7c1;
    --leftB:#1a8fbe;
  
    --rightA:#ffb347;
    --rightB:#ff5f8a;
  
    --card:#fff2d8;
    --card2:#ffe3b0;
  
    --violet:#6a5cff;
  
    --ink:#13141a;
    --shadow: 0 12px 34px rgba(0,0,0,.28);
    --radius: 18px;
  }
  
  *{box-sizing:border-box}
  html,body{height:100%}
  body{
    margin:0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
    background: linear-gradient(180deg, #0c0d12, #090a0f);
    color:#f3f3f3;
    overflow:hidden;
  }
  
  .app{
    position:relative;
    height:100vh;
    height:100dvh;
    min-height:0;
  }

  /* Panouri fixe stânga/dreapta (ca la oscilatorul simplu); simulatorul e centrat cu margini */
  .panel{
    position:fixed;
    top:0;
    bottom:0;
    height:100vh;
    height:100dvh;
    overflow-y:auto;
    overflow-x:hidden;
    padding:12px;
    min-height:0;
    z-index:150;
    transition:transform 0.28s ease;
    -webkit-overflow-scrolling:touch;
  }
  .panel.right .controls{
    padding-bottom:20px;
  }

  .panel.left{
    left:0;
    width:var(--kepler-pl-w);
    transform:translateX(0);
    background: linear-gradient(180deg, rgba(40,199,193,.92), rgba(26,143,190,.78));
    border-right: 2px solid rgba(255,255,255,.22);
    box-shadow: 8px 0 28px rgba(0,0,0,.28);
  }

  .panel.right{
    right:0;
    width:var(--kepler-pr-w);
    transform:translateX(0);
    background: linear-gradient(180deg, rgba(255,179,71,.92), rgba(255,95,138,.74));
    border-left: 2px solid rgba(255,255,255,.22);
    box-shadow: -8px 0 28px rgba(0,0,0,.28);
  }

  .panel.left.hidden{
    transform:translateX(-100%);
    pointer-events:none;
  }
  .panel.right.hidden{
    transform:translateX(100%);
    pointer-events:none;
  }

  .kepler-toggle{
    position:fixed;
    z-index:210;
    top:max(10px, env(safe-area-inset-top, 0px));
    width:44px;
    height:44px;
    padding:0;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:10px;
    border:2px solid rgba(255,255,255,.4);
    cursor:pointer;
    font-size:20px;
    line-height:1;
    font-weight:800;
    box-shadow:0 4px 18px rgba(0,0,0,.35);
    transition:left 0.28s ease, right 0.28s ease, transform 0.15s ease;
  }
  .kepler-toggle:hover{ transform:translateY(-1px); }
  .kepler-toggle-left{
    background:linear-gradient(180deg, rgba(40,199,193,.95), rgba(26,143,190,.88));
    color:#111;
  }
  .kepler-toggle-right{
    background:linear-gradient(180deg, rgba(255,179,71,.95), rgba(255,95,138,.82));
    color:#111;
  }
  
  .panelHeader{
    border-radius: var(--radius);
    padding:12px 14px;
    color:#111;
    box-shadow: var(--shadow);
    border: 2px solid rgba(255,255,255,.35);
    margin-bottom:10px;
    background: rgba(255,255,255,.45);
  }
  .leftHdr{ background: rgba(255,255,255,.55); }
  .rightHdr{ background: rgba(255,255,255,.55); }
  
  .panelHeader h2{margin:0 0 4px 0}
  .small{font-size:12.5px; line-height:1.35}
  .muted{opacity:.78}
  
  .card{
    background: rgba(255,242,216,.92);
    color:#111;
    border-radius: var(--radius);
    padding:12px 14px;
    margin-bottom:10px;
    box-shadow: var(--shadow);
    border: 2px solid rgba(255,255,255,.35);
  }
  .card.violet{
    background: linear-gradient(145deg, rgba(106,92,255,.92), rgba(88,72,220,.88));
    color:#f5f5ff;
    box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,.12);
  }
  .card.violet .mjx-math,
  .card.violet .MathJax,
  .card.violet [class^="mjx-"]{ color: inherit !important; }
  .card.mini{ padding:10px 12px; margin-bottom:8px; }
  .card.mini h3{ margin-bottom:8px; font-size:14px; }

  /* MathJax in cards */
  .formulaCard .mjx-math{ font-size: 110%; }
  .formulaCard .mjx-math mjx-container[jax="CHTML"]{ overflow-x: auto; overflow-y: hidden; }
  .formulaInline .mjx-math{ font-size: 100%; }
  
  .card h3{margin:0 0 10px 0}
  .list{margin:0; padding-left:18px}
  .list li{margin:6px 0}
  
  .formula{
    font-size:13px;
    line-height:1.6;
  }
  .formula hr{
    border:none;
    border-top:1px solid rgba(255,255,255,.35);
    margin:8px 0;
  }
  .formula .sp{ height: 6px; }
  .formula b{ font-weight: 900; }
  

  /* Scrollbar pentru panouri */
  .panel::-webkit-scrollbar{ width: 8px; }
  .panel::-webkit-scrollbar-track{ background: rgba(0,0,0,.12); border-radius: 4px; }
  .panel::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.35); border-radius: 4px; }
  .panel::-webkit-scrollbar-thumb:hover{ background: rgba(255,255,255,.5); }
  
  .stage{
    margin-left:var(--kepler-stage-ml);
    margin-right:var(--kepler-stage-mr);
    height:100vh;
    height:100dvh;
    transition:margin-left 0.28s ease, margin-right 0.28s ease;
    background: radial-gradient(1100px 700px at 50% 25%, rgba(120,130,255,.18), transparent 60%),
                linear-gradient(180deg, var(--bg1), var(--bg0));
    display:flex;
    flex-direction:column;
    min-height:0;
    padding:10px 14px 10px 14px;
    position:relative;
    box-sizing:border-box;
  }
  
  .stageTop{
    display:flex;
    justify-content:space-between;
    align-items:flex-end;
    gap:14px;
    padding:6px 4px 10px 4px;
    flex-wrap:wrap;
  }
  .stageTop h1{
    margin:0;
    font-size:clamp(1.15rem, 3.5vw, 34px);
    letter-spacing:.4px;
    text-shadow: 0 6px 18px rgba(0,0,0,.35);
  }
  
  .toggles{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
    justify-content:flex-end;
  }
  .toggle{
    display:flex;
    align-items:center;
    gap:8px;
    padding:10px 12px;
    border-radius: 999px;
    border:1px solid rgba(255,255,255,.25);
    background: rgba(255,255,255,.10);
    color:#fff;
    cursor:pointer;
    font-weight:800;
    user-select:none;
  }
  .toggle input{ accent-color: #ffd24a; }
  
  .canvasWrap{
    position:relative;
    flex:1;
    min-height:280px;
    border-radius: 20px;
    overflow:hidden;
    border:2px solid rgba(255,255,255,.18);
    box-shadow: 0 14px 40px rgba(0,0,0,.35);
  }
  #scene{
    width:100%;
    height:100%;
    display:block;
    background:
      radial-gradient(900px 460px at 50% 40%, rgba(255,255,255,.06), transparent 70%),
      linear-gradient(180deg, rgba(0,0,0,.16), rgba(0,0,0,.38));
  }
  
  .hint{
    position:absolute;
    right:14px;
    bottom:12px;
    background: rgba(0,0,0,.46);
    border:1px solid rgba(255,255,255,.16);
    color: rgba(255,255,255,.92);
    padding:10px 12px;
    border-radius: 14px;
    font-size:13px;
    backdrop-filter: blur(8px);
  }
  
  .stageBottom{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    padding:8px 4px 0 4px;
    flex-shrink:0;
  }
  .badge{
    background: rgba(255,242,216,.92);
    color:#111;
    border-radius: 999px;
    padding:8px 12px;
    font-weight:900;
    border:1px solid rgba(255,255,255,.25);
  }
  .readouts{
    display:flex;
    gap:14px;
    flex-wrap:wrap;
    justify-content:flex-end;
    font-size:13px;
    opacity:.95;
  }
  .k{opacity:.7}
  
  /* Right controls */
  .row{
    background: rgba(255,242,216,.88);
    color:#111;
    border-radius: 14px;
    padding:10px 12px;
    margin-bottom:8px;
    border:2px solid rgba(255,255,255,.35);
    box-shadow: var(--shadow);
  }
  .row label{
    display:block;
    font-weight:900;
    margin-bottom:4px;
    font-size:13px;
  }
  .inline{
    display:flex;
    align-items:center;
    gap:10px;
  }
  .pill{
    background: rgba(0,0,0,.10);
    border:1px solid rgba(0,0,0,.20);
    border-radius: 999px;
    padding:6px 10px;
    font-weight:900;
    min-width:72px;
    text-align:center;
  }
  input[type="range"]{ width:100%; }
  
  .btnStack{
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap:8px;
    margin: 6px 0 8px 0;
  }
  .btn{
    padding:10px 12px;
    border-radius: 14px;
    border:2px solid rgba(255,255,255,.45);
    background: rgba(255,242,216,.92);
    cursor:pointer;
    font-weight:900;
    font-size:13px;
    box-shadow: var(--shadow);
  }
  .btn:hover{ filter: brightness(1.03); }
  .btn.danger{
    background: rgba(255,95,138,.92);
    color:#111;
  }
  .btn.accent{
    background: linear-gradient(90deg, rgba(40,199,193,.95), rgba(255,179,71,.95));
  }
  
  .btnGrid{
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap:6px;
    margin-top:6px;
  }
  .btn.ghost{
    background: rgba(255,255,255,.60);
    border:1px solid rgba(0,0,0,.18);
    box-shadow:none;
    border-radius: 12px;
    padding:8px;
    font-size:12px;
  }
  
  #law3Plot{
    width:100%;
    height:140px;
    max-height:140px;
    border-radius: 12px;
    border:1px solid rgba(0,0,0,.18);
    background: rgba(0,0,0,.06);
  }

  .log{
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    line-height: 1.4;
    background: rgba(0,0,0,.06);
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 10px;
    padding:8px;
    min-height: 52px;
    max-height: 72px;
    overflow-y: auto;
  }
  
  @media (max-width: 1024px){
    :root{
      --kepler-pl-w: min(86vw, 320px);
      --kepler-pr-w: min(86vw, 320px);
    }
  }

  @media (prefers-reduced-motion: reduce){
    .panel,
    .stage,
    .kepler-toggle{ transition:none; }
  }
   
