.tabs-list {
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.active-line-underline {
  opacity: 0;
}

.tab-status.sheet {
  border-radius: 2px;
}

.tab-item.active .tab-status.sheet {
  background: var(--deep);
}

.new-pad-menu {
  position: fixed;
  z-index: 19;
  width: 218px;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 18px 54px #0a17113b, 0 3px #d9d8d1;
}

.dark .new-pad-menu {
  box-shadow: 0 18px 54px #0008, 0 3px #0b100d;
}

.new-pad-menu button {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.new-pad-menu button:hover,
.new-pad-menu button:focus-visible {
  border-color: var(--line);
  outline: 0;
  background: var(--panel);
}

.new-pad-menu button > span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.new-pad-menu strong {
  font-size: 12px;
}

.new-pad-menu small {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-pad-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--acid) 45%, var(--panel));
  color: var(--deep);
  font: 800 13px var(--font-geist-mono), monospace;
}

.new-pad-icon.sheet {
  background: color-mix(in srgb, var(--deep) 15%, var(--panel));
}

.editor-panel.cell-mode {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.sheet-toolbar {
  min-width: 0;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 16px 9px 24px;
  overflow: visible;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.sheet-controls {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.sheet-actions {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.sheet-actions::-webkit-scrollbar {
  display: none;
}

.sheet-actions button,
.sheet-fixed-actions > .theme-button,
.sheet-fixed-actions > .settings-wrap > .settings-button,
.sheet-result button {
  min-height: 34px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.sheet-actions button:hover,
.sheet-actions button:focus-visible,
.sheet-fixed-actions > .theme-button:hover,
.sheet-fixed-actions > .theme-button:focus-visible,
.sheet-fixed-actions > .settings-wrap > .settings-button:hover,
.sheet-fixed-actions > .settings-wrap > .settings-button:focus-visible,
.sheet-result button:hover,
.sheet-result button:focus-visible {
  border-color: var(--line);
  outline: 0;
  background: var(--paper);
  color: var(--ink);
}

.sheet-fixed-actions {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sheet-fixed-actions .theme-button,
.sheet-fixed-actions .settings-button {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  border-color: var(--line);
}

.sheet-fixed-actions .theme-button {
  font-size: 0;
  line-height: 0;
}

.sheet-fixed-actions .theme-button::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 17px;
  height: 17px;
  transform: translate(-50%, -50%);
  background: var(--theme-button-symbol) center / contain no-repeat;
  content: "";
}

.sheet-fixed-actions .settings-heading button {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  font-size: 17px;
}

.sheet-fixed-actions .reset-settings {
  justify-self: start;
  padding: 7px 9px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.sheet-fixed-actions .reset-settings:hover,
.sheet-fixed-actions .reset-settings:focus-visible {
  color: var(--ink);
}

.sheet-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: color-mix(in srgb, var(--muted) 58%, var(--panel)) var(--panel);
  scrollbar-width: thin;
  background: var(--panel);
}

.sheet-viewport::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.sheet-viewport::-webkit-scrollbar-track {
  background: var(--panel);
}

.sheet-viewport::-webkit-scrollbar-thumb {
  border: 3px solid var(--panel);
  border-radius: 99px;
  background: color-mix(in srgb, var(--muted) 58%, var(--panel));
}

.sheet-grid {
  position: relative;
  width: max-content;
  min-width: 100%;
  display: grid;
  grid-template-columns: var(--row-header-width, 54px) repeat(var(--column-count), var(--cell-width, 140px));
  grid-auto-rows: var(--cell-height, 30px);
}

.corner,
.column-header,
.row-header {
  position: sticky;
  z-index: 4;
  display: grid;
  place-items: center;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 68%, var(--panel));
  color: var(--muted);
  font: 700 var(--cell-header-size, 15px) var(--font-geist-mono), monospace;
  cursor: pointer;
  user-select: none;
}

.corner { z-index: 6; top: 0; left: 0; cursor: default; }
.column-header { top: 0; }
.row-header { left: 0; }

.column-header:hover,
.row-header:hover,
.column-header.selected,
.row-header.selected {
  background: color-mix(in srgb, var(--acid) 30%, var(--panel));
  color: var(--deep);
}

.cell-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.cell-wrap.selected {
  background: color-mix(in srgb, var(--acid) 25%, var(--panel));
}

.cell-wrap.active { z-index: 3; }
.cell-wrap.active::after {
  position: absolute;
  z-index: 3;
  inset: -1px;
  border: 2px solid var(--deep);
  content: "";
  pointer-events: none;
}

.cell-input {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  padding: 0 9px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: 500 12px var(--font-geist-mono), monospace;
  letter-spacing: var(--cell-letter-spacing, 1px);
}

.cell-input.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sheet-statusbar {
  min-width: 0;
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 32px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 700px) {
  .sheet-statusbar {
    min-height: 52px;
    gap: 8px;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  }
}

.sheet-statusbar > button {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px 8px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.sheet-statusbar > button:hover {
  background: var(--paper);
}

.sheet-statusbar > button:disabled {
  opacity: .4;
  cursor: default;
}

.sheet-result {
  min-width: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.sheet-result strong {
  max-width: 180px;
  overflow: hidden;
  color: var(--ink);
  font: 750 12px var(--font-geist-mono), monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-result button {
  min-height: 29px;
  border-color: var(--line);
}

@media (max-width: 820px) {
  .sheet-toolbar {
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
  }

  .sheet-statusbar {
    flex-wrap: wrap;
  }

  .sheet-result {
    width: 100%;
    margin-left: 0;
    padding: 7px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 520px) {
  :root {
    --cell-width: 124px;
    --row-header-width: 46px;
  }

  .sheet-statusbar .shortcut-label {
    display: none;
  }
}

@media (max-width: 480px) {
  .sheet-toolbar {
    min-height: 82px;
    flex-wrap: wrap;
    align-content: center;
    gap: 4px;
    padding: 7px 8px 6px;
    overflow: visible;
  }

  .sheet-controls {
    order: 1;
    flex: 0 0 100%;
    width: 100%;
  }
}

@media (max-width: 450px) {
  .sheet-statusbar {
    gap: 6px;
    padding-right: 8px;
    padding-left: 8px;
  }
}

@media (max-width: 360px) {
  .sheet-statusbar {
    gap: 2px;
    padding-right: 6px;
    padding-left: 6px;
  }
}
