:root {
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  color: #213b37;
  background: #f3f6f4;
  font-size: 14px;
  --green: #236b59;
  --line: #dbe4df;
}
.editing-cell {
  padding: 4px;
  overflow: visible;
  white-space: normal;
  vertical-align: top;
  box-shadow: inset 0 0 0 2px #428569;
}
.cell-editor {
  min-width: 160px;
  max-width: 100%;
  cursor: auto;
  user-select: text;
}
.cell-editor-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding-bottom: 4px;
}
.cell-editor-controls select {
  flex: 1;
  min-width: 0;
  width: 80px;
  padding: 2px 4px;
  font-size: 11px;
}
.cell-editor-controls button {
  padding: 1px 7px;
  font-size: 14px;
  line-height: 20px;
}
.cell-editor textarea {
  display: block;
  width: 100%;
  min-height: 36px;
  max-height: 200px;
  resize: vertical;
  padding: 5px;
  font:
    13px/1.6 Consolas,
    'Microsoft YaHei',
    monospace;
  user-select: text;
  white-space: pre;
}
.cell-editor small {
  display: block;
  font-size: 10px;
  line-height: 1.5;
  color: #73877a;
  white-space: normal;
  padding-top: 3px;
}
.cell-editor .cell-editor-error {
  color: #b14137;
  font-size: 11px;
}
.cell-editor .cell-editor-error:empty {
  display: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 7px 12px;
  color: inherit;
  white-space: nowrap;
}
button:hover {
  background: #edf5f0;
  border-color: #98b6a6;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.primary:hover {
  background: #185544;
  color: #fff;
}
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 9px;
  background: white;
  color: inherit;
}
input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid #69aa90;
  outline-offset: 1px;
}
[hidden] {
  display: none !important;
}
header {
  height: 62px;
  flex-shrink: 0;
  padding: 0 28px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
}
.mark {
  background: var(--green);
  color: #fff;
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 24px;
}
.badge {
  font-size: 11px;
  background: #ecf4ef;
  color: #537b66;
  padding: 3px 7px;
  border-radius: 4px;
}
.local {
  font-size: 12px;
  color: #5c7a68;
}
.local a {
  margin-left: 18px;
  color: #4f7b65;
  text-decoration: none;
}
.toolbar,
.tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.toolbar {
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.separator {
  height: 20px;
  width: 1px;
  background: var(--line);
  margin: 0 4px;
}
.spacer {
  flex: 1;
}
main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 28px 16px;
}
.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  color: #708d7c;
  margin-bottom: 8px;
}
h1 {
  font-size: 24px;
  line-height: 1.3;
  margin: 0;
  max-width: 65vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
p {
  line-height: 1.6;
}
.intro p {
  color: #728078;
  margin: 8px 0 0;
  font-size: 12px;
}
.tabs {
  display: flex;
  background: #e5ede7;
  border-radius: 8px;
  padding: 4px;
}
.tabs button {
  border: 0;
  background: none;
  min-width: 85px;
}
.tabs [aria-selected='true'] {
  background: #fff;
  box-shadow: 0 1px 5px #234c3620;
  color: var(--green);
  font-weight: 600;
}
.tools {
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}
.tools label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #64776d;
}
.tools input {
  width: 180px;
}
.tools select {
  max-width: 180px;
}
.secondary {
  border-radius: 0;
  background: #fafcfb;
  padding: 8px 12px;
  font-size: 12px;
}
.secondary button {
  font-size: 12px;
  padding: 6px 9px;
}
#tableview,
#sourceview {
  position: relative;
  flex: 1;
  min-height: 120px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}
#grid {
  height: 100%;
  overflow: auto;
  position: relative;
  outline: none;
}
table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}
th,
td {
  padding: 9px 12px;
  border-right: 1px solid #e5ebe7;
  border-bottom: 1px solid #e5ebe7;
  min-width: 48px;
  width: 180px;
  height: 36px;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  user-select: none;
}
th {
  position: sticky;
  top: 0;
  background: #f2f6f3;
  z-index: 2;
  color: #5c7165;
  font-weight: 500;
  overflow: hidden;
  text-align: left;
}
th:first-child {
  z-index: 3;
  background: #d6eae0;
  color: #1c5342;
  font-weight: 700;
  border-right: 2px solid #b5d3c3;
}
th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  min-width: 52px;
  width: 52px;
  max-width: 52px;
  text-align: center;
  font-size: 11px;
  z-index: 1;
}
td:first-child {
  background: #e5f2eb;
  color: #23614d;
  font-family: Consolas, monospace;
  font-weight: 600;
  border-right: 2px solid #bfdace;
}
td[data-cell][data-type='string'],
td[data-cell][data-type='text'] {
  background: #f4f8fd;
  color: #203b4d;
}
td[data-cell][data-type='number'],
td[data-cell][data-type='integer'],
td[data-cell][data-type='real'] {
  background: #eefaf3;
  color: #185a3d;
  font-family: Consolas, 'Microsoft YaHei', monospace;
}
td[data-cell][data-type='boolean'],
td[data-cell][data-type='text'][data-value-kind='boolean'] {
  background: #fef8e7;
  color: #8a5210;
  font-weight: 600;
}
td[data-cell][data-type='date'],
td[data-cell][data-type='text'][data-value-kind='date'] {
  background: #edf9fb;
  color: #195d6b;
  font-family: Consolas, 'Microsoft YaHei', monospace;
}
td[data-cell][data-type='null'],
td[data-cell][data-type='empty'],
td[data-cell][data-type='blank'],
td[data-cell][data-type='text'][data-value-kind='empty'] {
  background: #f5f6f7;
  color: #938881;
  font-style: italic;
}
td[data-cell][data-type='blob'] {
  background: #f6f2fc;
  color: #6b4999;
  font-family: Consolas, monospace;
}
td[data-cell][data-type='formula'] {
  background: #fcf4ea;
  color: #78521a;
}
td[data-cell][data-type='error'] {
  background: #fdf0f0;
  color: #b43232;
  font-weight: 600;
}
.type-legend {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}
.type-legend [data-swatch] {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.4;
  border: 1px solid #d8e3dd;
}
.type-legend [data-swatch='index'] {
  background: #e5f2eb;
  color: #23614d;
  border-color: #bfdace;
  font-family: Consolas, 'Microsoft YaHei', monospace;
  font-weight: 600;
}
.type-legend [data-swatch='string'] {
  background: #f4f8fd;
  color: #24507e;
  border-color: #d5e4f7;
}
.type-legend [data-swatch='number'] {
  background: #eefaf3;
  color: #185a3d;
  border-color: #ccecd9;
}
.type-legend [data-swatch='boolean'] {
  background: #fef8e7;
  color: #8a5210;
  border-color: #f3dfb0;
}
.type-legend [data-swatch='date'] {
  background: #edf9fb;
  color: #195d6b;
  border-color: #c8e9ef;
}
.type-legend [data-swatch='null'] {
  background: #f5f6f7;
  color: #6e7584;
  border-color: #dfe1e7;
}
.type-legend [data-swatch='blob'] {
  background: #f6f2fc;
  color: #6b4999;
  border-color: #e2d5f5;
}
.type-legend [data-swatch='formula'] {
  background: #fcf4ea;
  color: #78521a;
  border-color: #edd7bc;
}
.selected {
  background: #d8eee2 !important;
  box-shadow: inset 0 0 0 1px #67a283;
}
.changed:after {
  content: '•';
  color: #bb8136;
  margin-left: 6px;
}
.added:after {
  content: '+';
  color: #236b59;
  margin-left: 6px;
}
.found {
  background: #fff0be !important;
}
.active-cell {
  outline: 2px solid #428569;
  outline-offset: -2px;
}
.empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #6d8174;
  pointer-events: none;
}
.empty-icon {
  font-size: 52px;
  color: #9fb8a9;
}
.empty h2 {
  font-size: 18px;
  font-weight: 500;
  margin: 12px 0 0;
}
.empty p {
  margin: 8px;
}
.muted {
  font-size: 12px;
  color: #91a296;
}
#notice {
  margin: 0;
  padding: 8px 12px;
  background: #fff6df;
  color: #805c18;
  border: 1px solid #ecd8a6;
  font-size: 12px;
}
footer {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 9px 28px;
  font-size: 11px;
  background: #fff;
  border-top: 1px solid var(--line);
  color: #718478;
}
#sourceeditor {
  height: 100%;
  overflow: hidden;
}
.cm-editor {
  font-size: 13px;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 80px #163c3033;
  width: min(720px, 92vw);
  max-height: 85vh;
  padding: 22px;
}
dialog::backdrop {
  background: #163c3033;
}
.dialoghead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: move;
  user-select: none;
  touch-action: none;
}
.dialoghead h2 {
  font-size: 18px;
  margin: 0;
}
.dialoghead button {
  border: 0;
  font-size: 20px;
  cursor: pointer;
}
.dialogactions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
#dialogbody {
  margin-top: 16px;
  max-height: 57vh;
  overflow: auto;
}
#dialogbody label {
  display: block;
  margin: 12px 0 6px;
}
#dialogbody label input[type='checkbox'] {
  width: auto;
}
#dialogbody input:not([type='checkbox']),
#dialogbody textarea,
#dialogbody select {
  width: 100%;
}
#dialogbody textarea {
  min-height: 180px;
  resize: vertical;
  font-family: Consolas, monospace;
}
#dialogerror {
  color: #b14137;
  font-size: 12px;
  white-space: pre-wrap;
}
.preview {
  font:
    12px/1.7 Consolas,
    monospace;
  white-space: pre-wrap;
  background: #f4f7f5;
  padding: 12px;
  border-radius: 6px;
  max-height: 220px;
  overflow: auto;
}
#selectionstatus {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 900px) {
  header,
  .toolbar {
    padding-left: 16px;
    padding-right: 16px;
  }
  main {
    padding: 16px;
  }
  .tools input {
    width: 130px;
  }
  .local {
    display: none;
  }
  .intro {
    gap: 8px;
  }
  h1 {
    font-size: 20px;
  }
  .toolbar {
    gap: 6px;
  }
  footer {
    padding: 8px 16px;
  }
}

/* Compact high-density layout for CSV / SQLite / Excel editors */
header {
  height: 42px;
  padding: 0 16px;
}
.brand {
  gap: 8px;
  font-size: 15px;
}
.mark {
  padding: 2px 7px;
  font-size: 16px;
  border-radius: 6px;
}
.badge {
  font-size: 10px;
  padding: 2px 6px;
}
.toolbar {
  padding: 6px 16px;
  gap: 6px;
}
.toolbar button {
  padding: 5px 10px;
  font-size: 12px;
}
main {
  padding: 8px 14px 6px;
}
.intro {
  margin-bottom: 6px;
  gap: 12px;
  min-height: 30px;
}
.intro .eyebrow {
  display: none;
}
.intro > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}
.intro h1 {
  font-size: 14px;
  line-height: 1.3;
}
.intro p {
  margin: 0;
  font-size: 12px;
}
.tabs {
  padding: 2px;
  border-radius: 6px;
  flex-shrink: 0;
}
.tabs button {
  padding: 4px 10px;
  font-size: 12px;
  min-width: 64px;
}
.tools {
  padding: 6px 10px;
  gap: 6px;
}
.tools button,
.tools input,
.tools select {
  padding: 4px 8px;
  font-size: 12px;
}
.secondary {
  padding: 5px 10px;
}
.secondary button {
  padding: 4px 8px;
}
th,
td {
  padding: 6px 10px;
  height: 32px;
}
footer {
  height: 28px;
  min-height: 28px;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
footer .type-legend {
  gap: 4px;
  margin-left: auto;
}
footer .type-legend [data-swatch] {
  padding: 1px 5px;
  font-size: 10px;
  line-height: 1.3;
}
header .local {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  font-size: 12px;
  color: #5c7a68;
}
header .local a {
  margin-left: 0;
  white-space: nowrap;
}
header .language-picker {
  height: 26px;
  padding: 2px 6px;
  margin-left: 4px;
  flex-shrink: 0;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
