.mrc-table-editor {
  --mte-bg: var(--bg, #f4f5f7);
  --mte-panel: var(--panel, #fff);
  --mte-text: var(--text, #202124);
  --mte-muted: var(--muted, #687078);
  --mte-border: var(--border, #d7dbe0);
  --mte-primary: #2271b1;
  --mte-primary-hover: #135e96;
  box-sizing: border-box;
  color: var(--mte-text);
  color-scheme: light;
  font: 400 14px/1.45 "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 16px auto;
  max-width: 920px;
  min-width: 0;
}

.mrc-table-editor *, .mrc-table-editor *::before, .mrc-table-editor *::after { box-sizing: border-box; }
.mrc-table-editor .mte-panel {
  min-width: 0;
  margin: 0 0 16px;
  padding: 16px;
  background: var(--mte-panel);
  border: 1px solid var(--mte-border);
  border-radius: 12px;
}
.mrc-table-editor .mte-panel > details + details { margin-top: 12px; }
.mrc-table-editor summary { cursor: pointer; font-weight: 600; }
.mrc-table-editor details[open] > summary { margin-bottom: 10px; }
.mrc-table-editor label {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}
.mrc-table-editor button,
.mrc-table-editor input,
.mrc-table-editor select,
.mrc-table-editor textarea,
.mrc-table-editor .mte-menu summary {
  min-height: 36px;
  margin: 0;
  padding: 6px 9px;
  border: 1px solid var(--mte-border);
  border-radius: 7px;
  background: var(--mte-panel);
  color: var(--mte-text);
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  box-shadow: none;
}
.mrc-table-editor button { cursor: pointer; font-weight: 600; }
.mrc-table-editor button:disabled { opacity: .52; cursor: default; }
.mrc-table-editor button:not(:disabled):hover,
.mrc-table-editor .mte-menu summary:hover { background: var(--mte-bg); }
.mrc-table-editor :is(button, summary, input, select, textarea):focus-visible {
  outline: 2px solid var(--mte-primary);
  outline-offset: 2px;
}
.mrc-table-editor button.mte-primary,
.mrc-table-editor button[aria-pressed="true"] {
  border-color: var(--mte-primary);
  background: var(--mte-primary);
  color: #fff;
}
.mrc-table-editor button.mte-primary:hover,
.mrc-table-editor button[aria-pressed="true"]:hover { background: var(--mte-primary-hover); color: #fff; }
.mrc-table-editor textarea {
  width: 100%;
  max-width: 100%;
  resize: vertical;
  font: 400 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.mrc-table-editor input, .mrc-table-editor select { width: 100%; min-width: 0; }
.mrc-table-editor .mte-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-bottom: 10px;
  cursor: pointer;
}
.mrc-table-editor .mte-option input {
  appearance: auto;
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  accent-color: var(--mte-primary);
}
.mrc-table-editor input[type="color"] { padding: 3px; }
.mrc-table-editor small { display: block; color: var(--mte-muted); margin-top: 5px; }
.mrc-table-editor [data-action="import"] { margin-top: 8px; }

.mrc-table-editor .mte-toolbar,
.mrc-table-editor .mte-group,
.mrc-table-editor .mte-actions,
.mrc-table-editor .mte-selection { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mrc-table-editor .mte-toolbar {
  padding: 8px;
  background: var(--mte-bg);
  border: 1px solid var(--mte-border);
  border-radius: 8px;
  gap: 7px 12px;
}
.mrc-table-editor .mte-actions { margin-top: 10px; }
.mrc-table-editor .mte-menu { position: relative; }
.mrc-table-editor .mte-menu summary { line-height: 22px; margin: 0; }
.mrc-table-editor .mte-menu > div {
  position: absolute;
  z-index: 2;
  inset: calc(100% + 4px) auto auto 0;
  width: max-content;
  max-width: min(245px, calc(100vw - 70px));
  display: grid;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--mte-border);
  border-radius: 8px;
  background: var(--mte-panel);
  box-shadow: 0 4px 14px #20212426;
}
.mrc-table-editor .mte-menu button { text-align: left; }
.mrc-table-editor .mte-hint { margin: 12px 0 8px; color: var(--mte-muted); }
.mrc-table-editor .mte-selection { justify-content: space-between; gap: 6px 12px; margin: 0 0 8px; }
.mrc-table-editor .mte-selection output { font-weight: 600; }

.mrc-table-editor .mte-grid {
  max-width: 100%;
  max-height: 58vh;
  overflow: auto;
  border: 1px solid var(--mte-border);
  border-radius: 7px;
  background: #fff;
  color: #202124;
}
.mrc-table-editor .mte-grid table {
  width: 100%;
  max-width: none;
  margin: 0;
  border: 0;
  table-layout: auto;
  font: inherit;
  text-indent: 0;
}
.mrc-table-editor .mte-grid :is(th, td) {
  border: 0;
  padding: 0;
  min-width: 70px;
  word-break: normal;
}
.mrc-table-editor .mte-grid caption { padding: 8px; }
.mrc-table-editor .mte-grid [contenteditable] {
  min-height: 28px;
  padding: 4px;
  outline: none;
  overflow-wrap: anywhere;
  cursor: text;
}
.mrc-table-editor .mte-grid .mte-selected {
  outline: 2px solid var(--mte-primary);
  outline-offset: -2px;
}
.mrc-table-editor .mte-grid [contenteditable]:focus-visible {
  outline: 1px dashed var(--mte-primary);
  outline-offset: -1px;
}
.mrc-table-editor .mte-grid.mte-range-mode [contenteditable] { cursor: crosshair; }
.mrc-table-editor .mte-grid [contenteditable] a { color: #135e96; cursor: text; }

.mrc-table-editor .mte-properties { display: grid; gap: 8px; margin-top: 12px; }
.mrc-table-editor .mte-properties > details { border-top: 1px solid var(--mte-border); padding-top: 8px; }
.mrc-table-editor .mte-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 135px), 1fr));
  align-items: end;
  gap: 8px;
}
.mrc-table-editor .mte-status { color: var(--mte-muted); margin: 10px 0 0; }
.mrc-table-editor .mte-status:empty { display: none; }
.mrc-table-editor .mte-preview {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-height: 210px;
  background: #fff;
  border: 1px solid var(--mte-border);
  border-radius: 7px;
}
@media (max-width: 420px) {
  .mrc-table-editor .mte-panel { padding: 10px; }
  .mrc-table-editor .mte-toolbar { padding: 6px; }
}
