body.xlr8-mode {
  overflow: hidden;
}

body.xlr8-mode .app {
  height: 100dvh;
  min-height: 0;
  padding-bottom: 0;
}

body.xlr8-mode .topbar {
  display: none;
}

.view-root.xlr8-active {
  width: 100%;
  max-width: none;
  height: calc(100dvh - env(safe-area-inset-top));
  padding: 0;
  overflow: hidden;
}

.xlr8-shell {
  --xlr8-cell-width: 104px;
  --xlr8-row-height: 30px;
  --xlr8-row-header-width: 46px;
  --xlr8-column-header-height: 28px;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--bg);
  color: var(--body-text);
}

.xlr8-commandbar {
  flex: 0 0 auto;
  padding: 7px 9px 8px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, var(--foreground) 6%);
}

.xlr8-heading-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
}

.xlr8-back {
  width: 30px;
  height: 30px;
  padding: 0 1px 2px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--foreground);
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}

.xlr8-back:active {
  background: var(--panel-2);
  transform: scale(.97);
}

.xlr8-heading-text {
  min-width: 0;
}

.xlr8-heading-text strong,
.xlr8-heading-text span {
  display: block;
}

.xlr8-heading-text strong {
  color: var(--accent);
  font-size: 15px;
  line-height: 1;
  letter-spacing: -.01em;
}

.xlr8-heading-text span {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8.5px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.xlr8-save-status {
  min-width: 48px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .08em;
  text-align: right;
}

.xlr8-entry-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 6px;
  margin-top: 7px;
}

.xlr8-address,
.xlr8-editor {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--foreground);
}

.xlr8-address {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.xlr8-editor {
  min-width: 0;
  width: 100%;
  padding: 5px 9px;
  color: var(--body-text);
  caret-color: var(--accent);
  font-size: 16px;
  line-height: 1;
  outline: none;
}

.xlr8-editor:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line) 30%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 24%, transparent);
}

.xlr8-viewport {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  background: var(--foreground);
  scrollbar-color: var(--accent) var(--bg);
}

.xlr8-canvas {
  position: relative;
  isolation: isolate;
  background: color-mix(in srgb, var(--foreground) 96%, var(--bg) 4%);
}

.xlr8-cells-layer,
.xlr8-headers-layer {
  position: absolute;
  inset: 0;
}

.xlr8-headers-layer {
  z-index: 2;
  pointer-events: none;
}

.xlr8-cell,
.xlr8-column-header,
.xlr8-row-header,
.xlr8-corner-header {
  position: absolute;
  margin: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.xlr8-cell {
  z-index: 1;
  padding: 0 6px;
  overflow: hidden;
  background: var(--foreground);
  color: var(--body-text);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.xlr8-cell:active {
  background: var(--panel-2);
}

.xlr8-cell.is-selected {
  z-index: 2;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--foreground) 90%, var(--accent) 10%);
  color: var(--accent);
}

.xlr8-column-header,
.xlr8-row-header,
.xlr8-corner-header {
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 88%, var(--foreground) 12%);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.xlr8-column-header,
.xlr8-row-header {
  z-index: 3;
}

.xlr8-column-header.is-selected,
.xlr8-row-header.is-selected {
  color: var(--accent);
  background: color-mix(in srgb, var(--bg) 76%, var(--accent) 24%);
}

.xlr8-corner-header {
  z-index: 4;
  border-right-color: color-mix(in srgb, var(--line) 60%, var(--accent) 40%);
  border-bottom-color: color-mix(in srgb, var(--line) 60%, var(--accent) 40%);
}

.xlr8-loading-shell {
  position: relative;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.xlr8-loading-shell .xlr8-back {
  position: absolute;
  top: 8px;
  left: 9px;
}

@media (max-width: 480px) {
  .xlr8-shell {
    --xlr8-cell-width: 92px;
    --xlr8-row-height: 29px;
    --xlr8-row-header-width: 43px;
    --xlr8-column-header-height: 27px;
  }

  .xlr8-commandbar {
    padding-left: 7px;
    padding-right: 7px;
  }

  .xlr8-entry-row {
    grid-template-columns: 43px minmax(0, 1fr);
  }

  .xlr8-cell {
    padding-inline: 5px;
    font-size: 10.5px;
  }
}
