.work, .workspace-floating {
  --paper: #f5f8f7;
  --grid-paper: #f8faf9;
  --rail-paper: #f3f7f5;
  --radius: 7px;
}

.work {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 26rem;
  min-width: 0;
  font-size: 14px;
  line-height: 1.45;
  background: var(--surface);
}

.qlark-icon {
  display: inline-block;
  flex: none;
  vertical-align: middle;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: none;
  gap: 12px;
  min-height: 60px;
  padding: 2px 14px 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.workspace-identity,
.workspace-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.workspace-identity { flex: 1; }
.workspace-head-actions { align-self: stretch; flex: 0 1 auto; }
.workspace-heading { min-width: 0; padding-bottom: 4px; }

.workspace-title-line {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: .9rem;
}

.workspace-header h1 {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  font-size: 1.07rem;
  line-height: 1.25;
  font-weight: 725;
  letter-spacing: -.025em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.workspace-title-text,
.workspace-title-line > h1 > span {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.workspace-title-line button,
.workspace-title-line a,
.workspace-header .table-tab,
.workspace-header .table-action,
.workspace-header .table-overflow,
.workspace-account,
.workspace-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
}

.workspace-back {
  flex: none;
  width: 32px;
  padding: 0;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius);
}

.workspace-back:hover,
.workspace-back:focus-visible { background: var(--rail-paper); color: var(--ink); }

.workspace-caption {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
  margin-top: 3px;
  padding: 0;
  min-height: 15px;
  color: var(--muted);
  white-space: nowrap;
  font-size: 12px;
}

.workspace-caption > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-caption time { flex: none; margin-inline-start: 4px; padding-inline-start: 8px; border-inline-start: 1px solid var(--line); }
.workspace-title-line .workspace-share {
  flex: none;
  min-height: 28px;
  padding: 0 .48rem;
  font-size: .8rem;
  color: var(--brand-hover);
  background: var(--brand-soft);
  border-color: var(--brand-stroke);
  white-space: nowrap;
}

.workspace-header .table-tabs {
  display: flex;
  align-items: end;
  align-self: end;
  justify-content: end;
  min-width: 0;
  gap: 4px;
  margin-bottom: -1px;
}

.workspace-header .table-slot {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 172px;
  color: var(--muted);
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 7px 7px 0 0;
}

.workspace-header .table-slot:hover { background: var(--paper); }

.workspace-header .table-slot[data-renaming] {
  flex: 0 1 auto;
  width: clamp(125px, 45vw, 222px);
  max-width: none;
}
.workspace-header .table-inline-name {
  flex: 1;
  flex-wrap: nowrap;
  min-width: 0;
}
.workspace-header .table-inline-name input {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
}
.workspace-header .table-inline-name button {
  flex: 0 0 24px;
  min-width: 24px;
  padding-inline: 0;
}

.workspace-header .table-slot.active {
  border-color: var(--brand-stroke);
  color: var(--brand-hover);
  background: var(--brand-soft);
}

.workspace-header .table-slot .table-tab {
  flex: 0 1 auto;
  justify-content: start;
  max-width: 100%;
  min-width: 0;
  padding: 0 7px;
  border: 0;
  color: inherit;
  background: none;
  text-decoration: none;
  font-weight: 610;
}

.table-tab > span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.workspace-header .table-action { width: 29px; min-height: 30px; flex: none; padding: 0; }
.workspace-header .table-overflow { flex: none; max-width: min(40vw, 16rem); padding: 0 6px; color: var(--muted); border-color: transparent; background: none; }
.workspace-header .table-overflow:hover { color: var(--ink); background: var(--rail-paper); }
.workspace-header .table-overflow.has-current-table {
  color: var(--brand-hover);
  background: var(--brand-soft);
  border-color: var(--brand-stroke);
}
.table-overflow-label { flex: none; }
.table-overflow-current {
  min-width: 0;
  padding-inline-start: 5px;
  border-inline-start: 1px solid var(--brand-stroke);
  font-weight: 610;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workspace-header .overflow-compact-only { display: none; }

.workspace-account {
  flex: none;
  align-self: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  color: var(--brand-hover);
  background: var(--brand-soft);
  font-weight: 720;
}

.workspace-account .cloud-account-name,
.workspace-account .cloud-account-trigger > svg { display: none; }
.workspace-account .cloud-account-trigger { padding: 0; border: 0; background: transparent; }
.workspace-account .cloud-account-options { inset-inline: 0 auto; }
.workspace-title-line .workspace-title-button {
  max-width: 100%;
  min-width: 0;
  min-height: 25px;
  padding: 0 1px;
  border: 0;
  font-weight: inherit;
}
.workspace-title-button > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.workspace-title-button > svg { color: var(--muted); }

.workspace-tools {
  display: flex;
  position: relative;
  flex: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-height: 52px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.workspace-tools .view-toolbar,
.workspace-tools .toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
}

.workspace-tools .view-toolbar { flex: 1 1 auto; justify-content: flex-start; }
.workspace-tools .toolbar { flex: 0 1 auto; margin-inline-start: auto; }
.workspace-tools .view-alert { flex-basis: 100%; font-size: 12px; }
.workspace-tools .view-persist { margin-inline-start: 2rem; }
.workspace-tools .view-persist:empty { display: none; }
.workspace-tools .view-controls,
.workspace-tools .view-persist,
.workspace-tools .toolbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }

.workspace-tools button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 8px;
  font-size: 13px;
  white-space: nowrap;
}

.workspace-tools .view-controls button,
.workspace-tools .toolbar-actions .quiet { border-color: transparent; color: var(--muted); background: transparent; }
.workspace-tools .view-controls button:hover:not(:disabled),
.workspace-tools .toolbar-actions .quiet:hover:not(:disabled) { background: var(--paper); color: var(--ink); }
.workspace-tools .view-controls .view-enabled,
.workspace-tools .view-controls [aria-expanded="true"] {
  color: var(--brand-hover);
  border-color: var(--brand-stroke);
  background: var(--brand-soft);
}

.view-condition-count {
  min-width: 16px;
  padding: 0 3px;
  border-radius: 4px;
  color: var(--brand-hover);
  background: #d4ebe4;
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.workspace-tools .view-text-action { color: var(--muted); font-size: .85rem; }
.workspace-tools .view-text-action[data-view-action="save"] { color: var(--brand); }
.workspace-tools .view-text-action:hover:not(:disabled) { color: var(--brand-hover); background: var(--brand-soft); }
.workspace-search-trigger { flex: none; }
.workspace-search-popover { width: min(23rem, calc(100vw - 2rem)); }
.workspace-search-popover input[type="search"] { width: 100%; }
.workspace-search-line,
.floating-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-block: 6px;
}
.workspace-tools .toolbar-actions .view-enabled {
  background: var(--brand-soft);
  color: var(--brand-hover);
}
.workspace-tools .toolbar-actions .icon-button { width: 34px; padding-inline: 0; }
.workspace-tools .toolbar-actions .toolbar-create {
  color: var(--brand-hover);
  border-color: var(--brand-stroke);
  background: var(--brand-soft);
  font-weight: 680;
}
.workspace-tools .toolbar-actions .toolbar-create:hover:not(:disabled) {
  color: var(--brand-hover);
  background: #d2eae0;
}

@media (min-width: 651px) {
  .workspace-tools [data-new-record] { position: relative; margin-inline-start: 5px; }
  .workspace-tools [data-new-record]::before {
    content: "";
    position: absolute;
    inset-block: 6px;
    inset-inline-start: -6px;
    border-inline-start: 1px solid var(--line);
    pointer-events: none;
  }
}

.table-switch-menu { width: min(18rem, calc(100vw - 16px)); }
.table-switch-menu h2 { font-size: 14px; margin-bottom: 4px; }
.table-switch-menu .floating-search input { flex: 1 1 auto; width: 0; }
.table-create-directory {
  min-width: 0;
  padding-block-start: 10px;
  border-top: 1px solid var(--line);
}
.table-create-directory h3 { font-size: 13px; margin: 0 0 5px; }
.table-create-directory .all-table-list { max-height: min(36vh, 260px); }
.all-table-list > li {
  display: flex;
  align-items: center;
  gap: 3px;
  padding-block: 2px;
}
.all-table-list .table-directory-pick, .height-options button {
  display: flex;
  align-items: center;
  gap: 7px;
  justify-content: start;
}
.all-table-list .table-directory-pick {
  flex: 1;
  min-width: 0;
  min-height: 30px;
  margin: 0;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 560;
}
.table-directory-pick:where(button):hover:not(:disabled) { background: var(--paper); }
.all-table-list .table-directory-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.all-table-list .active-table { border-color: var(--brand-stroke); }
.all-table-list .table-directory-actions {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  min-height: 30px;
  margin: 0;
  padding: 0;
  color: var(--muted);
}
.all-table-list .table-inline-name { flex: 1; min-width: 0; }
.all-table-list .table-inline-name input { flex: 1 1 auto; width: 0; }
.all-table-list .table-inline-name button { flex: 0 0 28px; margin: 0; }

.directory-order-hint {
  font-size: .78rem;
  font-weight: 500;
  margin: 0 0 5px;
}
button.directory-order-handle {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 30px;
  min-height: 30px;
  margin: 0;
  padding: 0;
  border-radius: 5px;
  color: var(--muted);
  cursor: grab;
}
button.directory-order-handle:active { cursor: grabbing; }
button.directory-order-handle > svg { pointer-events: none; }
[data-directory-dragging] { opacity: .58; }
[data-directory-drop="before"] { box-shadow: 0 2px 0 inset var(--brand); }
[data-directory-drop="after"] { box-shadow: 0 -2px 0 inset var(--brand); }
.workspace-floating.directory-order-menu { padding: 4px; width: 6.25rem; }
.directory-order-actions { display: grid; gap: 2px; }
.directory-order-actions > button { min-height: 30px; padding: 3px 8px; text-align: start; }
.height-options { display: grid; gap: 2px; margin-top: 4px; }
.height-options button > span { flex: 1; }
.height-options button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-hover); }

@media (max-width: 950px) {
  .workspace-header .overflow-compact-only { display: inline-flex; }
}

@media (max-width: 650px) {
  .workspace-header { flex-direction: row; align-items: center; padding: 3px 8px 0; gap: 6px; }
  .workspace-identity,
  .workspace-head-actions,
  .workspace-title-line { gap: .65rem; }
  .workspace-header h1 { font-size: 15px; }
  .workspace-header .table-tabs { align-self: center; margin-bottom: 0; gap: 3px; }
  .workspace-header .table-slot:not([data-renaming]) { max-width: 114px; border-radius: var(--radius); }
  .workspace-header .table-slot .table-tab { gap: 4px; padding: 0 4px; }
  .workspace-header .table-action { width: 23px; }
  .workspace-caption time { display: none; }
  .workspace-back { width: 28px; }
  .workspace-account { width: 28px; height: 28px; min-height: 28px; }
  .workspace-tools { gap: 3px 6px; min-height: 45px; padding: 5px 7px; }
  .workspace-tools .view-toolbar { flex: 1 1 auto; }
  .workspace-tools .view-persist { margin-inline-start: .9rem; }
  .workspace-tools button { gap: 4px; min-height: 34px; padding-inline: 6px; font-size: 13px; }
}

@media (max-width: 500px) {
  .workspace-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 6px 9px 0;
  }
  .workspace-identity { flex: none; }
  .workspace-head-actions { justify-content: end; align-self: stretch; }
  .workspace-header .table-tabs { align-self: end; max-width: 100%; margin-bottom: -1px; }
  .workspace-header .table-slot:not([data-renaming]) {
    max-width: min(55vw, 12rem);
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .workspace-title-line { gap: .55rem; }
}

@media (max-width: 420px) {
  .workspace-header .table-overflow:not(.has-current-table) > .table-overflow-label,
  .workspace-header .table-overflow:not(.has-current-table) > svg:last-child,
  .workspace-header .table-overflow.has-current-table > svg:first-child,
  .workspace-header .table-tabs:has(.table-slot:nth-child(3)) .table-tab > svg { display: none; }
}

.workspace-floating {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 11px;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow: auto;
  overscroll-behavior: contain;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--control-line);
  border-radius: 9px;
  box-shadow: 0 10px 28px #1a332824, 0 2px 5px #1a33280b;
}

button.cell-tool-trigger,
.grid button.cell-tool-trigger {
  display: flex;
  align-items: center;
  justify-content: start;
  gap: 5px;
  min-width: 0;
  min-height: 31px;
  width: 100%;
  padding: 3px 5px;
  color: var(--muted);
  text-align: start;
}

.cell-tool-placeholder,
.cell-tool-value,
.cell-tool-chip {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cell-tool-placeholder,
.cell-tool-value { flex: 1; }
.cell-tool-value { display: flex; align-items: center; gap: 4px; color: var(--ink); }

.cell-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 1 auto;
  max-width: 100%;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--option-color, color-mix(in srgb, var(--chip-color, var(--brand)) 13%, var(--surface)));
  color: var(--option-ink, var(--ink));
}

.cell-tool-chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.cell-tool-chip::before {
  flex: none;
  width: 5px;
  height: 5px;
  content: "";
  border-radius: 50%;
  background: var(--chip-color, var(--brand));
}
.cell-tool-chip[data-option-color]::before { display: none; }

.cell-tool-more { flex: none; color: var(--muted); font-size: .6875rem; font-variant-numeric: tabular-nums; }
.cell-tool-popover { font-size: .8125rem; line-height: 1.45; }
.cell-choice-popover { width: min(16.25rem, calc(100vw - 16px)); }
.cell-calendar-popover { width: min(17.5rem, calc(100vw - 16px)); }

.cell-tool-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-inline: 7px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.cell-tool-search input[type="search"] {
  flex: 1;
  min-width: 0;
  min-height: 31px;
  padding: 4px 0;
  border: none;
  outline: none;
  border-radius: 0;
  background: transparent;
}

.cell-tool-search:focus-within { outline: 2px solid var(--brand); outline-offset: -1px; }

.cell-choice-list {
  display: grid;
  align-content: start;
  gap: 2px;
  margin-block-start: 6px;
  max-height: min(38dvh, 210px);
  overflow-y: auto;
}

.cell-choice-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
  min-height: 31px;
  padding: 3px 5px;
  text-align: start;
}

.cell-choice-item[data-current],
.cell-choice-item:hover,
.cell-calendar-day:hover { background: var(--paper); }

.cell-choice-item[data-current] { box-shadow: inset 2px 0 var(--brand); }
.cell-choice-item[aria-selected="true"] { background: color-mix(in srgb, var(--brand-soft) 72%, var(--surface)); }
.cell-choice-item:disabled { opacity: .62; }
.cell-choice-item[aria-selected="true"],
.cell-tool-check { color: var(--brand); }

.cell-tool-status,
.cell-tool-empty {
  margin: 4px 0;
  padding: 3px 4px;
  color: var(--muted);
  font-size: 12px;
}

.cell-tool-status { color: var(--danger); }
.cell-tool-footer {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  margin-block-start: 7px;
  padding-block-start: 5px;
  border-top: 1px solid var(--line);
}

.cell-tool-footer .cell-tool-link {
  min-height: 28px;
  padding: 2px 6px;
  color: var(--brand);
}
.cell-tool-footer .cell-tool-link:last-child { font-weight: 650; }

.cell-calendar-popover > input { width: 100%; min-height: 31px; }
.cell-calendar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block: 6px 4px;
}

.cell-calendar-heading button { width: 29px; min-height: 29px; padding: 0; }
.cell-calendar-weekdays,
.cell-calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  text-align: center;
}

.cell-calendar-weekdays { padding: 3px 0; color: var(--muted); font-size: 12px; }
.cell-calendar-days { gap: 2px; }
.cell-calendar-days button {
  min-width: 0;
  min-height: 30px;
  padding: 0;
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
}

.cell-calendar-day[data-adjacent] { color: var(--muted); }
.cell-calendar-day[aria-current="date"] { border-color: var(--brand-stroke, var(--line)); font-weight: 700; }
.cell-calendar-day[aria-pressed="true"] { color: white; background: var(--brand); }
.cell-calendar-day[aria-pressed="true"]:hover { background: var(--brand-hover); }
.cell-calendar-day:focus-visible { outline-offset: -2px; }

@media (max-width: 440px) {
  button.cell-tool-trigger, .grid button.cell-tool-trigger { min-height: 29px; }
  button.cell-tool-trigger > svg:first-child { display: none; }
}

/* Shared color choices for field options and view fill. */
.palette-panel { width: min(20rem, calc(100vw - 16px)); }
.palette-targets { display: flex; gap: .25rem; margin-bottom: .65rem; }
.palette-targets button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand); }
.palette-grid { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: .25rem; }
button.palette-swatch {
  aspect-ratio: 1;
  min-height: 0;
  width: 100%;
  border-radius: .32rem;
  padding: 0;
  background: var(--swatch);
  border: 1px solid #18262016;
}
button.palette-swatch:hover:not(:disabled) { background: var(--swatch); border-color: var(--ink); }
.palette-swatch[aria-pressed="true"] { outline: 2px solid var(--brand); outline-offset: 1px; }
.palette-clear { margin-top: .55rem; }
button.field-color-trigger {
  align-self: center;
  justify-self: center;
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  min-height: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  padding: 0;
  color: var(--option-ink, var(--ink));
  background-color: var(--option-color, var(--paper));
}
button.field-color-trigger:hover:not(:disabled) {
  background-color: var(--option-color, var(--paper));
  border-color: var(--option-color, var(--line));
}
.field-option-editor { display: grid; gap: .4rem; }
.field-option-line { display: grid; align-items: center; grid-template-columns: 2.2rem minmax(0, 1fr) auto; gap: .4rem; }
.field-option-editor > button { justify-self: start; color: var(--brand); }
.numbering-host, .numbering-editor { display: grid; gap: .55rem; min-width: 0; }
.numbering-preview-line { display: flex; align-items: baseline; gap: 1rem; padding: .55rem .7rem; border-radius: .45rem; background: var(--paper); }
.numbering-preview-line > span { color: var(--muted); }
.numbering-preview { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.numbering-rule { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr) auto; align-items: center; gap: .35rem; }
.numbering-rule > span { font-size: .86rem; }
.numbering-actions, .numbering-add { display: flex; align-items: center; flex-wrap: wrap; }
.numbering-actions button { min-height: 31px; padding: 0 .3rem; }
.numbering-add button { min-height: 32px; color: var(--brand); }
.grid thead th[data-header-field][style*="--grid-fill"],
.grid tbody tr:not(.editing) .grid-data-cell[style*="--grid-fill"] { background: var(--grid-fill); }
.grid tbody tr[aria-selected="true"]:not(.editing) .grid-data-cell[style*="--grid-fill"] {
  background: color-mix(in srgb, var(--grid-fill) 76%, var(--brand-soft));
}
.grid .cell-generated-number { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
