/* Sheet Studio — the one small stylesheet on top of 00.css.
 *
 * Everything here is either the table (which 00.css has no opinion about) or the phone
 * (where a table with seven columns has to stop being a table). Colours are the host's
 * tokens with the same fallbacks 00.css uses, so this file looks right with no theme at all.
 */

/* ── header ─────────────────────────────────────────────────────────────────────────────── */

.hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s2, 8px);
  margin-bottom: var(--s3, 12px);
}
.hdr-main { min-width: 0; flex: 1 1 220px; }
.hdr .btn { flex: 0 0 auto; }

/* ── the table ──────────────────────────────────────────────────────────────────────────── */

.grid-scroll {
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--line, #262a30);
  border-radius: var(--radius, 10px);
  background: var(--surface, #0f1114);
}
.grid-scroll:focus-visible {
  outline: 2px solid var(--accent, #4ade9b);
  outline-offset: 2px;
}

.grid {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  /* Numbers line up under each other, which is the only reason to look at a column of them. */
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.grid th,
.grid td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line, #262a30);
  max-width: 22ch;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0;
  background: var(--surface-2, #141619);
  border-bottom: 1px solid var(--line, #262a30);
  white-space: nowrap;
}

/* The header cell is a button so it is reachable by tab and announced as pressable. */
.colbtn {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: var(--tap, 44px);
  padding: 6px 10px;
  border: 0;
  background: none;
  color: var(--ink-dim, #8b95a1);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.colbtn:hover { color: var(--ink, #e6e9ec); }
.colbtn:focus-visible {
  outline: 2px solid var(--accent, #4ade9b);
  outline-offset: -2px;
}
.colbtn[data-sorted] { color: var(--accent, #4ade9b); }
.sortmark { font-size: 10px; }

.grid tbody tr { background: var(--surface, #0f1114); }
.grid tbody tr.selected { background: var(--raised, #1b1e22); box-shadow: inset 2px 0 0 var(--accent, #4ade9b); }
.grid tbody tr.active { outline: 2px solid var(--accent, #4ade9b); outline-offset: -2px; }
.grid tbody tr.active:focus-visible { outline: 2px solid var(--accent, #4ade9b); }
.grid tbody tr.drop { color: var(--ink-dim, #8b95a1); box-shadow: inset 2px 0 0 var(--danger, #f0555f); }
.grid tbody tr.drop td:first-child { text-decoration: line-through; }
.grid tbody tr.spacer { background: none; }
.grid tbody tr.spacer td { padding: 0; border: 0; }

.rownum { color: var(--ink-dim, #8b95a1); font-variant-numeric: tabular-nums; }
.dropmark { color: var(--danger, #f0555f); font-size: 11px; white-space: nowrap; }

/* ── the file list ──────────────────────────────────────────────────────────────────────── */

#sec-files .list { max-height: 40vh; overflow: auto; }
.file-btn {
  display: block;
  width: 100%;
  min-height: var(--tap, 44px);
  padding: var(--s2, 8px);
  border: 0;
  border-radius: var(--radius, 10px);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.file-btn:focus-visible { outline: 2px solid var(--accent, #4ade9b); outline-offset: -2px; }

/* ── the histogram ──────────────────────────────────────────────────────────────────────── */

.hist { margin-top: var(--s2, 8px); }
.hist svg { display: block; width: 100%; height: 88px; }
.hist rect { fill: var(--accent, #4ade9b); opacity: 0.75; }
.hist line { stroke: var(--line, #262a30); stroke-width: 1; }

/* ── the phone: at 360 px a seven-column table is not a table ────────────────────────────── */

/* The header row is where sorting lives on a wide screen; below, it folds away and this appears. */
.phone-only { display: none; }

@media (max-width: 560px) {
  .phone-only { display: flex; }
  .grid-scroll { max-height: 58vh; }
  .grid,
  .grid tbody,
  .grid tbody tr,
  .grid tbody td { display: block; width: auto; }
  .grid thead { display: none; }
  .grid tbody tr {
    border: 1px solid var(--line, #262a30);
    border-radius: var(--radius, 10px);
    margin: var(--s2, 8px);
    padding: var(--s1, 4px) 0;
  }
  .grid tbody td {
    display: flex;
    gap: var(--s2, 8px);
    max-width: none;
    border: 0;
    padding: 4px var(--s2, 8px);
    min-height: 24px;
  }
  /* Each cell carries its own column name, because the header row is gone. */
  .grid tbody td::before {
    content: attr(data-label);
    flex: 0 0 9em;
    color: var(--ink-dim, #8b95a1);
    font-size: 12px;
  }
  .grid tbody tr.drop td:first-child { text-decoration: none; }
  .grid tbody tr.spacer { margin: 0; border: 0; }
}

/* ── motion ─────────────────────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
