/* ============================================================================
   FISHDRAW  ·  stylesheet
   ----------------------------------------------------------------------------
   Dark desk, one canvas over it. Type comes from lib/sci.css: Inter for the
   controls, STIX Two Text for the names and the caption, the system mono
   for numbers only. Labels are sentence case with no letter-spacing. On a
   wide screen the control panel is a column on the left and the desk fills
   the rest. main.js fits the plate in the clear part of the desk.

     grep -n 'DESK'       the canvas, the caption, the busy note
     grep -n 'PANEL'      the control column
     grep -n 'CONTROLS'   sliders, segments, buttons, themes, parameters
     grep -n 'TOUCH'      target and text sizes for any touch screen
     grep -n 'PHONE'      dock and bottom sheet
     grep -n 'LANDSCAPE'  the phone drawer at the right edge
   ========================================================================== */
:root{
  --bg:#0b0c0f; --bg2:#14161b; --ink:#d9dbe0; --dim:#8a8f99; --faint:#2b2f37;
  --line:rgba(227,196,138,0.10); --line-b:rgba(227,196,138,0.24);
  --acc:#e3c48a; --panel-w:330px; --top:52px; --dock-h:0px;
}
*,*::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(--sci-sans);color:var(--ink);-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}
button{font-family:inherit;touch-action:manipulation;-webkit-tap-highlight-color:transparent;cursor:pointer}
button:focus-visible,input:focus-visible,select:focus-visible{outline:1px solid var(--acc);outline-offset:1px}
a{color:var(--acc)}
code{font:0.92em var(--sci-mono);color:#cfc6b2}

.topbar{position:fixed;top:0;left:0;right:0;height:var(--top);z-index:30;display:flex;align-items:center;gap:18px;padding:0 20px 0 calc(var(--panel-w) + 20px);background:rgba(11,12,15,0.9);border-bottom:1px solid var(--line);pointer-events:none;transition:padding 0.28s cubic-bezier(0.4,0,0.2,1)}
.brand{font-size:0.85rem;font-weight:500;color:var(--dim)}
.pagetitle{font-family:var(--sci-serif);font-size:1.15rem;color:#f1eee6}
.topbar .credit{margin-left:auto;font-size:0.78rem;color:var(--dim);pointer-events:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topbar .credit a{color:#d9c79f;text-decoration:none}
.topbar .credit a:hover{text-decoration:underline}
.credit-box{font-size:0.78rem;line-height:1.5;color:#d8d2c4;background:rgba(227,196,138,0.06);border:1px solid var(--line);border-radius:8px;padding:7px 10px;margin:0 0 12px}
.about .ours{font-size:0.74rem}
html.in-frame{--top:0px}
html.in-frame .topbar{display:none}
body.panel-closed .topbar{padding-left:68px}
html.in-frame body.panel-closed .topbar{padding-left:20px}

#gear{position:fixed;top:7px;left:14px;z-index:40;width:38px;height:38px;border:1px solid var(--line-b);background:rgba(20,22,27,0.85);color:var(--ink);border-radius:9px;font-size:1rem;display:none}
html.in-frame #gear{top:14px}
#gear:hover{border-color:var(--acc);color:var(--acc)}
@media(min-width:769px){ body.panel-closed #gear{display:block} }

/* DESK */
#desk{position:fixed;top:var(--top);left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(90% 80% at 55% 45%,#17181d 0%,#0b0c0f 75%)}
#view{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;cursor:grab}
#view.drag{cursor:grabbing}
#view.cell{cursor:pointer}
#caption{position:absolute;left:0;top:0;transform:translateX(-50%);white-space:nowrap;background:rgba(11,12,15,0.78);padding:2px 10px;border-radius:999px;z-index:3;font-family:var(--sci-serif);font-size:0.98rem;color:#a8acb5;pointer-events:none;max-width:96%;overflow:hidden;text-overflow:ellipsis}
#caption i{font-style:italic;color:#e7e2d6}
#caption .cr{color:#8f8a7e;font-size:0.9em}
#caption .n{font-variant-numeric:tabular-nums}
#busy{position:absolute;right:14px;top:12px;font-size:0.75rem;color:var(--dim);background:rgba(14,16,20,0.82);border:1px solid var(--line);border-radius:999px;padding:4px 10px;pointer-events:none}

#minimap{position:absolute;left:12px;bottom:40px;display:none;z-index:4;border:1px solid var(--line-b);border-radius:6px;box-shadow:0 4px 16px rgba(0,0,0,0.45);cursor:crosshair;touch-action:none}
#minimap.on{display:block}
/* TREE CARD. The fish under the cursor of the tree mode, large. */
#treeCard{position:absolute;right:14px;top:44px;width:400px;max-height:calc(100% - 60px);overflow-y:auto;z-index:5;
  background:rgba(14,16,20,0.94);border:1px solid var(--line-b);border-radius:12px;padding:12px 12px 10px;font-size:0.76rem;color:var(--dim);
  scrollbar-width:thin;scrollbar-color:var(--faint) transparent}
#treeCard[hidden]{display:none}
#cardClose{position:absolute;top:8px;right:8px;width:28px;height:28px;border:1px solid var(--line);border-radius:7px;background:var(--bg2);color:var(--dim)}
#cardFish{display:block;width:100%;aspect-ratio:5/3;border-radius:6px;margin-top:22px}
#cardName{font:italic 1.1rem var(--sci-serif);color:#f1eee6;margin:8px 0 2px}
#cardMeta{margin-bottom:6px}
#cardDiff .ch{color:var(--ink);margin:8px 0 3px}
#cardDiff ul,#cardDiff ol{margin:0 0 0 18px;line-height:1.5}
#cardDiff i{font-family:var(--sci-serif);font-size:0.86rem;color:#d8d2c4}
.seg.three{grid-template-columns:repeat(3,1fr)}

/* PANEL */
#panel{position:fixed;top:0;left:0;bottom:0;width:var(--panel-w);z-index:35;background:#0e1014;border-right:1px solid var(--line-b);
  padding:66px 18px 40px;overflow-y:auto;transform:translateX(-100%);transition:transform 0.28s cubic-bezier(0.4,0,0.2,1);
  scrollbar-width:thin;scrollbar-color:var(--faint) transparent}
#panel.open{transform:none}
html.in-frame #panel{padding-top:20px}
#panelClose{position:absolute;top:12px;right:12px;width:30px;height:30px;border:1px solid var(--line);background:transparent;color:var(--dim);border-radius:7px}
#panelClose:hover{color:var(--acc);border-color:var(--acc)}
#sheetGrip,#dock{display:none}

.sec-label{font-size:0.8rem;font-weight:600;color:#ecebe6;margin:22px 0 10px;padding-top:14px;border-top:1px solid var(--line)}
.sec-label.first{margin-top:0;padding-top:0;border-top:0}
.hint{font-size:0.72rem;line-height:1.55;color:var(--dim);margin:6px 0 4px}
.hint i{font-family:var(--sci-serif);font-size:0.86rem;color:#d8d2c4}

/* CONTROLS */
.prm{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:2px 8px;margin:8px 0 10px}
.prm .nm{font-size:0.82rem;color:var(--ink);white-space:nowrap}
.prm .val{font:0.74rem var(--sci-mono);color:var(--ink);text-align:right}
.prm input[type=range]{grid-column:1 / -1;width:100%;accent-color:var(--acc);height:3px;margin-top:4px}

.seg{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin:6px 0}
.seg.first{margin:0 0 6px}
.seg button,.btns button,.namerow button,.small{padding:8px 4px;border:1px solid var(--line-b);background:var(--bg2);color:var(--ink);border-radius:7px;font-size:0.76rem;transition:border-color 0.2s,color 0.2s}
.seg button{color:var(--dim)}
.seg button:hover,.btns button:hover,.namerow button:hover,.small:hover{border-color:var(--acc);color:var(--ink)}
.seg button.on,.btns button.on{border-color:var(--acc);color:var(--acc);background:rgba(227,196,138,0.07)}
.btns{display:flex;gap:6px;margin:6px 0}
.btns button{flex:1}
.btns.wrap{flex-wrap:wrap}
.btns.wrap button{flex:1 1 30%}
button:disabled{opacity:0.4;cursor:default}

.namerow{display:flex;gap:6px;margin:4px 0}
.namerow input{flex:1;min-width:0;padding:8px 10px;border:1px solid var(--line-b);border-radius:7px;background:#0a0b0e;color:#f1eee6;font:italic 1.02rem var(--sci-serif)}
.namerow button{flex:0 0 auto;padding:8px 14px}
#titleInp{font-style:normal}

.row2{display:flex;align-items:center;gap:8px;margin:8px 0}
.row2 .nm{font-size:0.82rem;flex:0 0 52px}
.row2 select{flex:1;min-width:0;padding:7px 8px;border:1px solid var(--line-b);border-radius:7px;background:var(--bg2);color:var(--ink);font:0.8rem var(--sci-sans)}
.row2 input[type=color]{width:42px;height:30px;border:1px solid var(--line-b);border-radius:7px;background:var(--bg2);padding:2px}
.row2 .small{padding:6px 10px}

.themes{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin:4px 0 8px}
.themes button{display:flex;align-items:center;gap:7px;padding:6px 7px;border:1px solid var(--line);border-radius:8px;background:var(--bg2);color:var(--dim);font-size:0.7rem;text-align:left;line-height:1.2}
.themes button i{flex:0 0 18px;height:18px;border-radius:4px;background:var(--p);box-shadow:inset 0 0 0 1px rgba(0,0,0,0.25);position:relative}
.themes button i::after{content:'';position:absolute;left:4px;right:4px;top:8px;height:2px;border-radius:1px;background:var(--k)}
.themes button.on{border-color:var(--acc);color:var(--acc)}

.chips{display:flex;flex-wrap:wrap;gap:5px;margin:4px 0 6px}
.chips button{flex:1 1 auto;padding:6px 9px;border:1px solid var(--line-b);border-radius:999px;background:var(--bg2);color:var(--dim);font-size:0.74rem}
.chips button.on{border-color:var(--acc);color:var(--acc)}
.chips button:hover{color:var(--ink)}

/* Parameters: one <details> per group. */
#params details{border:1px solid var(--line);border-radius:9px;margin:6px 0;background:#101217}
#params summary{list-style:none;display:flex;align-items:center;gap:8px;padding:8px 10px;cursor:pointer;font-size:0.8rem;color:#ecebe6}
#params summary::-webkit-details-marker{display:none}
#params summary::before{content:'›';color:var(--dim);transition:transform 0.2s;display:inline-block;width:8px}
#params details[open] summary::before{transform:rotate(90deg)}
#params summary .ed{font-size:0.68rem;color:var(--acc)}
#params summary .roll{margin-left:auto;padding:3px 9px;border:1px solid var(--line-b);border-radius:6px;background:var(--bg2);color:var(--ink);font-size:0.7rem}
#params summary .roll:hover{border-color:var(--acc)}
#params .body{padding:0 10px 8px}
.pr{display:grid;grid-template-columns:22px minmax(0,1fr) auto;align-items:center;gap:2px 6px;margin:6px 0 8px}
.pr .lock{width:22px;height:22px;border:0;background:none;color:#5d6270;padding:0;display:flex;align-items:center;justify-content:center;border-radius:5px}
.pr .lock svg{width:13px;height:13px}
.pr .lock.on{color:var(--acc);background:rgba(227,196,138,0.1)}
.pr .nm{font-size:0.78rem;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pr.edited .nm{color:var(--acc)}
.pr .val{font:0.72rem var(--sci-mono);color:var(--dim);text-align:right}
.pr input[type=range]{grid-column:2 / -1;width:100%;accent-color:var(--acc);height:3px}
.pr .opts{grid-column:2 / -1;display:flex;flex-wrap:wrap;gap:4px}
.pr .opts button{flex:1 1 auto;padding:5px 6px;border:1px solid var(--line);background:var(--bg2);color:var(--dim);border-radius:6px;font-size:0.7rem}
.pr .opts button.on{border-color:var(--acc);color:var(--acc)}

.about p{font-size:0.8rem;line-height:1.6;color:var(--dim);margin:0 0 9px}

/* TOUCH. Any touch screen or narrow window: targets are 44px or more. */
@media (pointer:coarse), (max-width:768px){
  :root{--panel-w:340px}
  #panelClose,#cardClose{width:44px;height:44px}
  #cardFish{margin-top:46px}
  .seg button,.btns button,.namerow button,.small{min-height:44px;font-size:0.8rem;border-radius:10px}
  .namerow input{min-height:44px;font-size:1.08rem}
  .row2 select{min-height:44px}
  .row2 input[type=color]{width:52px;height:44px}
  .themes button{min-height:44px;font-size:0.74rem}
  .chips button{min-height:40px;font-size:0.8rem}
  .prm .nm{font-size:0.86rem}
  .prm .val{font-size:0.8rem}
  .hint{font-size:0.76rem}
  .about p{font-size:0.84rem;line-height:1.65}
  #params summary{min-height:44px;font-size:0.86rem}
  #params summary .roll{min-height:34px;padding:4px 12px}
  .pr .lock{width:36px;height:36px}
  .pr{grid-template-columns:36px minmax(0,1fr) auto}
  .pr .nm{font-size:0.84rem}
  .pr .opts button{min-height:40px;font-size:0.76rem}
  input[type=range]{-webkit-appearance:none;appearance:none;height:40px!important;background:transparent}
  input[type=range]::-webkit-slider-runnable-track{height:6px;border-radius:3px;background:var(--faint)}
  input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:26px;height:26px;margin-top:-10px;border-radius:50%;background:var(--acc);border:3px solid #15130e;box-shadow:0 0 0 1px var(--acc)}
  input[type=range]::-moz-range-track{height:6px;border-radius:3px;background:var(--faint)}
  input[type=range]::-moz-range-thumb{width:22px;height:22px;border-radius:50%;background:var(--acc);border:3px solid #15130e}
}

/* PHONE. The query matches PHONE_Q in main.js. */
@media (max-width:768px), (max-height:500px) and (pointer:coarse){
  :root{--top:calc(46px + env(safe-area-inset-top));--dock-h:calc(64px + env(safe-area-inset-bottom));--panel-w:0px}
  html.in-frame{--top:0px}
  html,body{height:100dvh}
  .topbar{padding:env(safe-area-inset-top) 16px 0 calc(16px + env(safe-area-inset-left))}
  .brand{font-size:0.8rem}
  .pagetitle{font-size:1rem}
  .topbar .credit{font-size:0.7rem}
  #gear,body.panel-closed #gear{display:none}
  #desk{bottom:var(--dock-h)}
  #caption{font-size:0.86rem}
  #treeCard{left:8px;right:8px;top:8px;width:auto;max-height:62%;padding:10px}
  #cardFish{width:100%;margin:46px 0 4px}
  #minimap{left:8px;bottom:36px}
  #cardName{margin-top:0;padding-right:48px}

  #dock{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:45;gap:7px;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(14,16,20,0.96);border-top:1px solid var(--line-b)}
  #dock > button{flex:0 0 46px;height:48px;border:1px solid var(--line-b);border-radius:12px;background:var(--bg2);color:var(--ink);font-size:1.1rem}
  #dock > button.on{border-color:var(--acc);color:var(--acc);background:rgba(227,196,138,0.08)}
  #dock > button:disabled{opacity:0.35}
  #dock > button.name{flex:1 1 auto;min-width:0;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 12px;font-family:var(--sci-serif);font-style:italic;font-size:1rem;text-align:left}
  #dock > button.name span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  #dock > button.name i{font-style:normal;color:var(--dim);font-family:var(--sci-sans)}

  #panel{top:auto;left:0;right:0;bottom:var(--dock-h);width:auto;height:min(50vh,520px);height:min(50dvh,520px);
    border-right:0;border-top:1px solid var(--line-b);border-radius:18px 18px 0 0;
    padding:0 calc(18px + env(safe-area-inset-right)) 28px calc(18px + 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}
  #panel.open{transform:none}
  #panel.full{height:calc(100vh - var(--dock-h) - 40px);height:calc(100dvh - var(--dock-h) - 40px - env(safe-area-inset-top))}
  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:40px;margin:0 -18px 2px;background:linear-gradient(180deg,#0e1014 70%,rgba(14,16,20,0));touch-action:none;cursor:grab}
  #sheetGrip span{width:46px;height:5px;border-radius:3px;background:var(--dim);opacity:0.6}
  .themes{grid-template-columns:repeat(3,1fr)}
}

/* LANDSCAPE phone. The panel is a drawer at the right edge, the dock a
   tab at the lower left, and the topbar is hidden. */
@media (max-height:500px) and (orientation:landscape) and (pointer:coarse){
  :root{--top:0px}
  .topbar{display:none}
  #desk{bottom:0}
  #dock{right:auto;width:min(460px,58vw);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(46vw,380px);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:none}
  #sheetGrip{display:none}
  #panelClose{display:block;position:sticky;top:10px;margin:10px 0 0 auto;z-index:2;background:var(--bg2)}
}
@media(prefers-reduced-motion:reduce){#panel,.topbar{transition:none}}
