/* Movement Engineer layout */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: #f3f4f6;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* Top bar */

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: #111827;
  color: #f9fafb;
  gap: 0.75rem;
}

.top-bar h1 {
  margin: 0;
  font-size: 1.1rem;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.top-bar-title {
  display: flex;
  flex-direction: column;
}

.schema-version {
  font-size: 0.8rem;
  opacity: 0.7;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 6px;
  border: 1px solid #374151;
  color: #f9fafb;
  background: #111827;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.icon-button:hover {
  background: #1f2937;
  border-color: #4b5563;
}

.icon-button svg {
  width: 1.2rem;
  height: 1.2rem;
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1.1rem;
  border-radius: 6px;
  background: #111827;
  color: #f9fafb;
  border: 1px solid #374151;
}

.sidebar-toggle:hover {
  background: #1f2937;
}

button {
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  background: #e5e7eb;
  color: #111827;
}

button:hover {
  background: #d1d5db;
}

button.danger {
  background: #fee2e2;
  color: #b91c1c;
}

button.danger:hover {
  background: #fecaca;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

button.primary {
  background: #111827;
  color: #f9fafb;
}

button.primary:hover {
  background: #1f2937;
}

.status {
  font-size: 0.8rem;
  min-width: 120px;
  text-align: right;
  opacity: 0.8;
}

.save-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  background: #e0f2fe;
  color: #0f172a;
  border-bottom: 1px solid #bae6fd;
}

.save-banner.saved {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #0f172a;
}

/* Main layout */

.layout {
  flex: 1;
  display: flex;
  min-height: 0; /* allow flex children to scroll */
  position: relative;
}

/* Sidebar */

.sidebar {
  width: 230px;
  border-right: 1px solid #e5e7eb;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 19;
}

.sidebar-header {
  padding: 0.75rem 0.75rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 0.95rem;
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

.item-list li {
  padding: 0.4rem 0.8rem;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.item-list li span.secondary {
  font-size: 0.75rem;
  opacity: 0.6;
}

.item-list li:hover {
  background: #e5e7eb;
}

.item-list li.selected {
  background: #111827;
  color: #f9fafb;
}

/* Content */

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Tabs */

.tabs {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  gap: 0.25rem;
  flex-wrap: wrap;
  padding: 0.25rem 0.75rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-group {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  align-items: center;
}

.tab {
  padding: 0.5rem 0.9rem;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  flex: 0 0 auto;
  color: var(--tab-accent-text, #111827);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tab.active {
  border-bottom-color: var(--tab-accent, #111827);
  font-weight: 600;
  background: var(--tab-accent-soft, #e5e7eb);
  color: var(--tab-accent-text, #111827);
}

.tab:hover {
  border-bottom-color: var(--tab-accent, #111827);
  background: var(--tab-accent-soft, #e5e7eb);
  color: var(--tab-accent-text, #111827);
}

.tab-panel {
  display: none;
  flex: 1;
  overflow: auto;
}

.tab-panel.active {
  display: block;
}

/* Tabs nav: render as two stacked rows (tools, collections) */
#tabs-nav.tabs {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
  z-index: 2;
  flex-wrap: nowrap;
  flex: 0 0 auto;
}

#tabs-nav .tab-group {
  display: flex;
  gap: 0.25rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0.75rem;
  min-height: 2.25rem;
  flex: 0 0 auto;
}

#tool-tabs {
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

#collection-tabs {
  background: #f3f4f6;
}

#tabs-nav .tab[data-tab-group="collection"] {
  --tab-accent: #4338ca;
  --tab-accent-soft: #eef2ff;
  --tab-accent-text: #111827;
}

#tabs-nav .tab[data-tab-group="tool"] {
  --tab-accent: #111827;
  --tab-accent-soft: #e5e7eb;
  --tab-accent-text: #111827;
}

.panel-body {
  padding: 0.9rem 1.1rem 1.2rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.9rem;
  align-items: start;
}

/* Forms */

.form-row {
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  max-width: 600px;
}

.form-row label {
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
  color: #4b5563;
}

.form-row input,
.form-row textarea,
.form-row select {
  font-size: 0.88rem;
  padding: 0.35rem 0.45rem;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  background: #fff;
}

.form-row textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.5rem;
}

.hidden {
  display: none !important;
}

.github-import-modal {
  max-width: 560px;
  width: 95%;
}

.github-import-modal .form-row {
  margin-bottom: 0.75rem;
}

.github-import-modal input[type='url'] {
  width: 100%;
}

.import-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.35rem 0;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.25rem;
}

.inline-spinner {
  width: 1em;
  height: 1em;
  border: 2px solid #cbd5e1;
  border-top-color: #0f172a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.import-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
}

.loading-spinner {
  width: 15px;
  height: 15px;
  border-radius: 999px;
  border: 2px solid #cdd4df;
  border-top-color: #374151;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.fatal-error-banner {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: #7f1d1d;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  max-width: 520px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  z-index: 1400;
}

.fatal-error-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.fatal-error-body {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
}

.code-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.8rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: #e5e7eb;
}

/* Generic hints */

.hint {
  font-size: 0.8rem;
  margin-top: 0;
  margin-bottom: 0.9rem;
  color: #6b7280;
}

.muted {
  color: #6b7280;
}

/* Explorer toolbars */

.subtab-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  align-items: center;
  font-size: 0.8rem;
}

.subtab-toolbar label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.subtab-toolbar select,
.subtab-toolbar input[type="text"] {
  font-size: 0.8rem;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  background: #fff;
}

.subtab-toolbar .grow {
  flex: 1;
}

.toolbar-actions {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Split view in collections tab */

.split {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  min-height: 300px;
  flex-wrap: wrap;
}

.list-pane {
  flex: 0 0 35%;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #f9fafb;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.detail-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.item-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
  flex: 1;
}

.item-detail-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.5rem;
  align-items: start;
}

.item-detail-label {
  font-weight: 600;
  font-size: 0.78rem;
  color: #6b7280;
}

.item-detail-value {
  font-size: 0.85rem;
  word-break: break-word;
}

.generic-crud-layout {
  display: grid;
  grid-template-columns: 220px 320px 1fr;
  gap: 0.75rem;
  align-items: start;
}

.generic-crud-layout--collection {
  grid-template-columns: minmax(260px, 360px) 1fr;
  align-items: stretch;
  height: min(74vh, 880px);
  min-height: 540px;
}

@media (max-width: 1100px) {
  .generic-crud-layout--collection {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
}

.generic-crud-layout--collection .generic-crud-pane {
  min-height: 0;
}

.generic-crud-pane {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 360px;
}

.generic-crud-pane .pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.generic-crud-view-switcher {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.generic-crud-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.generic-crud-actions input[type="search"] {
  flex: 1;
}

.generic-crud-collection-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.generic-crud-collection-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.generic-crud-collection-meta {
  font-size: 0.8rem;
  color: #6b7280;
}

.generic-crud-record-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
}

.generic-crud-record-list .item-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.generic-crud-empty {
  font-size: 0.85rem;
  color: #6b7280;
  padding: 0.5rem 0.25rem;
}

.generic-crud-pane .item-list li.selected {
  background: #eef2ff;
  color: #111827;
}

.generic-crud-pane .item-list li.selected span.secondary {
  opacity: 0.7;
}

.generic-crud-pane .item-list li:hover {
  background: #f3f4f6;
}

.generic-crud-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.generic-crud-detail-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.generic-crud-detail-title h3 {
  margin: 0;
}

.generic-crud-detail-grid {
  display: grid;
  gap: 0.45rem;
}

.generic-crud-detail-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem;
  align-items: start;
}

.generic-crud-detail-label {
  font-weight: 600;
  font-size: 0.78rem;
  color: #6b7280;
}

.generic-crud-detail-value {
  font-size: 0.85rem;
  word-break: break-word;
}

@media (max-width: 720px) {
  .generic-crud-detail-row {
    grid-template-columns: 1fr;
  }
}

.generic-crud-error-summary {
  display: none;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
}

.generic-crud-error-summary.visible {
  display: block;
}

.generic-crud-field-error {
  color: #b91c1c;
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

.generic-crud-array {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.generic-crud-array-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.generic-crud-array-row input,
.generic-crud-array-row select {
  flex: 1;
}

.generic-crud-array-row button {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.schema-guide {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
}

.preview-pane,
.editor-pane,
.markdown-pane {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.issue-strip {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
  align-items: center;
  max-width: 320px;
}

.issue-badge {
  font-size: 0.72rem;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
  white-space: nowrap;
}

.issue-badge.warn {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

.issue-badge.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.preview-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preview-nav {
  display: inline-flex;
  gap: 0.25rem;
}

.preview-nav button {
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #111827;
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  line-height: 1.2;
}

.preview-nav button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.card-title {
  margin: 0.1rem 0 0.2rem;
  font-size: 1rem;
}

.small-text {
  font-size: 0.83rem;
}

.button-group {
  display: inline-flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.rules-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(380px, 1fr);
  gap: 1rem;
  align-items: start;
  margin-top: 0.5rem;
}

.rules-pane .card {
  height: 100%;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
}

.rules-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.6rem;
  margin: 0.4rem 0 0.6rem;
}

.rules-filter-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: #374151;
}

.rules-filter-grid select,
.rules-filter-grid input {
  font-size: 0.9rem;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
}

.rules-editor-card .button-group {
  align-self: flex-end;
}

.rules-editor-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.rules-editor-top .form-row {
  margin-bottom: 0;
  max-width: none;
  flex: 1;
}

.rules-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
}

.rules-editor-grid .form-row {
  margin-bottom: 0;
  max-width: none;
}

.rules-editor-grid .form-row.wide {
  grid-column: 1 / -1;
}

.rules-editor-card select[multiple] {
  min-height: 130px;
}

.rules-editor-card .form-actions {
  justify-content: space-between;
  margin-top: 0.85rem;
  padding-top: 0.6rem;
  border-top: 1px solid #e5e7eb;
}

.rules-editor-card .form-actions .hint {
  color: #4b5563;
}

.rules-browser .table-wrapper {
  margin-top: 0.1rem;
}

@media (max-width: 1100px) {
  .rules-layout {
    grid-template-columns: 1fr;
  }
}

.eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-bottom: 0.1rem;
}

.badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  white-space: nowrap;
}

.preview-body {
  border-top: 1px solid #f3f4f6;
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

.preview-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.35rem 0.75rem;
  align-items: flex-start;
}

.preview-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #4b5563;
}

.preview-value {
  font-size: 0.85rem;
  color: #111827;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.preview-value .muted,
.preview-value code {
  color: #6b7280;
}

.preview-value p {
  margin: 0;
}

.preview-value pre {
  margin: 0;
  width: 100%;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  padding: 0.45rem;
  border-radius: 4px;
  white-space: pre-wrap;
  font-size: 0.78rem;
}

.preview-value .chip-row {
  margin-top: 0.1rem;
}

#item-editor {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.82rem;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  padding: 0.5rem;
  background: #fff;
  min-height: 220px;
}

.editor-actions {
  margin-top: 0.4rem;
  display: flex;
  justify-content: flex-end;
}

/* Collection toolbar */

.collection-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.collection-toolbar label {
  font-size: 0.8rem;
}

.collection-toolbar select,
.collection-toolbar input[type="checkbox"] {
  margin-left: 0.25rem;
}

.collection-toolbar .inline {
  display: flex;
  align-items: center;
}

.collection-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}

.facet-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.facet-banner .eyebrow {
  margin-bottom: 0.1rem;
}

.facet-banner .muted {
  margin-top: 0.15rem;
}

/* Dashboard stats */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.stat-card {
  background: #f9fafb;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  padding: 0.6rem 0.7rem;
  font-size: 0.83rem;
}

.stat-card h3 {
  margin: 0 0 0.3rem;
  font-size: 0.9rem;
}

.stat-card ul {
  padding-left: 1.1rem;
  margin: 0.1rem 0 0;
}

/* Re-usable section heading */

.section-heading {
  margin-top: 1.1rem;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.section-heading.small {
  margin-top: 0.7rem;
  font-size: 0.84rem;
}

/* Chips */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.chip {
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: var(--chip-bg, #e5e7eb);
  color: var(--chip-text, #111827);
  border: 1px solid var(--chip-border, #d1d5db);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
  appearance: none;
  line-height: 1.2;
  box-shadow: var(--chip-shadow, none);
  transition:
    background 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

.chip-tag {
  --chip-bg: #f3f4f6;
  --chip-border: #e5e7eb;
  --chip-text: #374151;
}

.chip-entity {
  --chip-bg: #eef2ff;
  --chip-border: #c7d2fe;
  --chip-text: #3730a3;
  --chip-shadow: 0 1px 0 rgba(55, 48, 163, 0.08);
  --chip-hover: #e0e7ff;
  --chip-border-hover: #a5b4fc;
}

.chip:not(.chip-tile):hover {
  background: var(--chip-hover, #d1d5db);
  border-color: var(--chip-border-hover, #d1d5db);
}

.chip-entity:hover {
  background: var(--chip-hover, #e0e7ff);
  border-color: var(--chip-border-hover, #a5b4fc);
}

.chip:focus-visible {
  outline: 2px solid var(--chip-accent, #4f46e5);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.chip.chip-tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  width: 100%;
  gap: 0.25rem;
  border-radius: 10px;
}

.chip.chip-tile:hover {
  transform: translateY(-1px);
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #e5e7eb;
  color: #111827;
  cursor: pointer;
  font-size: 0.75rem;
}

.filter-pill input {
  margin: 0;
}

/* Comparison */

.comparison-selector {
  margin-bottom: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  font-size: 0.85rem;
}

.comparison-selector label {
  cursor: pointer;
}

.comparison-table-wrapper {
  overflow-x: auto;
}

.comparison-table-wrapper table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.8rem;
}

.comparison-table-wrapper th,
.comparison-table-wrapper td {
  border: 1px solid #e5e7eb;
  padding: 0.35rem 0.45rem;
}

.comparison-table-wrapper th {
  background: #f3f4f6;
  text-align: left;
}

/* Tree view */

.tree-container {
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 0.4rem 0.5rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
  font-size: 0.8rem;
}

#tab-canon .tree-container {
  flex: 1;
  min-height: 100%;
}

.markdown-row {
  align-items: stretch;
}

.markdown-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.markdown-row-actions button {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}

.markdown-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

.markdown-input {
  min-height: 220px;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
}

.markdown-preview-panel {
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
  padding: 0.75rem;
  min-height: 220px;
  overflow-y: auto;
  font-size: 0.9rem;
}

.markdown-preview-panel.empty {
  color: #6b7280;
  font-style: italic;
}

.markdown-preview-panel h1,
.markdown-preview-panel h2,
.markdown-preview-panel h3,
.markdown-preview-panel h4 {
  margin-top: 0.6em;
  margin-bottom: 0.35em;
}

.markdown-preview-panel p {
  margin: 0.4em 0;
}

.markdown-preview-panel ul,
.markdown-preview-panel ol {
  padding-left: 1.15rem;
}

.markdown-preview-panel code {
  background: #f3f4f6;
  padding: 0.1rem 0.2rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.markdown-preview-panel pre {
  background: #111827;
  color: #e5e7eb;
  padding: 0.75rem;
  border-radius: 4px;
  overflow-x: auto;
}

.markdown-raw-details {
  margin-top: 0.6rem;
}

.markdown-raw {
  margin: 0.45rem 0 0;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.markdown-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.markdown-modal {
  background: #fff;
  max-width: 960px;
  width: 96%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.25);
}

.markdown-modal-header,
.markdown-modal-footer {
  padding: 0.9rem 1.1rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.markdown-modal-footer {
  border-bottom: none;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.markdown-modal-body {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.6rem;
  padding: 0.9rem 1.1rem;
  background: #fff;
  overflow: hidden;
}

.markdown-editor-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.markdown-editor {
  flex: 1;
  width: 100%;
  resize: none;
  padding: 0.6rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
  box-sizing: border-box;
}

.markdown-preview {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.9rem;
  overflow-y: auto;
  background: #fff;
  font-size: 0.95rem;
}

/* Detail sections / cards */

.detail-section {
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 0.5rem 0.6rem;
  font-size: 0.82rem;
}

.detail-section h3 {
  margin-top: 0;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

/* Card grid */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.6rem;
  font-size: 0.82rem;
}

.card {
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 0.5rem 0.6rem;
}

.card h4 {
  margin: 0 0 0.15rem;
  font-size: 0.88rem;
}

.card .meta {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 0.25rem;
}

/* Generic table */

.table-wrapper {
  overflow-x: auto;
  font-size: 0.8rem;
}

.table-wrapper table {
  border-collapse: collapse;
  width: 100%;
}

.table-wrapper th,
.table-wrapper td {
  border: 1px solid #e5e7eb;
  padding: 0.3rem 0.4rem;
  vertical-align: top;
  cursor: default;
}

.table-wrapper th {
  background: #f3f4f6;
  text-align: left;
}

#notes-table-wrapper {
  flex: 1;
}

#notes-table-wrapper tr.selected {
  background: #eef2ff;
}

#notes-table-wrapper .note-actions {
  display: flex;
  gap: 0.3rem;
}

#notes-table-wrapper .note-actions button {
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
}

.table-wrapper tr.clickable-row {
  cursor: pointer;
}

.table-wrapper tr.selected {
  background: #eef2ff;
}

/* Entity graph */
.entity-graph-wrapper {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.entity-graph-canvas {
  flex: 1 1 620px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.5rem;
  box-shadow: 0 2px 6px rgba(17, 24, 39, 0.08);
}

.entity-graph-canvas svg {
  width: 100%;
  height: 100%;
}

.entity-graph-summary {
  flex: 0 0 260px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.75rem;
  box-shadow: 0 2px 6px rgba(17, 24, 39, 0.08);
}

.chip-row.wrap {
  flex-wrap: wrap;
}

.edge-list {
  margin: 0;
  padding-left: 1.05rem;
  font-size: 0.8rem;
  color: #374151;
}

.graph-node circle {
  transition: transform 0.15s ease, stroke 0.15s ease;
}

.graph-node:hover circle {
  transform: scale(1.05);
  stroke: #111827;
}

.graph-node-label {
  fill: #111827;
  font-size: 0.78rem;
  pointer-events: none;
  user-select: none;
  cursor: default;
}

.graph-context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 180px;
  z-index: 9999;
  padding: 4px 0;
}

.graph-context-item {
  padding: 10px 14px;
  cursor: pointer;
  color: #111827;
  transition: background 0.15s ease;
  font-size: 0.9rem;
}

.graph-context-item:hover {
  background: #f3f4f6;
}

.chip-strong {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

/* ---------------------------
   Graph Workbench (Ontorum-ish)
---------------------------- */

.graph-workbench {
  --graph-left-width: 360px;
  --graph-right-width: 420px;

  display: grid;
  grid-template-columns: var(--graph-left-width) 1fr var(--graph-right-width);
  gap: 12px;

  /* Good default inside a tab panel */
  height: 78vh;
  min-height: 640px;

  align-items: stretch;
}

@media (max-width: 960px) {
  .graph-workbench {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
}

.graph-pane {
  position: relative;
  min-width: 0; /* allow shrinking */
  height: 100%;
}

.graph-pane .pane-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.graph-pane details {
  background: var(--panel-bg, transparent);
  border-radius: 10px;
}

.graph-pane details > summary {
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
  list-style: none;
}

.graph-pane details[open] > summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.graph-pane details > summary::-webkit-details-marker {
  display: none;
}

.graph-pane details .details-body {
  padding: 10px 12px 12px 12px;
}

.graph-canvas {
  flex: 1;
  min-height: 420px;
  position: relative;
  overflow: hidden;
}

.graph-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.graph-toolbar .toolbar-spacer {
  flex: 1;
}

/* Library editor */
.library-atmosphere {
  position: relative;
  padding: 1.1rem 1.2rem 1.35rem;
  margin: -0.2rem;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.35), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(255, 255, 255, 0.25), transparent 32%),
    linear-gradient(135deg, rgba(39, 28, 20, 0.05), rgba(255, 255, 255, 0));
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(24, 16, 10, 0.18);
  overflow: hidden;
}

.library-atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(197, 155, 69, 0.12), transparent 30%),
    linear-gradient(300deg, rgba(87, 66, 49, 0.12), transparent 35%),
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.05),
      rgba(255, 255, 255, 0.05) 6px,
      rgba(255, 255, 255, 0.01) 6px,
      rgba(255, 255, 255, 0.01) 12px
    );
  pointer-events: none;
}

#tab-canon {
  --library-wood: #3e2b20;
  --library-wood-highlight: #5a3a2c;
  --library-wood-edge: rgba(28, 17, 11, 0.25);
  --library-paper: #f7f0df;
  --library-paper-ink: #24180f;
  --library-brass: #c59b45;
  --library-muted: #8c7256;
  --card-bg: #fdf7eb;
  --card-border: rgba(66, 45, 28, 0.25);
  --accent-color: #c59b45;
  --muted-text: var(--library-muted);
}

.library-atmosphere > * {
  position: relative;
  z-index: 1;
}

.library-layout {
  display: grid;
  grid-template-columns: 280px 360px 1fr;
  gap: 1.05rem;
  align-items: start;
  padding: 0.75rem;
  background:
    linear-gradient(90deg, rgba(62, 43, 32, 0.7), rgba(46, 33, 25, 0.8) 36%, rgba(62, 43, 32, 0.74)),
    linear-gradient(180deg, rgba(59, 40, 28, 0.55), rgba(28, 19, 13, 0.75));
  border-radius: 12px;
  border: 1px solid var(--library-wood-edge);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 18px 40px rgba(16, 10, 6, 0.4);
}

.library-pane {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(253, 247, 235, 0.9)),
    linear-gradient(145deg, rgba(197, 155, 69, 0.12), rgba(255, 255, 255, 0));
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.85rem;
  min-height: 320px;
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  overflow: hidden;
}

.library-pane .pane-header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(197, 155, 69, 0.25);
}

.library-pane .pane-header .inline-actions button {
  margin-left: 0.25rem;
}

.library-pane .input-row {
  margin-bottom: 0.75rem;
}

.library-search-results {
  list-style: none;
  margin: 0 0 0.75rem 0;
  padding: 0;
  border: 1px solid rgba(58, 38, 26, 0.35);
  border-radius: 10px;
  background: rgba(253, 247, 235, 0.95);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24);
  max-height: 260px;
  overflow-y: auto;
  display: none;
  backdrop-filter: blur(2px);
}

.library-search-results.visible {
  display: block;
}

.library-search-item {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid rgba(58, 38, 26, 0.16);
  cursor: pointer;
  transition: background 0.1s ease;
}

.library-search-item:last-child {
  border-bottom: none;
}

.library-search-item:hover,
.library-search-item.active {
  background: rgba(197, 155, 69, 0.12);
}

.library-search-item .path {
  font-weight: 600;
  margin-bottom: 2px;
}

.library-search-item .meta {
  color: var(--muted-text);
  font-size: 0.85rem;
}

.shelf-list,
.book-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.chip.shelf-card,
.chip.book-card {
  font-size: 1rem;
}

.shelf-card,
.book-card {
  position: relative;
  border: 1px solid rgba(58, 38, 26, 0.3);
  border-radius: 10px;
  padding: 0.65rem 0.7rem 0.65rem 0.9rem;
  cursor: pointer;
  transition: border-color 0.1s ease, box-shadow 0.1s ease, transform 0.1s ease;
  background: linear-gradient(
    90deg,
    #c8a367 0%,
    #b38541 18%,
    #d3b06f 50%,
    #c29b57 65%,
    #a8743a 100%
  );
  color: var(--library-paper-ink);
  box-shadow:
    inset 6px 0 0 rgba(0, 0, 0, 0.08),
    0 8px 18px rgba(0, 0, 0, 0.18);
}

.shelf-card.active,
.book-card.active {
  border-color: var(--accent-color);
  box-shadow:
    0 0 0 2px rgba(197, 155, 69, 0.28),
    0 14px 26px rgba(0, 0, 0, 0.22);
  transform: translateY(-1px);
}

.shelf-card::before,
.book-card::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 10px;
  bottom: 10px;
  width: 7px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(0, 0, 0, 0.05));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.shelf-card .meta,
.book-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  font-size: 0.85rem;
  color: rgba(36, 24, 15, 0.7);
}

.book-card .inline-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.book-card .inline-actions button {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(58, 38, 26, 0.25);
  color: var(--library-paper-ink);
}

.book-card .inline-actions button:hover {
  background: rgba(197, 155, 69, 0.12);
}

.library-pane.shelves-pane::before {
  content: "";
  position: absolute;
  inset: 12px 14px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(197, 155, 69, 0.28),
    rgba(197, 155, 69, 0.28) 2px,
    transparent 2px,
    transparent 76px
  );
  opacity: 0.9;
  pointer-events: none;
  border-radius: 10px;
}

.library-pane.books-pane::before {
  content: "";
  position: absolute;
  inset: 16px 12px 12px 16px;
  background: linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.3) 0,
      rgba(255, 255, 255, 0.02) 14%
    ),
    linear-gradient(180deg, rgba(255, 255, 255, 0.4), transparent);
  pointer-events: none;
  border-radius: 8px;
}

.library-pane.editor-pane {
  background: linear-gradient(140deg, rgba(49, 33, 24, 0.95), rgba(29, 20, 14, 0.94));
  border-color: rgba(0, 0, 0, 0.3);
  box-shadow:
    0 16px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  color: #f3e7d3;
}

.library-pane.editor-pane::before {
  content: "";
  position: absolute;
  inset: 10px;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.08), transparent 32%),
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.06), transparent 35%),
    linear-gradient(160deg, rgba(0, 0, 0, 0.22), rgba(255, 255, 255, 0.04));
  pointer-events: none;
  border-radius: 10px;
}

.library-pane .pane-header .section-heading {
  letter-spacing: 0.02em;
  color: var(--library-paper-ink);
}

.library-pane .pane-header .muted {
  color: rgba(36, 24, 15, 0.7);
}

.library-pane.editor-pane .pane-header .section-heading {
  color: #f7ead3;
}

.library-pane.editor-pane .pane-header .muted {
  color: rgba(243, 231, 211, 0.8);
}

.library-pane .breadcrumb {
  font-size: 0.9rem;
  color: rgba(255, 236, 209, 0.75);
}

.library-pane .card {
  margin-bottom: 0.75rem;
}

.library-pane.editor-pane .card {
  background: var(--library-paper);
  border: 1px solid rgba(60, 40, 26, 0.35);
  border-radius: 12px;
  box-shadow:
    0 14px 26px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  background-image: linear-gradient(
      transparent 0,
      transparent 22px,
      rgba(0, 0, 0, 0.05) 23px,
      transparent 24px
    ),
    radial-gradient(circle at 16% 14%, rgba(197, 155, 69, 0.14), transparent 38%),
    radial-gradient(circle at 86% 10%, rgba(255, 255, 255, 0.3), transparent 40%);
  color: var(--library-paper-ink);
  font-family: "Georgia", "Times New Roman", serif;
  position: relative;
}

.library-pane.editor-pane input,
.library-pane.editor-pane textarea,
.library-pane.editor-pane select {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(60, 40, 26, 0.3);
  color: var(--library-paper-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.library-pane.editor-pane .inline-actions button {
  background: rgba(197, 155, 69, 0.12);
  border: 1px solid rgba(197, 155, 69, 0.45);
  color: var(--library-paper-ink);
}

.library-pane.editor-pane .inline-actions button:hover {
  background: rgba(197, 155, 69, 0.2);
}

.library-pane.editor-pane button.danger {
  background: rgba(190, 24, 19, 0.12);
  border-color: rgba(190, 24, 19, 0.45);
}

.toc-node {
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s ease, transform 0.1s ease;
}

.toc-node.active {
  background: rgba(197, 155, 69, 0.16);
  transform: translateX(2px);
}

.toc-node .toc-label {
  font-weight: 600;
  margin-right: 0.35rem;
}

.toc-node .toc-meta {
  color: var(--library-muted);
  font-size: 0.85rem;
}

.library-empty {
  padding: 0.5rem 0.65rem;
  color: var(--library-muted);
  font-style: italic;
}

@media (max-width: 1100px) {
  .library-layout {
    grid-template-columns: 1fr;
  }
}

.graph-resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: col-resize;
  z-index: 5;
}

.graph-resize-handle.left {
  right: -5px;
}

.graph-resize-handle.right {
  left: -5px;
}

@media (max-width: 960px) {
  .graph-resize-handle {
    display: none;
  }
}

/* Search UI */
.graph-search-results {
  list-style: none;
  margin: 10px 0 0 0;
  padding: 0;
  max-height: 300px;
  overflow: auto;
  border-radius: 10px;
}

.graph-search-item {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 8px;
}

.graph-search-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.graph-search-item.selected {
  outline: 2px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
}

.graph-search-item .meta {
  opacity: 0.7;
  font-size: 0.85em;
  white-space: nowrap;
}

/* Graph workbench filter chips */
#gw-filter-types .filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
}

#gw-filter-types .filter-pill input[type='checkbox'] {
  transform: translateY(1px);
}

#gw-filter-center-label {
  margin-top: 4px;
  margin-bottom: 6px;
}

/* Small form helpers */
.graph-form .form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.graph-form .form-row.inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.graph-form .form-row.inline > * {
  flex: 1;
}

.graph-form .hint {
  font-size: 0.85em;
  opacity: 0.7;
}

.graph-selected-body {
  padding: 12px;
}

.graph-selected-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.graph-selected-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.graph-selected-subtitle {
  margin: 0;
  opacity: 0.7;
  font-size: 0.85rem;
}

/* D3 graph styling */
.graph-canvas svg {
  width: 100%;
  height: 100%;
  display: block;
}

.graph-link {
  stroke: var(--link-color, rgba(31, 41, 55, 0.55));
  stroke-width: 1.5px;
  fill: none;
}

.graph-link-hitbox {
  stroke: transparent;
  stroke-width: 12px;
  fill: none;
  cursor: pointer;
}

.graph-link.selected .graph-link {
  stroke-width: 3px;
}

.graph-link-label {
  font-size: 11px;
  opacity: 0.7;
  pointer-events: none;
}

.graph-node circle {
  stroke: rgba(0, 0, 0, 0.35);
  stroke-width: 1px;
}

.graph-node.selected circle {
  stroke: rgba(255, 255, 255, 0.65);
  stroke-width: 3px;
}

.graph-node text {
  font-size: 11px;
  opacity: 0.9;
  pointer-events: none;
}

/* Responsive tweaks */
@media (max-width: 1100px) {
  .save-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .status {
    min-width: 0;
    text-align: left;
  }
}

@media (max-width: 960px) {
  .top-bar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .top-bar-left {
    width: 100%;
    justify-content: space-between;
  }

  .top-bar-title h1 {
    font-size: 1rem;
  }

  .top-bar-right {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .layout {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    max-width: 320px;
    width: min(320px, 85vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.2);
  }

  .content {
    width: 100%;
    min-width: 0;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .split {
    flex-direction: column;
  }

  .list-pane,
  .detail-pane {
    width: 100%;
    flex: 1 1 auto;
  }

  .preview-row {
    grid-template-columns: 1fr;
  }

  .collection-toolbar {
    gap: 0.5rem;
  }
}

@media (max-width: 720px) {
  .tabs {
    gap: 0.15rem;
  }

  .tab {
    padding: 0.45rem 0.7rem;
  }

  .form-row {
    max-width: 100%;
  }

  .preview-label {
    font-size: 0.82rem;
  }

  .preview-value {
    font-size: 0.83rem;
  }
}
