/* ════════════════════════════════════════════════════════
   ADERPY · metaTOOLS shell — 1-bit mono
   ════════════════════════════════════════════════════════ */

*{box-sizing:border-box;margin:0;padding:0}

:root{
  --ink:#000;
  --paper:#fff;
  --rule:2px;
  --tab-w:130px;
  --tab-overlap:14px;
  --tab-h:36px;
  --tab-peek:28px;
  --tabbar-h:52px;
  --mono:"Monaco","Geneva","Lucida Console","Courier New",monospace;
}

html,body{height:100%;overflow:hidden}

body{
  background:var(--paper);
  color:var(--ink);
  font-family:var(--mono);
  font-size:12px;
  line-height:1.4;
  -webkit-font-smoothing:none;
  font-smooth:never;
  display:flex;
  flex-direction:column;
}

a{color:inherit;text-decoration:none}
button{font:inherit;color:inherit;background:none;border:0;cursor:pointer}

/* ═══ TABBAR ════════════════════════════════════════════ */
.tabbar{
  position:relative;
  display:flex;
  align-items:flex-end;
  height:var(--tabbar-h);
  flex-shrink:0;
  background:var(--paper);
}
/* Only the front/bottom rule spans beneath the control rail to
   the canvas edge. Active tabs rise over it. */
.tabbar::after{
  content:"";
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  height:var(--rule);
  background:var(--ink);
  z-index:5000;
  pointer-events:none;
}
/* a column of tab rows: the front/bottom row first in reading
   order, back rows stacked behind and above it (JS sets the
   negative margins, stagger, and z-index bands) */
.tab-strip{
  flex:1;
  min-width:0;
  overflow:visible;
  position:relative;   /* anchors the per-row .row-edge rules */
}
.tab-row{
  display:flex;
  align-items:flex-end;
}
/* Divider-sheet border: a scalable straight run joined to a
   fixed 18px SVG cap. JS sets the baseline and stacking depth. */
.row-edge{
  position:absolute;
  left:0; right:0;
  height:0;
  pointer-events:none;
}
.row-edge-line{
  position:absolute;
  left:0;
  right:0;
  top:calc(-1 * var(--rule));
  height:var(--rule);
  background:var(--ink);
}
.file-edge .row-edge-line{right:18px}
.row-edge-cap{
  position:absolute;
  top:calc(-1 * var(--rule));
  right:0;
  width:18px;
  overflow:visible;
}
.row-edge-cap path{
  fill:none;
  stroke:var(--ink);
  stroke-width:2;
  vector-effect:non-scaling-stroke;
}

/* Each tab is a click target containing an SVG silhouette and a label. */
.tab{
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:var(--tab-w); /* fixed — no resize jitter */
  height:var(--tab-h);
  padding:0 18px;
  font-size:10px;
  letter-spacing:.16em;
  text-transform:uppercase;
  white-space:nowrap;
  cursor:pointer;
  flex-shrink:0;
  user-select:none;
  margin-right:calc(-1 * var(--tab-overlap)); /* overlap by one flare-width */
}
.tab.active{
  font-weight:700;
}

.tab-bg{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  pointer-events:none;
  z-index:-1;
  overflow:visible;
}
/* fill and stroke are separate paths (see TAB_FILL / TAB_LINE):
   the fill blanks whatever is behind the tab, the stroke's base
   sits half a stroke higher so it registers exactly on the
   2px edge rules */
.tab-bg .tab-fill{
  fill:var(--paper);
  stroke:none;
}
.tab-bg .tab-line{
  fill:none;
  stroke:var(--ink);
  stroke-width:2;
  vector-effect:non-scaling-stroke;
}

/* cascade: earlier tabs render on top of later, so each tab's
   left flare is obscured by its left neighbour's overlap;
   the active tab pops over everything, folder edge included */
.tab{ z-index:var(--z,1); }
.tab.active{ z-index:9999; }

.compact-nav{display:none}

/* The controls are a real flex sibling of the strip. Their
   padding is the tabs' right-side safe area, so neither the
   controls nor the canvas edge can cover a tab. */
.tab-controls{
  flex:0 0 auto;
  align-self:flex-start;
  display:flex;
  gap:8px;
  padding:8px 8px 0;
  position:relative;
  z-index:6000;
}

/* On desktop the filing-cabinet sheets own the full canvas width.
   The controls float over that canvas; JS reserves their footprint
   only in the one tab row that actually shares their vertical band. */
@media (min-width:701px){
  .tab-controls{
    position:absolute;
    top:0;
    right:0;
  }
}
.help-btn{
  width:26px;
  height:26px;
  border:var(--rule) solid var(--ink);
  border-radius:50%;
  background:var(--paper);
  font-size:13px;
  font-weight:900;
  line-height:1;
  display:flex;
  align-items:center;
  justify-content:center;
}
.help-btn.active{
  background:var(--ink);
  color:var(--paper);
}

/* filing-cabinet toggle: hides / shows the back rows.
   Inverted while the drawer is shut (rows hidden). */
.cabinet-btn{
  width:26px;
  height:26px;
  border:var(--rule) solid var(--ink);
  background:var(--paper);
  display:flex;
  align-items:center;
  justify-content:center;
}
.cabinet-btn.active{
  background:var(--ink);
  color:var(--paper);
}
.cabinet-btn:active{transform:translate(1px,1px)}

/* ═══ CONTENT ═══════════════════════════════════════════ */
.content{
  flex:1;
  overflow:hidden;
  position:relative;
  display:flex;
  flex-direction:column;
}
.hidden{display:none!important}

/* ─── Landing ─── */
.home{
  flex:1;
  min-width:0;
  min-height:0;
  overflow:hidden;
  display:grid;
  grid-template-rows:minmax(0,1fr) auto;
  padding:clamp(16px,3vw,32px);
  gap:clamp(10px,2vh,20px);
  width:100%;
}

.logo{
  min-width:0;
  min-height:0;
  overflow:hidden;
  display:flex;
  align-items:center;
  justify-content:center;
  grid-column:span 3;
  border-right:var(--rule) solid var(--ink);
  border-bottom:var(--rule) solid var(--ink);
  padding:clamp(8px,calc(var(--grid-tile-size) * .12),24px);
  width:100%;
}
.logo .mark{
  display:block;
  max-width:100%;
  max-height:100%;
  object-fit:contain;
  image-rendering:pixelated;
}

.grid{
  --grid-min-track:72px;
  --grid-cols:3;
  --grid-rows:1;
  --grid-tile-size:120px;
  display:grid;
  grid-template-columns:repeat(var(--grid-cols),minmax(0,1fr));
  grid-template-rows:repeat(var(--grid-rows),minmax(0,1fr));
  grid-auto-flow:row;
  gap:0;
  width:100%;
  height:100%;
  min-width:0;
  min-height:0;
  border-top:var(--rule) solid var(--ink);
  border-left:var(--rule) solid var(--ink);
}
.cell{
  min-width:0;
  min-height:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:clamp(2px,calc(var(--grid-tile-size) * .04),8px);
  padding:clamp(3px,calc(var(--grid-tile-size) * .08),12px)
          clamp(3px,calc(var(--grid-tile-size) * .04),6px);
  border-right:var(--rule) solid var(--ink);
  border-bottom:var(--rule) solid var(--ink);
  background:var(--paper);
  cursor:pointer;
  text-align:center;
  overflow:hidden;
}
.cell:hover{ background:var(--ink); color:var(--paper); }
.cell:hover .ico img{ filter:invert(1); }
.cell:active{transform:translate(1px,1px)}

.ico{
  width:min(64px,55%);
  height:auto;
  aspect-ratio:1 / 1;
  flex:0 1 auto;
  display:flex; align-items:center; justify-content:center;
}
.ico img{
  width:100%;
  height:100%;
  display:block;
  object-fit:contain;
  image-rendering:pixelated;
}

.cell .name{
  max-width:100%;
  font-size:clamp(6px,calc(var(--grid-tile-size) * .065),10px);
  letter-spacing:.18em;
  text-transform:uppercase;
  font-weight:700;
  overflow-wrap:anywhere;
}
.beta-cell{
  justify-content:center;
  min-height:0;
  font-size:clamp(6px,calc(var(--grid-tile-size) * .065),10px);
  font-weight:700;
  letter-spacing:.08em;
  line-height:1.5;
  text-transform:none;
}

.rites-note{
  margin-top:0;
  text-align:center;
  font-family:var(--mono);
  font-size:10px;
  line-height:1.4;
  letter-spacing:.08em;
  color:var(--ink);
}
.copy-glyph{
  display:inline-block;
  text-decoration:line-through;
  text-decoration-thickness:var(--rule);
  text-decoration-skip-ink:none;
}

/* ── App iframe ── */
.app-frame{
  width:100%;
  flex:1;
  border:none;
  background:var(--paper);
  display:block;
}

.app-loading{
  position:absolute;
  inset:0;
  z-index:1;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:var(--paper);
  color:var(--ink);
}
.app-loading[hidden]{display:none}

/* ═══ MOBILE ════════════════════════════════════════════ */
@media (max-width:600px){
  :root{--tabbar-h:44px;--tab-h:30px;--tab-peek:24px}
  .tab{padding:0 16px; font-size:9px; letter-spacing:.12em}
  .home{padding:12px;gap:10px}
  .grid{--grid-min-track:56px}
  .ico{width:min(44px,55%);height:auto}
  .tab-controls{gap:6px;padding:6px 6px 0}
  .help-btn{width:24px;height:24px;font-size:12px}
  .cabinet-btn{width:24px;height:24px}
}

/* Shared by mobile navigation and collapsed desktop tabs. */
  .paged-tabs .compact-nav{
    flex:0 0 28px;
    width:28px;
    height:28px;
    margin-bottom:2px;
    border:0;
    background:var(--paper);
    display:flex;
    align-items:center;
    justify-content:center;
    position:relative;
    z-index:6000;
  }
  .paged-tabs .compact-nav svg{width:14px;height:14px}
  .paged-tabs .compact-nav path{
    fill:none;
    stroke:currentColor;
    stroke-width:2;
    stroke-linecap:square;
    stroke-linejoin:miter;
  }

  .paged-tabs .compact-nav:focus-visible{outline:var(--rule) solid var(--ink);outline-offset:-4px}
  .paged-tabs .compact-nav:disabled{visibility:hidden;pointer-events:none}
  .paged-tabs .tab-strip{
    overflow-x:hidden;
    overflow-y:hidden;
    padding-top:2px;
    overscroll-behavior-x:contain;
    scrollbar-width:none;
    touch-action:pan-y;
  }
  .paged-tabs .tab-strip::-webkit-scrollbar{display:none}
  .paged-tabs .compact-tab-row{
    width:max-content;
    padding-right:var(--tab-overlap);
    flex-wrap:nowrap;
  }
  .paged-tabs .tab-controls{
    position:relative;
    top:auto;
    right:auto;
    margin-left:auto;
  }
@media (max-width:700px){
  .cabinet-btn{display:none!important}
}
