/* ============================================================================
   SMITH CHART  ·  stylesheet
   ----------------------------------------------------------------------------
   Dark shell with the cyan of the Light & Fields nav group. The 2D canvas
   fills the frame. The control panel is on the left. The status bar sits at
   the base. Type comes from lib/sci.css, which loads after this file:
   Inter for the controls, STIX Two Text for the title, the system mono for
   numbers only. Labels are sentence case with no letter-spacing.

   SYMBOLS. A field or readout label with data-sym shows its quantity as an
   inline MathJax symbol (equations.js), in the same .m1 to .m6 color as in
   the formulas. grep -n '\.sym' for the sizes.

   PANEL. Each section is a <details class="sec">. A field (.fld) is a label,
   a text input that reads engineering units, and a unit. .tabs is a row of
   exclusive buttons. .chips is a row of small preset buttons.

   PHONE (max-width 768px, or a short landscape touch screen). A dock at the
   base holds the panel button, the three grid modes, and the line walk. In
   portrait the panel is a bottom sheet above the dock. In landscape it is a
   drawer on the right edge. Every control is at least 44px high.
     grep -n 'TOUCH'      target and text sizes for any touch screen
     grep -n 'PHONE'      the phone block
     grep -n 'LANDSCAPE'  the landscape overrides
   ========================================================================== */
:root{
  --bg:#06080c; --bg2:#0c1118; --bg3:#111823; --ink:#e6eef6; --text:#b9c8d6; --dim:#71859a; --faint:#1d2a36;
  --line:rgba(120,200,232,0.10); --line-b:rgba(120,200,232,0.22);
  --z:#50dce8; --y:#e58bd0; --warm:#fca35e; --zin:#9db4ff; --match:#7ee0a0; --bad:#ff6b6b;
  --panel-w:330px;
  --f-sans:var(--sci-sans);
  --f-mono:var(--sci-mono);
  --f-serif:var(--sci-serif);
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html,body{width:100%;height:100%;overflow:hidden;background:var(--bg);overscroll-behavior:none}
body{font-family:var(--f-sans);color:var(--text);-webkit-font-smoothing:antialiased}
button{font-family:inherit;touch-action:manipulation;-webkit-tap-highlight-color:transparent}

.topbar{
  position:fixed;top:0;left:0;right:0;height:52px;z-index:30;display:flex;align-items:center;gap:18px;padding:0 20px;
  background:rgba(6,8,12,0.85);border-bottom:1px solid var(--line);pointer-events:none;
}
.brand{font-size:0.85rem;font-weight:500;color:var(--dim)}
.pagetitle{margin-left:auto;font-family:var(--f-serif);font-size:1.2rem;color:var(--ink)}
html.in-frame .topbar{display:none}

#chart{position:fixed;inset:0;width:100%;height:100%;display:block;touch-action:none;cursor:crosshair}
#dock,#sheetGrip{display:none}
#hint{
  position:fixed;left:50%;bottom:52px;transform:translateX(-50%);z-index:20;transition:opacity 0.6s;
  font:400 0.76rem/1 var(--f-sans);color:var(--dim);pointer-events:none;
}
#hint.gone{opacity:0}
#tip{
  position:fixed;z-index:22;pointer-events:none;display:none;padding:8px 10px;border-radius:9px;
  background:rgba(12,17,24,0.94);border:1px solid var(--line-b);font:400 0.68rem/1.6 var(--f-mono);
  white-space:nowrap;font-variant-numeric:tabular-nums;color:var(--text);box-shadow:0 10px 30px -12px #000;
}
#tip b{font-weight:500;color:var(--ink)}
#tip .cz{color:var(--z)} #tip .cy{color:var(--y)}

#gear{
  position:fixed;top:14px;left:14px;z-index:40;width:40px;height:40px;
  border:1px solid var(--line-b);background:rgba(12,17,24,0.8);color:var(--ink);
  border-radius:10px;font-size:1.05rem;cursor:pointer;display:none;
}
html.in-frame #gear{top:12px}
#gear:hover{border-color:var(--z);color:var(--z)}

#panel{
  position:fixed;top:0;left:0;bottom:0;width:var(--panel-w);z-index:35;
  background:#0a0e14;
  border-right:1px solid var(--line-b);padding:58px 16px 28px;overflow-y:auto;
  transform:translateX(-100%);transition:transform 0.28s cubic-bezier(0.4,0,0.2,1);backdrop-filter:blur(6px);
  scrollbar-width:thin;scrollbar-color:var(--faint) transparent;
}
#panel.open{transform:translateX(0)}
html.in-frame #panel{padding-top:20px}
#panelClose{position:absolute;top:12px;right:12px;width:32px;height:32px;border:1px solid var(--line);background:transparent;color:var(--dim);border-radius:8px;cursor:pointer;z-index:3}
#panelClose:hover{color:var(--z);border-color:var(--z)}

/* sections */
.sec{border-bottom:1px solid var(--line);padding:4px 0 12px}
.sec + .sec{margin-top:4px}
.sec > summary{
  list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:10px 0 8px;
  font:600 0.8rem/1 var(--f-sans);color:#e6eef6;
}
.sec > summary::-webkit-details-marker{display:none}
.sec > summary::after{content:'›';margin-left:auto;font-size:0.95rem;color:var(--dim);transition:transform .2s}
.sec[open] > summary::after{transform:rotate(90deg)}
.sec > summary:hover{color:var(--ink)}
.sec > summary .at{font:400 0.72rem/1 var(--f-mono);color:var(--dim)}

/* value fields */
.fields{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.fields .fld:only-child,.fields .fld.wide{grid-column:1 / -1}
.fld{
  display:flex;align-items:center;gap:6px;min-width:0;padding:0 10px;height:38px;border:1px solid var(--line-b);border-radius:9px;
  background:var(--bg2);transition:border-color .15s;cursor:text;
}
.fld:focus-within{border-color:var(--z);box-shadow:0 0 0 3px rgba(80,220,232,0.08)}
.fld > span{flex:none;font:400 0.78rem/1 var(--f-sans);color:var(--dim)}
.sym{display:inline-block;line-height:0;vertical-align:middle;color:var(--ink);font-size:0.95rem}
.sym svg{overflow:visible}
.fld > span.sym{font-size:0.95rem;line-height:0;color:var(--ink)}
.readout .sym{font-size:0.9rem}
.fld input{flex:1;min-width:0;width:100%;background:none;border:0;outline:none;color:var(--ink);font:400 0.82rem/1 var(--f-mono);text-align:right;font-variant-numeric:tabular-nums}
.fld > em{flex:none;font:400 0.7rem/1 var(--f-mono);font-style:normal;color:var(--dim);min-width:1.2em}
.fld.bad{border-color:var(--bad)}
.fld.bad input{color:var(--bad)}
.fields + .fields{margin-top:8px}

/* exclusive tabs and preset chips */
.tabs{display:grid;grid-template-columns:repeat(4,1fr);gap:5px;margin:0 0 10px}
.tabs.two{grid-template-columns:1fr 1fr}
.tabs.three{grid-template-columns:repeat(3,1fr)}
#gridModes{grid-template-columns:repeat(3,1fr)}
.tabs + .tabs{margin-top:-4px}
.tabs button,.chips button{
  min-height:32px;padding:6px 4px;border:1px solid var(--line);background:var(--bg2);color:var(--dim);border-radius:8px;cursor:pointer;
  font:500 0.7rem/1.15 var(--f-sans);text-align:center;transition:border-color .15s,color .15s,background .15s;
}
.tabs button:hover,.chips button:hover{border-color:var(--line-b);color:var(--ink)}
.tabs button.on{border-color:var(--z);background:rgba(80,220,232,0.08);color:var(--z)}
.tabs button:disabled,.chips button:disabled{opacity:0.35;cursor:default}
.chips{display:flex;flex-wrap:wrap;gap:5px;margin-top:8px}
.chips button{min-height:28px;padding:4px 9px;font:400 0.72rem/1 var(--f-sans);border-radius:999px}
.chips button.on{border-color:var(--z);color:var(--z)}
.chip-gap{flex-basis:100%;height:0}

input[type=range]{width:100%;accent-color:var(--z);margin:10px 0 8px;height:18px}
.note{font-size:0.76rem;line-height:1.5;color:var(--dim);margin:8px 0 0}
.note b{color:var(--text);font-weight:500}
.off{display:none!important}

/* readout */
.readout{width:100%;border-collapse:collapse;font:400 0.72rem/1.35 var(--f-mono);font-variant-numeric:tabular-nums}
.readout td{padding:4px 0;border-bottom:1px solid var(--line);vertical-align:top}
.readout td:first-child{color:var(--dim);font-family:var(--f-sans);white-space:nowrap;padding-right:10px;vertical-align:middle}
.readout td:last-child{text-align:right;color:var(--ink)}
.readout tr:last-child td{border-bottom:0}
.readout tr.zin td:last-child{color:var(--zin)}

/* formulas: static MathJax SVG. The SVG size is in ex of the box font-size.
   A wide formula scrolls sideways; it does not shrink. */
.eq{color:#eef4ff;margin:6px 0 10px;overflow-x:auto;overflow-y:hidden;scrollbar-width:none;font-size:14px;line-height:0;padding:2px 0}
.eq::-webkit-scrollbar{display:none}
.eq svg{max-width:none;overflow:visible}
.about p{font-size:0.8rem;line-height:1.6;color:var(--dim);margin:0 0 8px}
.cz{color:var(--z)} .cy{color:var(--y)}

#status{
  position:fixed;left:0;bottom:0;z-index:25;display:flex;gap:16px;align-items:center;padding:10px 18px;
  font:400 0.74rem/1 var(--f-mono);color:var(--text);background:rgba(6,8,12,0.8);border-top:1px solid var(--line);
  max-width:calc(100% - var(--panel-w));font-variant-numeric:tabular-nums;
}
#status .fn{color:var(--warm)}
#status .right{color:var(--dim)}

/* The panel covers the left edge on wide screens. The status bar and the
   topbar content start after it. */
@media(min-width:769px){
  #status{left:var(--panel-w)}
  .topbar{padding-left:calc(var(--panel-w) + 20px)}
  #hint{left:calc(50% + var(--panel-w) / 2)}
  body.panel-closed #hint{left:50%}
  body.panel-closed #gear{display:block}
  body.panel-closed #status{left:0;max-width:100%}
  body.panel-closed .topbar{padding-left:68px}
}

/* TOUCH. Any touch screen or narrow window, phone or tablet: every target is
   44px or more, and all text is 11px or more. The layout does not change.
   An input font of 16px stops the iOS zoom on focus. */
@media (pointer:coarse), (max-width:768px){
  :root{--panel-w:340px}
  #panelClose{width:44px;height:44px}
  #status{font-size:0.74rem}
  #hint,#tip{font-size:0.72rem}
  .sec > summary{min-height:44px;font-size:0.84rem}
  .fld{height:46px;border-radius:11px}
  .fld input{font-size:16px}
  .fld > span,.fld > em{font-size:0.8rem}
  .tabs button{min-height:44px;font-size:0.78rem;border-radius:11px}
  .chips button{min-height:40px;padding:4px 12px;font-size:0.74rem}
  .note{font-size:0.76rem}
  .readout{font-size:0.78rem}
  .readout td{padding:7px 0}
  .about p{font-size:0.84rem;line-height:1.65}
  input[type=range]{height:44px}
}

/* PHONE. The query matches PHONE_Q in main.js. */
@media (max-width:768px), (max-height:500px) and (pointer:coarse){
  :root{--dock-h:calc(64px + env(safe-area-inset-bottom))}
  .topbar{height:calc(48px + env(safe-area-inset-top));padding:env(safe-area-inset-top) 16px 0 calc(16px + env(safe-area-inset-left))}
  .brand{font-size:0.8rem}
  .pagetitle{font-size:1.1rem}
  #gear,body.panel-closed #gear{display:none}

  #dock{
    display:flex;position:fixed;left:0;right:0;bottom:0;z-index:45;gap:8px;align-items:center;
    padding:8px calc(10px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
    background:rgba(9,12,17,0.95);border-top:1px solid var(--line-b);backdrop-filter:blur(8px);
  }
  #dock > button{flex:0 0 48px;height:48px;border:1px solid var(--line-b);border-radius:12px;background:var(--bg2);color:var(--ink);font-size:1.1rem;cursor:pointer}
  #dock > button.on{border-color:var(--z);color:var(--z)}
  .seg{flex:1;display:flex;height:48px;min-width:0;border:1px solid var(--line-b);border-radius:12px;overflow:hidden}
  .seg button{flex:1;min-width:0;border:0;border-right:1px solid var(--line);background:var(--bg2);color:var(--dim);font:500 0.8rem/1 var(--f-sans);cursor:pointer}
  .seg button:last-child{border-right:0}
  .seg button.on{background:rgba(80,220,232,0.14);color:var(--z)}

  #status{left:0;right:0;bottom:var(--dock-h);max-width:none;gap:10px;padding:6px calc(14px + env(safe-area-inset-right)) 6px calc(14px + env(safe-area-inset-left));white-space:nowrap;overflow:hidden}
  #status span{min-width:0;overflow:hidden;text-overflow:ellipsis}
  #hint{bottom:auto;top:calc(56px + env(safe-area-inset-top));left:16px;right:16px;transform:none;text-align:center;line-height:1.6}
  html.in-frame #hint{top:12px}
  body:not(.panel-closed) #hint{opacity:0}

  /* The panel is a bottom sheet above the dock. */
  #panel{
    top:auto;left:0;right:0;bottom:var(--dock-h);width:auto;
    height:min(50vh,540px);height:min(50dvh,540px);
    border-right:0;border-top:1px solid var(--line-b);border-radius:18px 18px 0 0;
    padding:0 calc(16px + env(safe-area-inset-right)) 24px calc(16px + env(safe-area-inset-left));
    transform:translateY(calc(100% + var(--dock-h)));transition:transform 0.3s cubic-bezier(0.4,0,0.2,1),height 0.3s cubic-bezier(0.4,0,0.2,1);
    overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
  }
  #panel.open{transform:translateY(0)}
  #panel.full{height:calc(100vh - var(--dock-h) - 40px);height:calc(100dvh - var(--dock-h) - 40px)}
  html.in-frame #panel{padding-top:0}
  #panelClose{display:none}
  #sheetGrip{
    display:flex;position:sticky;top:0;z-index:2;justify-content:center;align-items:center;height:44px;margin:0 -16px 0;
    background:linear-gradient(180deg,rgba(12,17,24,1) 65%,rgba(12,17,24,0));touch-action:none;cursor:grab;
  }
  #sheetGrip span{width:46px;height:5px;border-radius:3px;background:var(--dim);opacity:0.6}
}

/* LANDSCAPE phone. The panel is a drawer on the right edge. The dock is a
   tab at the lower left. The topbar and the status bar are hidden, because
   the readout in the panel shows the same values. */
@media (max-height:500px) and (orientation:landscape){
  .topbar,#status{display:none}
  #hint,html.in-frame #hint{top:10px;left:25%;right:25%}
  #dock{right:auto;width:min(440px,56vw);border-right:1px solid var(--line-b);border-radius:0 16px 0 0}
  #panel,#panel.full{
    top:0;bottom:0;left:auto;right:0;width:min(48vw,400px);height:auto;
    border-top:0;border-left:1px solid var(--line-b);border-radius:0;
    padding:0 calc(16px + env(safe-area-inset-right)) 20px 16px;
    transform:translateX(100%);
  }
  #panel.open{transform:translateX(0)}
  #sheetGrip{display:none}
  #panelClose{display:block;position:sticky;top:10px;margin:10px 0 0 auto;width:44px;height:44px;z-index:3;background:var(--bg2)}
}

/* MATCH. Solution cards (match.js). Each card is a button; the selected one
   is drawn on the chart. .schem is the L-network schematic. */
.sols{display:grid;gap:6px}
.sol{
  display:flex;gap:10px;align-items:flex-start;width:100%;padding:9px 10px;border:1px solid var(--line);border-radius:10px;
  background:var(--bg2);color:var(--text);text-align:left;cursor:pointer;transition:border-color .15s,background .15s;
}
.sol:hover{border-color:var(--line-b)}
.sol.on{border-color:var(--match);background:rgba(126,224,160,0.06)}
.sol-n{flex:none;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;background:var(--faint);color:var(--ink);font:500 0.7rem/1 var(--f-mono)}
.sol.on .sol-n{background:var(--match);color:#06120a}
.sol-body{flex:1;min-width:0}
.sol-t{font:400 0.74rem/1.5 var(--f-mono);color:var(--ink);font-variant-numeric:tabular-nums}
.sol-t .arr{color:var(--dim);margin:0 5px}
.sol-t .dim,.sol-s{color:var(--dim)}
.sol-s{font-size:0.68rem;line-height:1.45;margin-top:2px}
.schem{display:block;width:100%;max-width:168px;height:auto;margin-top:4px;color:var(--match)}
.schem text{fill:var(--dim);font:400 9px var(--f-mono)}
@media (pointer:coarse), (max-width:768px){
  .sol{padding:11px 12px}
  .sol-t{font-size:0.8rem}
  .sol-s{font-size:0.74rem}
}

/* SWEEP. Load model fields, the Touchstone file box, and the |S11| plot
   (sweep.js). A model box with three fields puts C on its own row. */
[data-model-box] + [data-model-box]{margin-top:0}
.fields[data-model-box] .fld:nth-child(3){grid-column:1 / -1}
.filebtn{
  position:relative;display:grid;place-items:center;min-height:32px;padding:6px 4px;border:1px solid var(--line);background:var(--bg2);
  color:var(--dim);border-radius:8px;cursor:pointer;font:500 0.7rem/1.15 var(--f-sans);text-align:center;
}
.filebtn:hover{border-color:var(--line-b);color:var(--ink)}
.filebtn input{position:absolute;inset:0;opacity:0;cursor:pointer}
#pasteBox{
  width:100%;height:76px;resize:vertical;padding:8px 10px;border:1px solid var(--line-b);border-radius:9px;background:var(--bg2);
  color:var(--ink);font:400 0.68rem/1.45 var(--f-mono);outline:none;
}
#pasteBox:focus{border-color:var(--z)}
.note.bad{color:var(--bad)}
#sweepPlot{display:block;width:100%;height:150px;margin-top:10px;border:1px solid var(--line);border-radius:10px;background:var(--bg2);cursor:crosshair;touch-action:none}
@media (pointer:coarse), (max-width:768px){
  .filebtn{min-height:44px;font-size:0.78rem;border-radius:11px}
  #pasteBox{font-size:16px;height:90px}
  #sweepPlot{height:170px}
}

/* TOOLS. Markers, the share buttons, and the toast (tools.js). */
.marks{list-style:none;display:grid;gap:5px;margin-top:2px}
.marks li{display:flex;align-items:center;gap:9px;padding:6px 8px;border:1px solid var(--line);border-radius:9px;background:var(--bg2)}
.marks .mk{flex:none;font:500 0.72rem/1 var(--f-mono);color:#ffd166}
.marks .mv{flex:1;min-width:0;font:400 0.72rem/1.45 var(--f-mono);color:var(--ink);font-variant-numeric:tabular-nums}
.marks .mv small{color:var(--dim);font-size:0.66rem}
.marks button{flex:none;width:26px;height:26px;border:1px solid var(--line);border-radius:7px;background:transparent;color:var(--dim);cursor:pointer}
.marks button:hover{color:var(--bad);border-color:var(--bad)}
.fld > span + input{min-width:0}
#toast{
  position:fixed;left:50%;top:18px;transform:translate(-50%,-12px);z-index:60;padding:9px 14px;border-radius:999px;
  background:rgba(12,17,24,0.96);border:1px solid var(--match);color:var(--match);font:500 0.74rem/1 var(--f-sans);
  opacity:0;pointer-events:none;transition:opacity .25s,transform .25s;
}
#toast.on{opacity:1;transform:translate(-50%,0)}
@media (pointer:coarse), (max-width:768px){
  .marks button{width:44px;height:44px}
  .marks .mv{font-size:0.78rem}
}
