:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --line: #d5dce4;
  --text: #17212b;
  --muted: #667382;
  --accent: #1664d9;
  --accent-soft: #eaf2ff;
  --navy: #163a5f;
  --teal: #0f766e;
  --danger: #b83232;
  --sidebar-width: 252px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select { font: inherit; }

button {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #334155;
  cursor: pointer;
}

button:hover:not(:disabled) { background: #f6f8fa; }
button:disabled { cursor: default; opacity: .5; }

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.primary:hover:not(:disabled) { filter: brightness(.96); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; }
button.wide { width: 100%; }
button.small { padding: 5px 8px; font-size: 12px; }

input,
textarea,
select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: #fff;
  color: var(--text);
}

input:focus,
textarea:focus,
select:focus {
  border-color: #85aff0;
  box-shadow: 0 0 0 3px rgba(22, 100, 217, .09);
}

textarea { resize: vertical; }

label {
  display: block;
  margin: 10px 0 6px;
  color: #4f5b67;
  font-size: 12px;
  font-weight: 700;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.pre-line { white-space: pre-line; }

#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid #dbe3ec;
  background: #f8fafc;
  color: #1e293b;
}

.sidebar-resize-handle {
  position: absolute;
  z-index: 20;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.sidebar-resize-handle::after {
  position: absolute;
  top: 0;
  right: 3px;
  width: 2px;
  height: 100%;
  background: transparent;
  content: "";
  transition: background .12s ease;
}

.sidebar-resize-handle:hover::after,
.sidebar-resize-handle:focus-visible::after,
body.sidebar-resizing .sidebar-resize-handle::after {
  background: #4d91e8;
}

.sidebar-resize-handle:focus-visible { outline: none; }

body.sidebar-resizing {
  cursor: col-resize;
  user-select: none;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.brand-logo-frame {
  position: relative;
  width: min(176px, 100%);
  height: 96px;
  overflow: hidden;
}

.brand-logo {
  position: absolute;
  top: -42px;
  left: 50%;
  display: block;
  width: 176px;
  height: 176px;
  max-width: none;
  transform: translateX(-50%);
}

.section-label {
  margin: 22px 5px 8px;
  color: #64748b;
  font-size: 10px;
  letter-spacing: .12em;
}

.sidebar-create-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.sidebar-create-actions button { padding: 8px 10px; }
.sidebar-create-actions button:last-child {
  border-color: #cbd5e1;
  background: #fff;
  color: #334155;
}

.sidebar-create-actions button:last-child:hover { background: #eef2f7; }

.explorer-hint {
  margin: -3px 5px 8px;
  color: #94a3b8;
  font-size: 9px;
  line-height: 1.4;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}

.project-folder-group {
  position: relative;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
}

.project-folder-header {
  display: flex;
  min-height: 28px;
  align-items: center;
  gap: 2px;
  padding: 2px 3px;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: grab;
}

.project-folder-header:hover { background: #edf2f7; }
.project-folder-header:active { cursor: grabbing; }

.folder-toggle {
  flex: 0 0 20px;
  width: 20px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #64748b;
  font-size: 17px;
  line-height: 1;
}

.folder-toggle:hover:not(:disabled) {
  background: transparent;
  color: #0f172a;
}

.folder-toggle:focus-visible {
  outline: 1px solid #5c9ce6;
  outline-offset: -2px;
  background: transparent;
}

.project-folder-name {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 6px;
  color: #334155;
  cursor: pointer;
  user-select: none;
}

.project-folder-name:has(.folder-name-editor) { cursor: text; }

.project-folder-name strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-icon { color: #d8a743; font-size: 12px; }

.folder-project-count {
  min-width: 19px;
  padding: 2px 5px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #64748b;
  font-size: 9px;
  font-weight: 800;
  text-align: center;
}

.project-folder-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s ease;
}

.project-folder-header:hover .project-folder-actions { opacity: 1; }

.project-folder-actions button {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 13px;
}

.project-folder-actions button:hover { background: #dfe7ef; color: #0f172a; }

.project-folder-projects {
  min-height: 7px;
  padding: 1px 2px 3px 24px;
  border-radius: 4px;
}

.project-folder-children {
  margin-left: 16px;
  border-left: 1px solid #dbe3ec;
  padding-left: 2px;
}

.project-folder-children:empty { display: none; }

.folder-root-drop-zone {
  height: 0;
  margin: 0 2px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 3px;
  transition: height .12s ease, border-color .12s ease, background .12s ease;
}

.project-list.dragging-folder .folder-root-drop-zone {
  height: 25px;
  margin-bottom: 3px;
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.project-list.dragging-folder .folder-root-drop-zone::after {
  display: block;
  color: #64748b;
  font-size: 9px;
  line-height: 23px;
  text-align: center;
  content: "Thả để đưa ra cấp ngoài";
}

.project-list.dragging-folder .folder-root-drop-zone.drop-target {
  border-color: #4d91e8;
  background: rgba(77, 145, 232, .14);
}

.project-list.dragging-folder .folder-root-drop-zone.drop-target::after {
  color: #2563a9;
  content: "Đưa folder ra cấp ngoài";
}
.ungrouped-folder .folder-icon { color: #94a3b8; }
.ungrouped-folder .project-folder-header { cursor: default; }

.folder-name-editor {
  height: 24px;
  min-width: 0;
  padding: 2px 5px;
  border-color: #4d91e8;
  border-radius: 2px;
  background: #fff;
  color: #1e293b;
  font-size: 11px;
  box-shadow: 0 0 0 1px #4d91e8;
}

.folder-create-row { margin-bottom: 2px; }

.folder-empty {
  display: block;
  padding: 8px 7px;
  color: #94a3b8;
  font-size: 10px;
  font-style: italic;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #475569;
  cursor: pointer;
}

.project-item:hover { background: #edf2f7; }
.project-item.active { border-color: #93c5fd; background: #dbeafe; color: #123f73; }
.project-file-icon { flex: 0 0 auto; color: #3b82f6; font-size: 13px; }
.project-item-text { min-width: 0; flex: 1; }
.project-item-text strong,
.project-item-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item-text strong {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 4px;
  color: inherit;
  font-size: 12px;
  font-weight: 600;
}
.project-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item-stats { flex: 0 0 auto; color: #64748b; font-size: 10px; font-weight: 700; }
.project-item.active .project-item-stats { color: #2563a9; }
.project-item-text small { margin-top: 2px; color: #94a3b8; font-size: 9px; }

.project-item.dragging,
.project-folder-group.dragging { opacity: .42; }

.project-folder-group.drop-target {
  border-color: #4d91e8;
  background: rgba(77, 145, 232, .12);
}

.project-folder-group.drop-inside > .project-folder-header {
  border-color: #4d91e8;
  background: rgba(77, 145, 232, .18);
}

.project-folder-group.drop-before::before,
.project-folder-group.drop-after::after {
  position: absolute;
  right: 2px;
  left: 2px;
  z-index: 3;
  height: 2px;
  border-radius: 2px;
  background: #55a5ff;
  content: "";
}

.project-folder-group.drop-before::before { top: -2px; }
.project-folder-group.drop-after::after { bottom: -2px; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 4px 0;
  border-top: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 11px;
}

.main { min-width: 0; }

.empty-state {
  display: grid;
  min-height: 100vh;
  padding: 40px;
  place-content: center;
  text-align: center;
}

.empty-state h1 { margin: 12px 0 6px; }
.empty-state p { max-width: 560px; color: var(--muted); }
.empty-icon { font-size: 44px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
}

.project-topbar-actions {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.project-folder-field {
  min-width: 190px;
  margin: 0;
}

.project-folder-field span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.project-folder-field select {
  height: 36px;
  padding: 6px 30px 6px 9px;
  background: #f8fafc;
  font-size: 12px;
}

.project-identity { min-width: 0; flex: 1; }

.project-name-field,
.project-meta-field {
  display: block;
  margin: 0;
}

.project-name-field > span,
.project-meta-field > span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.project-title {
  width: min(560px, 65vw);
  padding: 2px 5px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 22px;
  font-weight: 800;
}

.project-title:focus,
.project-subline input:focus {
  border-color: #85aff0;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(22, 100, 217, .09);
}

.project-title:hover,
.project-subline input:hover { border-color: #d5dce4; background: #f8fafc; }

.project-subline {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.project-meta-field { width: 190px; }
.project-meta-field.device-id-field { width: 260px; }

.project-subline input {
  padding: 3px 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.document-page {
  display: grid;
  gap: 24px;
  padding: 24px;
}

.project-description-card,
.document-section {
  min-width: 0;
  border: 1px solid #cfd6de;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 28, 40, .06);
}

.project-description-card { padding: 12px 16px 16px; }
.project-description-card label { margin-top: 0; }
.project-description-card textarea { min-height: 78px; }

.document-section { padding: 18px; }

.document-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.document-section-heading > div:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
}

.document-section-heading h2 {
  margin: 0;
  color: #1f2f40;
  font-size: 21px;
}

.section-kicker {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.feature-description-table-wrap,
.json-command-table-wrap {
  overflow: auto;
  border: 1px solid #cfd6de;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  border-right: 1px solid #d9dfe6;
  border-bottom: 1px solid #d9dfe6;
  vertical-align: top;
  text-align: left;
}

th:last-child,
td:last-child { border-right: 0; }
tr:last-child td { border-bottom: 0; }

.feature-description-table {
  min-width: 800px;
  table-layout: fixed;
}

.feature-description-table .col-code { width: 13%; }
.feature-description-table .col-name { width: 25%; }
.feature-description-table .col-description { width: 44%; }
.feature-description-table .col-action { width: 18%; }

.feature-description-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #e9edf2;
  color: #263442;
  font-weight: 800;
}

.feature-summary-row:hover td { background: #f8fbff; }

.editable-table-cell { cursor: text; }

.editable-table-cell:hover {
  box-shadow: inset 0 0 0 2px rgba(22, 100, 217, .24);
}

.editable-table-cell.cell-editing {
  padding: 7px;
  background: #f7faff !important;
  box-shadow: inset 0 0 0 2px rgba(22, 100, 217, .55);
}

.cell-editor {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.cell-editor label {
  display: grid;
  gap: 4px;
  margin: 0;
  font-size: 11px;
}

.cell-editor input,
.cell-editor textarea,
.cell-editor select {
  min-width: 0;
  padding: 7px 8px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
}

.json-command-table .cell-editor textarea {
  min-height: 180px;
  font-family: "Cascadia Code", Consolas, monospace;
  tab-size: 2;
}

.json-command-name .cell-editor textarea {
  min-height: 76px;
  font-family: inherit;
}

.json-field-cell .cell-editor textarea {
  min-height: 112px;
  resize: vertical;
  font-family: inherit;
}

.feature-summary-code {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
}

.feature-command-count {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.table-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.vertical-actions { align-items: stretch; flex-direction: column; }

.inline-feature-row td { background: #f7faff; }
.inline-feature-row input,
.inline-feature-row textarea { min-width: 0; font-size: 12px; }
.inline-feature-row textarea { min-height: 74px; }

.inline-table-error {
  margin-top: 6px;
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
}

.inline-table-error:empty { display: none; }
.table-empty { padding: 38px !important; color: var(--muted); text-align: center; }

.json-section { scroll-margin-top: 110px; }

.json-section-heading { margin-bottom: 10px; }

.json-command-actions {
  width: min(420px, 42vw);
  margin-left: auto;
}

.json-command-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.json-group-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.json-group-actions button { padding: 7px 10px; font-size: 12px; }

.json-command-count {
  margin-left: 4px;
  color: #5b6876;
  font-size: 12px;
  white-space: nowrap;
}

.json-command-table { min-width: 1180px; table-layout: fixed; }
.json-command-table .col-feature { width: 21%; }
.json-command-table .col-request { width: 23%; }
.json-command-table .col-response { width: 23%; }
.json-command-table .col-fields { width: 33%; }

.json-command-table thead th {
  height: 51px;
  padding: 8px 12px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  vertical-align: middle;
}

.json-command-table thead tr:last-child th {
  position: sticky;
  top: 0;
  z-index: 3;
}

.json-command-table .excel-document-title th {
  height: 42px;
  padding: 7px 16px;
  background: var(--navy);
  font-size: 20px;
}

.json-command-table .excel-document-description th {
  height: 54px;
  padding: 9px 16px;
  background: #eaf2f8;
  color: #334155;
  font-weight: 400;
  text-align: left;
}

.json-feature-group td {
  padding: 6px 12px;
  background: #dceaf7;
  color: var(--navy);
  font-size: 14px;
  font-weight: 800;
  vertical-align: middle;
}

.json-feature-group-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.json-feature-group-content.is-collapsible { cursor: pointer; }

.json-feature-group-content small {
  margin-left: auto;
  color: #536b82;
  font-size: 12px;
  font-weight: 400;
}

.json-group-toggle {
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--navy);
  font-size: 17px;
}

.add-command-row-btn {
  padding: 4px 8px;
  border-color: #9fb7cc;
  color: var(--navy);
  font-weight: 700;
}

.json-command-row td {
  min-height: 120px;
  background: #fff;
  line-height: 1.4;
}

.json-command-row:hover td { background: #f8fbfd; }
.json-command-collapsed { display: none; }
.json-command-name { position: relative; }
.json-command-name.has-row-toggle { padding-left: 42px; }
.json-command-name.has-row-toggle.cell-editing { padding-left: 42px; }
.json-command-name strong { display: block; font-weight: 700; }
.json-command-name p { margin: 7px 0 0; color: #596777; font-size: 12px; white-space: pre-line; }

.json-command-summary-row td {
  min-height: 0;
  padding: 8px 10px;
  background: #f8fbfd;
  vertical-align: middle;
}

.json-command-summary-row .json-command-summary-cell {
  position: relative;
  padding: 10px 12px 10px 42px;
}

.json-command-summary-cell > strong { color: #263a50; font-size: 12px; }

.json-command-toggle-label {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color .12s ease, text-decoration-color .12s ease;
}

.json-command-toggle-label:hover {
  color: #0f5fbd;
  text-decoration-color: #77a9dc;
}

.json-command-collapsed-preview {
  display: -webkit-box;
  max-height: 2.9em;
  overflow: hidden;
  color: #506073;
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.json-command-collapsed-preview.is-code {
  color: #334155;
  font-family: "Cascadia Code", Consolas, monospace;
}

.json-command-collapsed-empty { color: #8a96a4; font-size: 11px; }

.json-command-row-toggle {
  position: absolute;
  top: 8px;
  left: 9px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #526578;
  font-size: 17px;
  line-height: 24px;
  text-align: center;
}

.json-command-row-toggle:hover:not(:disabled) { background: transparent; color: var(--accent); }
.json-command-summary-cell .json-command-row-toggle { top: 7px; }

.command-row-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.open-command-btn {
  padding: 3px 7px;
  border-color: #a9d2cd;
  color: var(--teal);
}

.delete-command-row-btn { border-color: #e8b4b4; color: #a12d2d; }

.json-code-cell { position: relative; min-height: 28px; }

.copy-json-btn {
  position: absolute;
  top: -4px;
  right: -5px;
  z-index: 1;
  width: 26px;
  height: 26px;
  padding: 0;
  background: rgba(255, 255, 255, .94);
  color: #475569;
}

.json-table-code {
  margin: 0;
  padding-right: 26px;
  overflow-wrap: anywhere;
  color: #17212b;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.json-field-description {
  position: relative;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
}

.json-field-description.is-collapsed {
  max-height: 132px;
  overflow: hidden;
}

.json-field-description.is-collapsed::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 34px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff 86%);
  content: "";
  pointer-events: none;
}

.json-command-row:hover .json-field-description.is-collapsed::after {
  background: linear-gradient(to bottom, rgba(248, 251, 253, 0), #f8fbfd 86%);
}

.json-field-toggle {
  margin-top: 7px;
  padding: 3px 8px;
  border-color: #a9d2cd;
  background: #fff;
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
}

.excel-empty-value { color: #64748b; }

.inline-command-row td { padding: 10px; background: #f8fafc; }
.inline-command-stack,
.inline-json-label { display: grid; gap: 5px; }
.inline-command-stack { gap: 8px; }

.inline-command-stack label,
.inline-json-label {
  margin: 0;
  color: #405063;
  font-size: 11px;
}

.inline-command-row input,
.inline-command-row textarea,
.inline-command-row select {
  min-width: 0;
  padding: 7px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
}

.inline-command-json {
  min-height: 260px;
  resize: vertical;
  font-family: "Cascadia Code", Consolas, monospace;
  tab-size: 2;
}

.inline-command-actions { display: flex; align-items: center; gap: 7px; }

.excel-document-note td {
  padding: 10px 16px;
  background: #fff7ed;
  color: #7c2d12;
  font-size: 12px;
}

.json-empty { padding: 40px !important; color: var(--muted); text-align: center !important; }

.sequence-section {
  scroll-margin-top: 110px;
  border-color: #dfe2f3;
  background: #fbfbff;
}

.sequence-section .document-section-heading h2 {
  background: linear-gradient(100deg, #1746d1 0%, #7c3aed 76%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.section-description {
  margin: -4px 0 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.sequence-diagram-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.sequence-diagrams-body {
  display: grid;
  gap: 16px;
}

.sequence-feature-group {
  overflow: hidden;
  border: 1px solid #cfd9e3;
  border-radius: 8px;
  background: #f8fafc;
}

.sequence-feature-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  background: #dceaf7;
  color: var(--navy);
}

.sequence-feature-header strong { font-size: 14px; }
.sequence-feature-header span { color: #536b82; font-size: 12px; }

.sequence-command-list {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.sequence-command-card {
  overflow: hidden;
  border: 1px solid #dfe2f3;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(41, 48, 92, .04);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.sequence-command-card:hover {
  border-color: #c5cced;
  box-shadow: 0 8px 24px rgba(52, 60, 120, .08);
  transform: translateY(-1px);
}

.sequence-command-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
}

.sequence-command-header > div:first-child {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sequence-command-code {
  padding: 4px 7px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.sequence-command-name { font-size: 13px; }

.sequence-command-total {
  color: var(--muted);
  font-size: 11px;
}

.sequence-status {
  padding: 3px 6px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #718096;
  font-size: 10px;
}

.sequence-status.has-sequence { background: #dcfce7; color: #166534; }

.sequence-command-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.sequence-command-actions button {
  border-color: #cfd4eb;
  color: #183a91;
}

.sequence-command-actions button:hover:not(:disabled) {
  border-color: #9eaae1;
  background: #f1f2ff;
}

.sequence-command-btn { border-color: #b6c8db; color: var(--navy); }

.sequence-command-body {
  padding: 14px;
  border-top: 1px solid #e1e7ed;
  background: #fbfdff;
}

.sequence-preview,
.sequence-live-preview,
.command-drawer-mermaid {
  min-height: 150px;
  padding: 14px;
  overflow: auto;
  border: 1px solid #d8e0e8;
  border-radius: 7px;
  background: #fff;
  text-align: center;
}

.sequence-preview svg,
.sequence-live-preview svg,
.command-drawer-mermaid svg {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.mermaid-loading {
  display: grid;
  min-height: 120px;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.mermaid-error {
  display: grid;
  min-height: 100px;
  padding: 16px;
  place-content: center;
  gap: 6px;
  color: #9f2828;
  font-size: 12px;
  text-align: left;
}

.mermaid-error span { color: #6b3b3b; white-space: pre-wrap; }

.sequence-source-details { margin-top: 10px; }
.sequence-source-details summary { color: var(--teal); font-size: 12px; font-weight: 700; cursor: pointer; }

.sequence-source-details pre {
  margin: 9px 0 0;
  padding: 12px;
  overflow: auto;
  border-radius: 6px;
  background: #101923;
  color: #dce7f3;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.sequence-editor { display: grid; gap: 10px; }
.sequence-editor label { margin: 0; }

.sequence-editor textarea {
  min-height: 230px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  tab-size: 2;
}

.sequence-editor-actions { display: flex; align-items: center; gap: 7px; }
.sequence-editor-error { color: var(--danger); font-size: 12px; font-weight: 700; white-space: pre-wrap; }
.sequence-editor-error:empty { display: none; }
.sequence-feature-empty,
.sequence-empty { padding: 24px; color: var(--muted); font-size: 12px; text-align: center; }

.command-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, .34);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.command-drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.command-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 51;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(640px, 94vw);
  height: 100dvh;
  background: #fff;
  box-shadow: -16px 0 48px rgba(15, 23, 42, .2);
  transform: translateX(102%);
  visibility: hidden;
  transition: transform .2s ease, visibility 0s linear .2s;
}

.command-drawer.open {
  visibility: visible;
  transform: translateX(0);
  transition: transform .2s ease;
}

.command-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 18px;
  border-bottom: 1px solid var(--line);
}

.command-drawer-header h2 { margin: 7px 0 4px; font-size: 20px; }
.command-drawer-header p { margin: 0; color: #64748b; font-size: 12px; }

.command-drawer-code {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--navy);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.command-drawer-close {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #475569;
  font-size: 24px;
}

.command-drawer-body { min-height: 0; overflow: auto; }
.command-drawer-section { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.command-drawer-section h3 { margin: 0 0 10px; color: #25364a; font-size: 13px; }
.command-drawer-description { margin: 0; color: #465568; font-size: 13px; line-height: 1.55; white-space: pre-wrap; }

.command-drawer-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.command-drawer-section-head h3 { margin: 0; }
.drawer-copy-btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; font-size: 11px; }

.command-drawer-json,
.command-drawer-sequence {
  margin: 0;
  padding: 13px;
  overflow: auto;
  border-radius: 6px;
  background: #101923;
  color: #dce7f3;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.command-drawer-sequence { background: #f5f7fa; color: #334155; }
.command-drawer-fields { color: #3d4d5f; font-size: 12px; white-space: pre-wrap; }
.command-drawer-empty { margin: 0; color: #718096; font-size: 12px; }

.command-drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
}

body.drawer-open { overflow: hidden; }

.app-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 28px));
  padding: 9px 13px;
  border-radius: 6px;
  background: #17212b;
  color: #fff;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity .16s ease, transform .16s ease;
}

.app-toast.visible { opacity: 1; transform: translate(-50%, 0); }

dialog {
  width: min(440px, calc(100vw - 28px));
  padding: 20px;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, .22);
}

dialog::backdrop { background: rgba(10, 18, 28, .45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.sequence-dialog {
  width: min(1380px, calc(100vw - 32px));
  height: min(900px, calc(100vh - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid #dfe2f3;
  border-radius: 14px;
  box-shadow: 0 28px 90px rgba(30, 36, 76, .28);
}

.sequence-dialog::backdrop { background: rgba(28, 33, 66, .56); }

.sequence-dialog.is-fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
}

.sequence-dialog-shell {
  display: grid;
  height: 100%;
  max-height: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.sequence-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid #e3e6f4;
  background: #fff;
}

.sequence-dialog-header > div:first-child {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px 9px;
}

.sequence-dialog-header h2 {
  margin: 0;
  background: linear-gradient(100deg, #1746d1 0%, #7c3aed 78%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 22px;
  font-weight: 850;
}

.sequence-dialog-header p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.sequence-dialog-close {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #475569;
  font-size: 24px;
}

.sequence-dialog-body {
  min-height: 0;
  padding: 14px 16px 18px;
  overflow: auto;
  background: #f5f6fc;
}

.sequence-dialog.is-fullscreen .sequence-dialog-body {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.sequence-dialog.is-fullscreen .sequence-dialog-workspace {
  min-height: 0;
  flex: 1;
  overflow: auto;
}

.sequence-dialog.is-fullscreen .sequence-dialog-workspace:not(.editing),
.sequence-dialog.is-fullscreen .sequence-dialog-workspace.preview-focused {
  display: flex;
  overflow: hidden;
}

.sequence-dialog.is-fullscreen .sequence-dialog-workspace:not(.editing) .sequence-canvas,
.sequence-dialog.is-fullscreen .sequence-dialog-workspace.preview-focused .sequence-canvas {
  height: 100%;
  min-height: 0;
  max-height: none;
  flex: 1;
}

.sequence-canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.sequence-zoom-controls,
.sequence-export-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sequence-canvas-toolbar button {
  min-height: 34px;
  padding: 6px 10px;
  border-color: #ccd2ea;
  border-radius: 7px;
  background: #fff;
  color: #173787;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(42, 48, 91, .04);
}

.sequence-canvas-toolbar button:hover {
  border-color: #99a6df;
  background: #eef0ff;
}

.sequence-zoom-controls button:first-child,
.sequence-zoom-controls button:nth-child(3) {
  width: 34px;
  padding: 0;
  font-size: 18px;
}

#sequenceZoomValue {
  min-width: 54px;
  color: #526078;
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.sequence-dialog-workspace.editing {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  height: auto;
  min-height: 0;
}

.sequence-dialog-workspace.editing.preview-focused { display: block; }

.sequence-dialog-editor {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border: 1px solid #dfe2f3;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(48, 55, 100, .05);
}

.sequence-dialog-editor-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.sequence-dialog-editor-heading strong { color: #27376f; font-size: 13px; }
.sequence-dialog-editor-heading span { color: var(--muted); font-size: 11px; }

.sequence-dialog-editor textarea {
  width: 100%;
  min-height: 260px;
  padding: 13px;
  resize: vertical;
  border-color: #ccd2ea;
  border-radius: 7px;
  background: #101923;
  color: #dce7f3;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  tab-size: 2;
}

.sequence-dialog-editor textarea:focus {
  border-color: #7c83e8;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .14);
  outline: 0;
}

.sequence-canvas {
  min-height: 480px;
  max-height: calc(100vh - 310px);
  overflow: auto;
  border: 1px solid #dfe2f3;
  border-radius: 10px;
  background-color: #fff;
  background-image: radial-gradient(#d9def2 1px, transparent 1px);
  background-size: 20px 20px;
  box-shadow: inset 0 1px 2px rgba(48, 55, 100, .04);
}

.sequence-dialog-workspace.editing .sequence-canvas {
  height: auto;
  min-height: 480px;
  max-height: calc(100vh - 310px);
}

.sequence-dialog-workspace.editing .sequence-dialog-preview { min-height: 478px; }

.sequence-dialog-preview {
  display: flex;
  min-width: 100%;
  min-height: 478px;
  padding: 28px;
  align-items: flex-start;
  justify-content: center;
  overflow: visible;
  background: transparent;
  text-align: center;
}

.sequence-dialog-preview.is-zoomed { justify-content: flex-start; }

.sequence-dialog-preview svg {
  display: block;
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  filter: drop-shadow(0 10px 18px rgba(37, 45, 91, .08));
}

.sequence-dialog-preview svg text,
.sequence-live-preview svg text,
.command-drawer-mermaid svg text {
  font-family: Inter, "Segoe UI", sans-serif !important;
}

.sequence-dialog-preview svg .actor,
.sequence-live-preview svg .actor,
.command-drawer-mermaid svg .actor {
  fill: #eef0ff !important;
  stroke: #a8b2ec !important;
  stroke-width: 1.3px !important;
}

.sequence-dialog-preview svg .actor-line,
.sequence-live-preview svg .actor-line,
.command-drawer-mermaid svg .actor-line {
  stroke: #cbd2e7 !important;
  stroke-dasharray: 4 5 !important;
}

.sequence-dialog-preview svg .messageLine0,
.sequence-dialog-preview svg .messageLine1,
.sequence-live-preview svg .messageLine0,
.sequence-live-preview svg .messageLine1 {
  stroke: #475569 !important;
  stroke-width: 1.35px !important;
}

.sequence-dialog-preview svg .messageText,
.sequence-live-preview svg .messageText {
  fill: #26334d !important;
  font-weight: 520 !important;
}

.sequence-dialog-preview svg marker[id$="-sequencenumber"] circle,
.sequence-live-preview svg marker[id$="-sequencenumber"] circle,
.command-drawer-mermaid svg marker[id$="-sequencenumber"] circle {
  fill: #f8faff !important;
  stroke: #818cf8 !important;
  stroke-width: 1.5px !important;
}

.sequence-dialog-preview svg text.sequenceNumber,
.sequence-live-preview svg text.sequenceNumber,
.command-drawer-mermaid svg text.sequenceNumber {
  fill: #25316d !important;
  font-weight: 800 !important;
}

.sequence-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 20px;
  border-top: 1px solid #e3e6f4;
  background: #fff;
}

.sequence-dialog-footer > div { display: flex; gap: 8px; }

.history-section { overflow: hidden; }

.version-history-body {
  position: relative;
  display: grid;
  margin-top: 18px;
}

.version-history-body::before {
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 8px;
  width: 2px;
  background: #dce3ef;
  content: "";
}

.version-history-item {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 84px;
  padding: 14px 0;
  border-bottom: 1px solid #e7ebf0;
}

.version-history-item:last-child { border-bottom: 0; }

.version-timeline-marker {
  z-index: 1;
  width: 18px;
  height: 18px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: #7c8ba1;
  box-shadow: 0 0 0 2px #cbd5e1;
}

.version-history-item:first-child .version-timeline-marker {
  background: var(--accent);
  box-shadow: 0 0 0 2px #93b8ef;
}

.version-history-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.version-history-title strong { font-size: 13px; }

.version-current-badge {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #1557b0;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.version-history-content p {
  margin: 5px 0 4px;
  color: #334155;
  font-size: 13px;
}

.version-history-content > span {
  color: var(--muted);
  font-size: 11px;
}

.version-history-actions {
  display: flex;
  gap: 7px;
}

.version-history-empty {
  padding: 28px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
}

.version-dialog {
  width: min(900px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .25);
}

.version-dialog::backdrop { background: rgba(15, 23, 42, .62); }

.version-dialog-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100vh - 32px);
}

.version-dialog-header,
.version-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
}

.version-dialog-header { border-bottom: 1px solid #e2e8f0; }
.version-dialog-header h2 { margin: 3px 0; font-size: 19px; }
.version-dialog-header p { margin: 0; color: var(--muted); font-size: 12px; }

.version-dialog-kicker {
  color: var(--accent);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .12em;
}

.version-dialog-close {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
}

.version-dialog-body {
  min-height: 0;
  padding: 18px 20px;
  overflow: auto;
  background: #f7f9fc;
}

.version-dialog-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.version-dialog-summary > div {
  padding: 13px 15px;
  border: 1px solid #dfe6ef;
  border-radius: 9px;
  background: #fff;
}

.version-dialog-summary strong,
.version-dialog-summary span { display: block; }
.version-dialog-summary strong { color: #173787; font-size: 17px; }
.version-dialog-summary span { margin-top: 3px; color: var(--muted); font-size: 11px; }

.version-dialog-json {
  max-height: 55vh;
  margin: 0;
  padding: 18px;
  overflow: auto;
  border: 1px solid #dbe3ec;
  border-radius: 10px;
  background: #101827;
  color: #dce7f5;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre;
}

.version-dialog-footer {
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.version-dialog-footer > span { color: var(--muted); font-size: 11px; }
.version-dialog-footer > div { display: flex; gap: 8px; flex-shrink: 0; }

/* Compact, scannable version history */
.version-history-body {
  gap: 14px;
}

.version-history-body::before { content: none; }

.version-history-overview {
  display: grid;
  grid-template-columns: .7fr 1fr 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid #dfe6ef;
  border-radius: 11px;
  background: #f7f9fc;
}

.version-history-overview > div {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
}

.version-history-overview span,
.version-history-overview strong,
.version-history-overview small { display: block; }
.version-history-overview span { margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.version-history-overview strong { color: #25324a; font-size: 15px; }
.version-history-overview small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.version-history-overview .version-safe-state { color: #087b62; }

.version-history-list {
  display: grid;
  gap: 8px;
}

.version-history-item {
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 15px;
  min-height: 92px;
  padding: 13px 14px;
  border: 1px solid #e0e6ee;
  border-radius: 10px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.version-history-item:hover {
  border-color: #b9c9df;
  box-shadow: 0 5px 16px rgba(23, 55, 99, .07);
  transform: translateY(-1px);
}

.version-number {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid #d9e2ef;
  border-radius: 10px;
  background: #f4f7fb;
  color: #526078;
  font-size: 13px;
  font-weight: 850;
}

.version-history-item:first-child .version-number {
  border-color: #9abcf0;
  background: var(--accent-soft);
  color: #1557b0;
}

.version-change-badge,
.version-current-badge {
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: none;
}

.version-change-badge.update { background: #edf2f7; color: #475569; }
.version-change-badge.add { background: #e7f8f1; color: #087b62; }
.version-change-badge.delete { background: #fff0f0; color: #b83232; }
.version-change-badge.restore { background: #f3eefe; color: #7047a8; }
.version-change-badge.create { background: #e9f3ff; color: #1664d9; }
.version-change-badge.diagram { background: #fff7e2; color: #946200; }

.version-history-content p {
  margin: 7px 0 8px;
  color: #1f2937;
  font-size: 14px;
  font-weight: 700;
}

.version-history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.version-history-meta > span { color: var(--muted); font-size: 11px; }
.version-history-meta .version-date { color: #42516a; font-weight: 700; }

.version-history-meta .version-stat {
  padding: 3px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #526078;
}

.version-history-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 2px;
}

.version-history-more span { color: var(--muted); font-size: 11px; }

.version-dialog-document {
  margin-bottom: 14px;
  padding: 17px;
  border: 1px solid #dfe6ef;
  border-radius: 10px;
  background: #fff;
}

.version-document-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.version-document-heading h3 { margin: 3px 0 0; color: #1f2d43; font-size: 17px; }
.version-document-heading span { color: #627087; font-size: 11px; }
.version-document-heading > div > span { color: var(--accent); font-weight: 800; }
.version-dialog-document > p { margin: 11px 0 14px; color: #526078; font-size: 12px; line-height: 1.55; }

.version-feature-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.version-feature-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 7px;
  background: #f6f8fb;
}

.version-feature-item span { color: #1664d9; font-size: 10px; font-weight: 800; }
.version-feature-item strong { overflow: hidden; color: #344258; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.version-feature-item small { color: var(--muted); font-size: 10px; }
.version-feature-more,
.version-no-features { margin-top: 9px; color: var(--muted); font-size: 11px; text-align: center; }

.version-json-details {
  border: 1px solid #dbe3ec;
  border-radius: 10px;
  background: #fff;
}

.version-json-details summary {
  padding: 12px 15px;
  color: #334155;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.version-json-details .version-dialog-json {
  border: 0;
  border-top: 1px solid #dbe3ec;
  border-radius: 0 0 10px 10px;
}

@media (max-width: 900px) {
  #app { display: block; }
  .sidebar { position: static; height: auto; min-height: 0; }
  .sidebar-resize-handle { display: none; }
  .project-list { max-height: 180px; }
  .sidebar-footer { margin-top: 10px; }
  .topbar { position: static; align-items: flex-start; padding: 14px; }
  .project-topbar-actions { width: 100%; align-items: stretch; }
  .project-folder-field { min-width: 0; flex: 1; }
  .project-title { width: 100%; }
  .document-page { padding: 14px; }
  .document-section { padding: 12px; }
  .document-section-heading { align-items: stretch; flex-direction: column; }
  .json-command-actions { width: 100%; margin: 0; }
  .json-group-actions { flex-wrap: wrap; }
  .json-command-count { width: 100%; margin-left: 0; }
  .json-feature-group-content small { display: none; }
  .sequence-command-header { align-items: stretch; flex-direction: column; }
  .sequence-command-actions { justify-content: flex-start; }
  .sequence-dialog { width: calc(100vw - 20px); height: calc(100vh - 20px); }
  .sequence-canvas-toolbar { align-items: stretch; flex-direction: column; }
  .sequence-export-controls { flex-wrap: wrap; }
  .sequence-dialog-workspace.editing {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .sequence-dialog-editor textarea { min-height: 250px; resize: vertical; }
  .sequence-canvas { min-height: 320px; max-height: calc(100vh - 390px); }
  .sequence-dialog-workspace.editing .sequence-canvas { height: auto; min-height: 320px; max-height: calc(100vh - 390px); }
  .sequence-dialog-preview { min-height: 318px; padding: 18px; }
  .sequence-dialog-footer { align-items: stretch; flex-direction: column; }
  .sequence-dialog-footer > div { justify-content: flex-end; }
  .version-history-overview { grid-template-columns: 1fr; }
  .version-history-item { grid-template-columns: 52px minmax(0, 1fr); align-items: start; }
  .version-history-actions { grid-column: 2; }
  .version-history-more { align-items: stretch; flex-direction: column; text-align: center; }
  .version-dialog-summary { grid-template-columns: 1fr; }
  .version-feature-list { grid-template-columns: 1fr; }
  .version-document-heading { flex-direction: column; }
  .version-dialog-footer { align-items: stretch; flex-direction: column; }
  .version-dialog-footer > div { justify-content: flex-end; }
  .command-drawer { width: 100%; max-width: none; }
}

@media (max-width: 560px) {
  .topbar { flex-direction: column; }
  .topbar > * { width: 100%; }
  .project-subline { flex-wrap: wrap; }
  .project-meta-field,
  .project-meta-field.device-id-field { width: 100%; }
}
