.site-description{margin:.2rem 0 0;color:#bbb;font-size:.85rem;}
.site-description span{display:inline-block;}
:focus-visible{outline:2px solid var(--accent);outline-offset:3px;}
#inputError{color:var(--warn);text-align:center;}

/* =======================================================
   Text-Byte v1.1.0 – 2026-07-12
   ======================================================= */

:root{
  --bg:#0e0e0e; --panel:#1a1a1a; --accent:#4af; --text:#fff; --border:#333;
  --ok:#00ff66; --warn:#ffb300;
  --ok-bg:radial-gradient(circle at center,#00ff6699 0%,#00ff6622 70%,#00ff6608 100%);
  --warn-bg:radial-gradient(circle at center,#ffb300cc 0%,#ffb30033 70%,#ffb3000f 100%);
  --radius:8px; --gap:0.9rem;
  --content-max:calc(240px * 7 + 0.9rem * 6 + 2rem);
  /* Pill indicators */
  --pill-size: 1.4em;
  --pill-icon: .7em;
  --pill-glow-1: 4px;
  --pill-glow-2: 8px;
  --pill-spread-1: 1.5px;
  --pill-spread-2: 3px;
  /* Header */
  --edge: 3rem;
  /* Scrollbars */
  --scroll-track: #0a0a0a;
  --scroll-thumb: #444;
  --scroll-thumb-hover: #666;
}

*{ box-sizing:border-box; }
html{
  margin:0; padding:0; min-height:100%;
  overflow-x: hidden;
  /* iOS Safari otherwise inflates text inside wide, non-wrapping output
     blocks (notably binary64 and the hex dump) to almost twice its size. */
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
}
body{
  margin:0; padding:0; min-height:100%;
  background:var(--bg); color:var(--text);
  font-family:system-ui,sans-serif; font-size:16px; line-height:1.5;
  color-scheme: dark;
}

/* Reservera alltid plats for scrollbar */
html {
  scrollbar-gutter: stable both-edges;
}

/* Fallback for Safari/aldre: visa alltid vertical scrollbar */
@supports not (scrollbar-gutter: stable) {
  html { overflow-y: scroll; }
}

input[type="checkbox"] {
  /* A real size rather than a scaled default: transform does not change the
     layout box, so a default-sized checkbox shrinks to a sliver when space is
     tight and only looks large. This box holds its width. */
  width: 1.2rem;
  height: 1.2rem;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

/* =======================================================
   GRID / CARDS
   ======================================================= */

#cards{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(240px,1fr));
  max-width:var(--content-max);
  gap:var(--gap);
  padding:1rem;
  margin:.5rem auto 2rem;
  align-items:stretch;
}

/* =======================================================
   INPUT (wrapper + textarea + clear)
   ======================================================= */

/* INPUT STICKY BAR */
.input-bar{
  /* Clears the fixed settings button once the bar sticks to the top,
     so it cannot land on the input's clear button. */
  position: sticky;
  top: 3rem;
  z-index: 100;
  margin: 0 auto;
  padding: .7rem 1rem .5rem;
  pointer-events:none;
}

/* INPUT WRAPPER */
.input-wrapper {
  position: relative;
  display: block;
  width: 100%;
  padding: .9rem .9rem .5rem;
  border-radius: var(--radius);
  background: rgba(26,26,26,.3);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  pointer-events:auto;
}

.input-wrapper textarea {
  display: block;
  width: 100%;
  padding: .7rem 2.2rem .7rem 1rem;
  font-size: 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(0,0,0,.4);
  color: var(--text);
  resize: vertical;
}

/* Equal outer columns keep Open file centred whatever the stats text says;
   the narrow layout below drops it to the right instead. */
.input-stats{
  display:grid; grid-template-columns:1fr auto 1fr; align-items:center;
  column-gap:.5rem;
  font-size:.78rem; color:rgba(255,255,255,.45);
  margin:.35rem 0 0; letter-spacing:.01em;
}
#inputStats{ justify-self:start; }
#filterInput{
  background:transparent; border:1px solid rgba(255,255,255,.15);
  border-radius:.4rem; padding:.2rem .5rem; font-size:.78rem;
  color:rgba(255,255,255,.65); width:10rem;
  transition:border-color .2s, color .2s;
}
#filterInput:focus{
  outline:none; border-color:var(--accent); color:#fff;
}
#filterInput::placeholder{ color:rgba(255,255,255,.3); }
.file-open-btn{
  padding:.2rem .55rem; font-size:.78rem;
  border-radius:.4rem; border:1px solid rgba(255,255,255,.15);
  background:rgba(255,255,255,.06); color:rgba(255,255,255,.7);
  cursor:pointer;
}
.file-open-btn:hover,.file-open-btn:focus-visible{ border-color:var(--accent); color:#fff; }
.filter-wrap{
  position:relative; display:inline-flex; align-items:center; justify-self:end;
}
.filter-clear{
  position:absolute; right:.3rem;
  background:none; border:none; color:rgba(255,255,255,.35);
  font-size:.85rem; cursor:pointer; padding:0 .15rem;
  display:none; line-height:1;
}
.filter-wrap.has-text .filter-clear{ display:block; }
.filter-clear:hover{ color:#fff; }
.filter-wrap.has-text #filterInput{ padding-right:1.3rem; }
.input-wrapper.drag-hover textarea{
  border-color:var(--accent);
  box-shadow:0 0 12px rgba(64,128,255,.35);
}
.input-wrapper.drag-hover::after{
  content:'Drop text file here';
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  background:rgba(0,0,0,.65); color:var(--accent); font-size:1.1rem; font-weight:600;
  border-radius:var(--radius); pointer-events:none; z-index:3;
}

@media (max-width: 600px) {
  .input-wrapper {
    width: 100%;
  }
  .input-bar {
    padding: .7rem 0 .5rem;
  }
}

/* Below this the three columns no longer fit the longest stats text (about
   250px); Open file moves right and the filter gets its own row. */
@media (max-width: 700px) {
  .input-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    row-gap: .45rem;
  }
  .file-open {
    margin-left: auto;
  }
  .filter-wrap {
    display: flex;
    flex: 1 0 100%;
  }
  #filterInput {
    width: 100%;
  }
}

/* Clear button inside textarea top-right */
#clearBtn{
  position:absolute;
  top:1.1rem; right:1.1rem;
  display:flex; align-items:center; justify-content:center;
  width:1.4rem; height:1.4rem; border-radius:50%;
  border:none;
  background:rgba(255,255,255,.07);
  color:rgba(255,255,255,.5); font-size:.95rem; font-weight:300;
  cursor:pointer; transition:all .2s ease; z-index:2;
  line-height:1;
}
#clearBtn:hover{
  background:rgba(255,255,255,.2);
  color:#fff;
}

/* =======================================================
   CARD
   ======================================================= */

.card{
  display:flex; flex-direction:column; justify-content:flex-start;
  background:var(--panel); border-radius:var(--radius);
  padding:1rem; border:1px solid var(--border); height:100%;
  position:relative;
  /* Grid items default to min-width:auto. Without this the hex dump's
     pre-formatted line widens the whole column instead of scrolling. */
  min-width:0;
  transition:opacity .2s, transform .2s;
}
.card.hidden{ display:none; }
.card.dragging{ opacity:.3; }
.card.drop-before::before,
.card.drop-after::after{
  content:''; position:absolute; top:4%; height:92%;
  width:3px; border-radius:2px;
  background:var(--accent);
  box-shadow:0 0 10px rgba(64,128,255,.7);
  pointer-events:none; z-index:2;
}
.card.drop-before::before{ left:calc(var(--gap) / -2 - 1.5px); }
.card.drop-after::after{   right:calc(var(--gap) / -2 - 1.5px); }
.card h3{ margin:0 0 .4rem; color:var(--accent); font-size:1.05rem; padding-right:1.5rem; cursor:grab; }
.card h3:active{ cursor:grabbing; }
.hide-btn{
  position:absolute; top:.55rem; right:.55rem;
  width:1.4rem; height:1.4rem; border-radius:50%;
  border:1px solid rgba(255,255,255,.15);
  background:rgba(255,255,255,.06);
  color:rgba(255,255,255,.35); font-size:.8rem; line-height:1;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
  transition:all .2s ease; opacity:0;
}
.card:hover .hide-btn{ opacity:1; }
.hide-btn:hover{
  background:rgba(255,80,80,.25); color:#ff8888;
  border-color:rgba(255,80,80,.4);
}

.out{
  font-family:monospace; font-size:.9rem; white-space:pre-wrap; word-break:break-word;
  background:#111; padding:.6rem .8rem; border-radius:var(--radius); border:1px solid #222;
  flex:1 1 auto; display:flex; align-items:flex-start; justify-content:flex-start;
  min-height:3em; max-height:16em; overflow-y:auto; overflow-x:hidden;
  scrollbar-width:thin; scrollbar-color:#444 #111;
}

.meta{
  margin:.55rem 0; font-size:.75rem; color:#ffb347; line-height:1.3; white-space:pre-wrap;
}
.meta.ok{
  color:var(--ok);
}
/* These three clear their meta while the worker runs. Reserving one line stops
   the grid row collapsing and springing back on every keystroke. */
#meta_b36,#meta_b58,#meta_b58chk{
  min-height:1.3em;
}

.meta.warn{
  margin-top:-0.6rem;
  position:relative;
  z-index:1;
}

.actions{
  display:flex; justify-content:space-between; align-items:center;
  margin-top:auto; gap:.75rem;
}

/* Copy / Reset buttons look */
.btn{
  background:linear-gradient(145deg,rgba(64,128,255,.25),rgba(64,128,255,.15));
  border:1px solid rgba(80,140,255,.35); color:#cfe5ff;
  border-radius:.6rem; padding:.35rem .9rem; font-size:.9rem; font-weight:600; letter-spacing:.02em;
  cursor:pointer; backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
  box-shadow:inset 0 1px 1px rgba(255,255,255,.2), 0 2px 6px rgba(0,0,0,.4);
  transition:background .25s,color .25s,box-shadow .25s, transform .15s;
}
.btn:hover{
  background:linear-gradient(145deg,rgba(100,160,255,.45),rgba(64,128,255,.25));
  border-color:rgba(120,180,255,.6); color:#fff;
  box-shadow:0 0 8px rgba(80,160,255,.45), 0 3px 12px rgba(0,0,0,.5);
  transform:translateY(-1px);
}
.btn:active{
  transform:translateY(1px);
  box-shadow:inset 0 1px 3px rgba(0,0,0,.6), 0 0 4px rgba(64,128,255,.3);
}
.btn:disabled{
  opacity:.35; cursor:not-allowed; pointer-events:none;
}

/* =======================================================
   Pill indicators (round lamps)
   ======================================================= */

/* Pill: small LED-style dot with 3 states */
.pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:var(--pill-size);
  height:var(--pill-size);
  border-radius:50%;
  border:none;
  transition:all .25s ease;
  position:relative;
}

/* Inactive / empty – gray dot */
.pill.inactive{
  background:rgba(255,255,255,.08);
  box-shadow:none;
}

/* OK – green glow with checkmark */
.pill.ok{
  background:radial-gradient(circle at center,rgba(0,255,102,.45) 0%,rgba(0,255,102,.12) 70%,transparent 100%);
  box-shadow:
    0 0 var(--pill-glow-1) var(--pill-spread-1) color-mix(in srgb, var(--ok) 80%, transparent),
    0 0 var(--pill-glow-2) var(--pill-spread-2) color-mix(in srgb, var(--ok) 40%, transparent);
}
.pill.ok::after{
  content:'';
  width:.35em; height:.22em;
  border-left:1.5px solid var(--ok);
  border-bottom:1.5px solid var(--ok);
  transform:rotate(-45deg) translate(.02em, -.08em);
  display:block;
}

/* Warn – yellow glow with triangle ! */
.pill.warn{
  background:radial-gradient(circle at center,rgba(255,179,0,.5) 0%,rgba(255,179,0,.15) 70%,transparent 100%);
  box-shadow:
    0 0 var(--pill-glow-1) var(--pill-spread-1) color-mix(in srgb, var(--warn) 80%, transparent),
    0 0 var(--pill-glow-2) var(--pill-spread-2) color-mix(in srgb, var(--warn) 40%, transparent);
}
.pill.warn::after{
  content:'';
  width:0; height:0;
  border-left:.28em solid transparent;
  border-right:.28em solid transparent;
  border-bottom:.48em solid var(--warn);
  transform:translateY(-.06em);
  display:block;
}

/* ===== TITLE (scrollable) ===== */

.site-header{
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: var(--content-max);
  /* Right padding keeps the tagline clear of the fixed settings button. */
  margin: 1.5rem auto .5rem;
  padding: 0 3.5rem 0 1rem;
}
.site-logo{
  width: 5rem;
  height: 5rem;
  display: block;
  flex: none;
}
.site-heading{ min-width: 0; }
.site-header .page-title{ margin: 0; text-align: left; }

.page-title{
  text-align: center;
  margin: 1.5rem 0 .5rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .03em;
}

/* ===== SETTINGS BUTTON (fixed) ===== */

.menu-buttons{
  position: fixed;
  top: .7rem; right: .9rem;
  z-index: 1001;
  display: flex; align-items: center; gap: .6rem;
}
.menu-buttons button{
  background: none; border: none;
  color: var(--text);
  cursor: pointer;
  transition: color .2s ease, transform .15s ease;
  display:flex; align-items:center; justify-content:center;
  width:2rem; height:2rem;
  padding:0; line-height:1;
  font-size:1.5rem;
}
.menu-buttons button:hover{ color: var(--accent); transform: scale(1.1); }
.gear-icon{ transition: transform .3s ease; }

/* ===== MENU LAYOUT ===== */
.menu{
  /* Percentages resolve against the viewport without the scrollbar; vw counts
     it, which made the panel wider than the visible area. Anchored right, that
     overhang fell across the checkbox column on the left. */
  position:fixed; top:0; right:0; width:min(620px,100%); bottom:0;
  background:rgba(17,17,17,.92); color:var(--text);
  backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px);
  transform:translateX(100%); transition:transform .3s ease;
  z-index:1000; display:flex; flex-direction:column;
  box-shadow:-4px 0 20px rgba(0,0,0,.5), 0 0 25px rgba(180,200,255,.08);
  min-height:0;
  overflow: clip;
  padding-top:3rem;
}
.menu.open{ transform:translateX(0); }

/* ==== MENU ACTIONS ==== */

.menu-actions {
  flex: 0 0 auto;
  padding: .6rem 1rem;
  border-bottom: 1px solid #2a2a2a;
  background: #181818;
}

.menu-actions .btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
}

.menu-actions .btn-grid > * {
  min-width: 0;
}

.btn.btn-ghost {
  background: transparent;
  color: #ffdca3;
  border: 1px dashed rgba(255,200,120,.45);
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn.btn-ghost:hover {
  background: rgba(255,200,120,.08);
  color: #fff;
  border-style: solid;
}

.btn.btn-save{
  visibility:hidden;
  background:linear-gradient(145deg,rgba(0,200,80,.35),rgba(0,180,60,.2));
  border:1px solid rgba(0,200,80,.5); color:#b5ffcf;
}
.btn.btn-save.visible{ visibility:visible; }
.btn.btn-save:hover{
  background:linear-gradient(145deg,rgba(0,220,100,.5),rgba(0,200,80,.3));
  border-color:rgba(0,230,110,.7); color:#fff;
  box-shadow:0 0 10px rgba(0,200,80,.4);
}

.menu-sub{
  flex:0 0 auto; padding:.55rem 1rem; border-bottom:1px solid #2a2a2a; background:#151515;
}
.menu-sub .space-opt{ display:flex; gap:.5rem; align-items:center; font-size:.95rem; }
.menu-sub input[type="checkbox"]{ cursor:pointer; }
#presetSelect{
  background:#222; color:var(--text); border:1px solid var(--border);
  border-radius:.6rem; padding:.35rem .5rem; font-size:.9rem;
  font-family:inherit; cursor:pointer; width:100%;
}
#presetSelect:focus{ outline:none; border-color:var(--accent); }

/* Scrollable middle */
.menu-body{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding-bottom: 1rem;
}

.menu-body::after {
  content: "";
  display: block;
  height: 4rem;
}

body.menu-open{
  overflow: hidden;
}

@supports (-webkit-touch-callout: none) {
  body.menu-open{
    position: fixed;
    width: 100%;
  }
}

/* Table */
.menu-table{ width:100%; border-collapse:collapse; }
.menu-table th,.menu-table td{
  text-align:left; padding:.45rem .6rem; border-bottom:1px solid #333; font-size:.9rem;
}
.menu-table th{
  color:var(--accent); position:sticky; top:0; background:#181818; z-index:1;
}
/* Column widths live here rather than inline, so the narrow breakpoint can
   relax them instead of fighting an inline style. */
.menu-table th:nth-child(1){ width:2.5rem; }
.menu-table th:nth-child(2){ min-width:12rem; }
.menu-table th:nth-child(4){ width:5rem; text-align:center; }
.menu-table td:nth-child(4){ text-align:center; }

/* Reset button (menu) */
#resetMenu{
  background:linear-gradient(145deg,rgba(255,180,60,.25),rgba(255,140,40,.15));
  border:1px solid rgba(255,180,60,.4); color:#ffe6b3;
  border-radius:.6rem; padding:.35rem .9rem; font-size:.9rem; font-weight:600; letter-spacing:.02em;
  cursor:pointer; backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
  box-shadow:inset 0 1px 1px rgba(255,255,255,.15), 0 2px 6px rgba(0,0,0,.4);
  transition:background .25s,color .25s,box-shadow .25s, transform .15s;
}
#resetMenu:hover{
  background:linear-gradient(145deg,rgba(255,200,80,.45),rgba(255,160,50,.25));
  border-color:rgba(255,200,100,.6); color:#fff;
  box-shadow:0 0 8px rgba(255,190,80,.45), 0 3px 12px rgba(0,0,0,.5);
  transform:translateY(-1px);
}
#resetMenu:active{
  transform:translateY(1px);
  box-shadow:inset 0 1px 3px rgba(0,0,0,.6), 0 0 4px rgba(255,180,80,.3);
}

/* =======================================================
   UNIFIED DARK SCROLLBARS (Menu + .out)
   ======================================================= */

/* Firefox */
.menu-body,
.out {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

/* WebKit (Chrome/Edge/Safari) */
.menu-body::-webkit-scrollbar,
.out::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.menu-body::-webkit-scrollbar-track,
.out::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 4px;
}
.menu-body::-webkit-scrollbar-thumb,
.out::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 4px;
}
.menu-body::-webkit-scrollbar-thumb:hover,
.out::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}
.menu-body::-webkit-scrollbar-corner,
.out::-webkit-scrollbar-corner {
  background: var(--scroll-track);
}

/* Column-aligned output scrolls instead of wrapping. */
#out_hexdump,#out_float64,#out_float32{
  white-space:pre; word-break:normal; overflow-x:auto; min-width:0;
}

/* =======================================================
   EXPORT FOOTER
   ======================================================= */

.export-footer{
  position:sticky; bottom:0; z-index:10;
  display:flex; justify-content:center; gap:.6rem;
  padding:.6rem 0 .8rem;
  background:linear-gradient(to top, var(--bg) 60%, transparent);
  pointer-events:none;
}
.export-footer .btn{
  pointer-events:auto;
}
.export-footer .btn.flash{
  background:linear-gradient(145deg,rgba(40,180,100,.35),rgba(40,180,100,.18));
  border-color:rgba(60,200,120,.5);
}

/* =======================================================
   RESPONSIVE
   ======================================================= */

@media (max-width:600px){
  #cards{ margin-top:.5rem; grid-template-columns:1fr; }
  .menu-buttons{ top:.4rem; right:.5rem; }
  .input-bar{ top:2.6rem; }
  .menu{ left:0; right:0; width:auto; }
  .menu-actions .btn-row .btn,
  .menu-actions .btn-grid > *{ padding:.3rem .2rem; font-size:.78rem; letter-spacing:0; }
  .menu-table td:nth-child(4),
  .menu-table th:nth-child(4){ display:none; }
  .menu-table th,.menu-table td{ padding:.4rem .4rem; font-size:.85rem; }
  /* The name column's 12rem floor plus the checkbox column left too little for
     the description, so the table grew past the panel and .menu clipped it.
     Fix the layout to the panel width and let the text wrap instead. */
  .menu-table{ table-layout:fixed; }
  .menu-table th:nth-child(1){ width:2.3rem; }
  .menu-table th:nth-child(2){ min-width:0; width:40%; }
  .menu-table td{ overflow-wrap:anywhere; }
}
