/* Desktop history names share the combination workbench, without changing
 * mobile history or the second-level historical review screen. Capacity is
 * measured from the grid's available box; cards never stretch to fill a page. */
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace {
  --history-panel: #fff;
  --history-card: linear-gradient(180deg, #fff, #fafcf9);
  --history-line: #dbe7df;
  --history-name: #284338;
  --history-text: #29363e;
  --history-muted: #708177;
  --history-accent: #286955;
  --history-on-accent: #fff;
  --history-button: #fff;
  --history-button-text: #426b57;
  --history-button-line: #d5e2d9;
  --history-selected: #edf4ee;
  --history-min-width: 200px;
  --history-card-height: 100px;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  gap: 14px;
  overflow: hidden;
  color: rgba(var(--ui-source-c229c6cf220117-rgb, 41, 54, 62), var(--ui-source-c229c6cf220117-alpha, 1));
}

html:not([data-ui="mobile"]) body[data-theme="tech"] .history-match-workspace {
  --history-panel: var(--ui-surface-1, #101f30);
  --history-card: var(--ui-surface-2, #152b42);
  --history-line: var(--ui-line, #2c435b);
  --history-name: var(--ui-text-strong, #e8f0fa);
  --history-text: var(--ui-text, #d8e5f2);
  --history-muted: var(--ui-text-muted, #a4b8cc);
  --history-accent: var(--ui-accent, #80c6ff);
  --history-on-accent: var(--ui-text-on-accent, #062138);
  --history-button: var(--ui-surface-2, #152b42);
  --history-button-text: var(--ui-text-strong, #d8e5f2);
  --history-button-line: var(--ui-line, #3e617d);
  --history-selected: var(--ui-surface-selected, #244662);
}

html:not([data-ui="mobile"]) body[data-theme="ink"] .history-match-workspace {
  --history-panel: var(--ink-n-surface);
  --history-card: var(--ink-n-raised);
  --history-line: var(--ink-n-line);
  --history-name: var(--ink-n-gold);
  --history-text: var(--ink-n-text);
  --history-muted: var(--ink-n-muted);
  --history-accent: var(--ink-n-gold);
  --history-on-accent: #171913;
  --history-button: var(--ink-n-deep);
  --history-button-text: var(--ink-n-text);
  --history-button-line: var(--ink-n-gold-line);
  --history-selected: #302f29;
}

html:not([data-ui="mobile"]) body[data-theme="redbook"] .history-match-workspace {
  --history-panel: #fff;
  --history-card: #fff;
  --history-line: #dedede;
  --history-name: #202020;
  --history-text: #333;
  --history-muted: #686868;
  --history-accent: var(--rb-action);
  --history-on-accent: #fff;
  --history-button: #fff;
  --history-button-text: #555;
  --history-button-line: #ddd;
  --history-selected: #fff0f2;
}

html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-workspace-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  margin: 0;
  padding: 4px 4px 2px;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: rgba(var(--ui-source-b4ab9a086098c0-rgb, 41, 54, 62), var(--ui-source-b4ab9a086098c0-alpha, 1));
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-workspace-header h1 {
  margin: 0;
  padding: 0;
  font-size: 26px;
  line-height: 36px;
  font-weight: 650;
  letter-spacing: .03em;
  color: inherit;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-workspace-header button {
  min-height: 36px;
  height: auto;
  padding: 6px 15px;
  border: 1px solid rgba(var(--ui-source-09942b757a3991-rgb, 213, 226, 217), var(--ui-source-09942b757a3991-alpha, 1));
  border-radius: 6px;
  background: rgba(var(--ui-source-9e0a6a32fe966e-rgb, 255, 255, 255), var(--ui-source-9e0a6a32fe966e-alpha, 1));
  color: rgba(var(--ui-source-f6512c8a4d090a-rgb, 66, 107, 87), var(--ui-source-f6512c8a4d090a-alpha, 1));
  font-size: 13px;
  line-height: 22px;
  box-shadow: none;
}

html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace > .name-combination-mode {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  gap: 6px;
  margin: 0;
  padding: 0 2px 12px;
  border: 0;
  border-bottom: 1px solid rgba(var(--ui-source-ba19f5ac623cca-rgb, 219, 231, 223), var(--ui-source-ba19f5ac623cca-alpha, 1));
  border-radius: 0;
  background: transparent;
  overflow: visible;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace > .name-combination-mode > button {
  flex: 0 0 auto;
  height: auto;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid rgba(var(--ui-source-6c9132ee1bdc2a-rgb, 213, 226, 217), var(--ui-source-6c9132ee1bdc2a-alpha, 1));
  border-radius: 6px;
  background: rgba(var(--ui-source-4b349bb967c4d7-rgb, 255, 255, 255), var(--ui-source-4b349bb967c4d7-alpha, 1));
  color: rgba(var(--ui-source-8a603beddc0360-rgb, 66, 107, 87), var(--ui-source-8a603beddc0360-alpha, 1));
  font-size: 13px;
  line-height: 20px;
  white-space: nowrap;
  box-shadow: none;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace > .name-combination-mode > button.active {
  border-color: rgba(var(--ui-source-0c6b7f884c5675-rgb, 40, 105, 85), var(--ui-source-0c6b7f884c5675-alpha, 1));
  background: rgba(var(--ui-source-6922aa1d034345-rgb, 40, 105, 85), var(--ui-source-6922aa1d034345-alpha, 1));
  color: rgba(var(--ui-source-facac2de3f91e9-rgb, 255, 255, 255), var(--ui-source-facac2de3f91e9-alpha, 1));
  box-shadow: none;
}

html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-results {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: auto;
  gap: 0;
  margin: 0;
  padding: 18px 18px 0;
  border: 1px solid rgba(var(--ui-source-e120f8cc2843d2-rgb, 219, 231, 223), var(--ui-source-e120f8cc2843d2-alpha, 1));
  border-radius: 9px;
  background: rgba(var(--ui-source-d89cb5294cfef4-rgb, 255, 255, 255), var(--ui-source-d89cb5294cfef4-alpha, 1));
  color: rgba(var(--ui-source-c229c6cf220117-rgb, 41, 54, 62), var(--ui-source-c229c6cf220117-alpha, 1));
  overflow: hidden;
  box-shadow: none;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-grid {
  display: grid;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  grid-template-columns: repeat(var(--history-columns, 6), minmax(0, 1fr));
  grid-template-rows: none;
  grid-auto-rows: var(--history-card-height);
  column-gap: 12px;
  row-gap: 8px;
  align-content: start;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-grid.is-empty {
  grid-template: minmax(100px, 1fr) / minmax(0, 1fr);
  align-content: stretch;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-card {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 35px;
  gap: 0;
  min-width: 0;
  min-height: 100px;
  height: var(--history-card-height);
  margin: 0;
  padding: 0;
  border: 1px solid rgba(var(--ui-source-e120f8cc2843d2-rgb, 219, 231, 223), var(--ui-source-e120f8cc2843d2-alpha, 1));
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(var(--ui-source-3df613b2ff30a3-rgb, 255, 255, 255), var(--ui-source-3df613b2ff30a3-alpha, 1)), rgba(var(--ui-source-ea409fd697b764-rgb, 250, 252, 249), var(--ui-source-ea409fd697b764-alpha, 1)));
  color: rgba(var(--ui-source-f575fd6616aa67-rgb, 40, 67, 56), var(--ui-source-f575fd6616aa67-alpha, 1));
  overflow: hidden;
  box-shadow: none;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-card-head {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: 0;
  padding: 3px 10px 0;
  flex-direction: column;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-card-head > strong {
  display: block;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  color: rgba(var(--ui-source-244222f56c9111-rgb, 40, 67, 56), var(--ui-source-244222f56c9111-alpha, 1));
  background: transparent;
  border: 0;
  font-family: "NameHuiwenMincho", "Songti SC", serif;
  font-size: 34px;
  font-weight: 400;
  font-synthesis: none;
  line-height: 1.15;
  letter-spacing: .025em;
  text-align: center;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  overflow: visible;
  text-shadow: none;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-actions,
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-import-actions {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 0;
  grid-template: none;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-actions { padding-inline: 8px; }
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-actions button {
  flex: 0 1 auto;
  width: auto;
  min-width: 68px;
  height: 28px;
  min-height: 28px;
  margin: 0;
  padding: 3px 12px;
  border: 1px solid rgba(var(--ui-source-c9edc7c9eb1206-rgb, 213, 226, 217), var(--ui-source-c9edc7c9eb1206-alpha, 1));
  border-radius: 4px;
  background: rgba(var(--ui-source-14c1a89af6fff7-rgb, 255, 255, 255), var(--ui-source-14c1a89af6fff7-alpha, 1));
  color: rgba(var(--ui-source-36396f0b314ae9-rgb, 66, 107, 87), var(--ui-source-36396f0b314ae9-alpha, 1));
  font-size: 12px;
  font-weight: 400;
  line-height: 20px;
  white-space: nowrap;
  box-shadow: none;
  transform: none;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-actions button:last-child {
  background: rgba(var(--ui-source-90744806d82577-rgb, 237, 244, 238), var(--ui-source-90744806d82577-alpha, 1));
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace button:focus-visible {
  outline: 2px solid rgba(var(--ui-source-3925b0c75c8553-rgb, 40, 105, 85), var(--ui-source-3925b0c75c8553-alpha, 1));
  outline-offset: 2px;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-actions button:hover:not(:disabled) {
  border-color: rgba(var(--ui-source-8cd0cca2c3b5af-rgb, 40, 105, 85), var(--ui-source-8cd0cca2c3b5af-alpha, 1));
  background: rgba(var(--ui-source-18b7a55b31622d-rgb, 237, 244, 238), var(--ui-source-18b7a55b31622d-alpha, 1));
  color: rgba(var(--ui-source-68bb235d443be3-rgb, 40, 67, 56), var(--ui-source-68bb235d443be3-alpha, 1));
  transform: none;
  box-shadow: none;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-actions button:disabled {
  color: rgba(var(--ui-source-c888d3b2755fbf-rgb, 112, 129, 119), var(--ui-source-c888d3b2755fbf-alpha, 1));
  background: rgba(var(--ui-source-1c7e533b695f46-rgb, 237, 244, 238), var(--ui-source-1c7e533b695f46-alpha, 1));
  opacity: .72;
  cursor: default;
}

html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-pagination {
  position: static;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-height: 56px;
  margin: 10px 0 0;
  padding: 12px 0;
  border: 0;
  border-top: 1px solid rgba(var(--ui-source-033073b5031455-rgb, 219, 231, 223), var(--ui-source-033073b5031455-alpha, 1));
  border-radius: 0;
  background: rgba(var(--ui-source-d89cb5294cfef4-rgb, 255, 255, 255), var(--ui-source-d89cb5294cfef4-alpha, 1));
  color: rgba(var(--ui-source-521d4fd8179a44-rgb, 112, 129, 119), var(--ui-source-521d4fd8179a44-alpha, 1));
  font-size: 12px;
  line-height: 20px;
  box-shadow: none;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-pagination > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-pagination button {
  min-height: 32px;
  height: auto;
  min-width: 32px;
  padding: 5px 11px;
  border: 1px solid rgba(var(--ui-source-c9edc7c9eb1206-rgb, 213, 226, 217), var(--ui-source-c9edc7c9eb1206-alpha, 1));
  border-radius: 5px;
  background: rgba(var(--ui-source-14c1a89af6fff7-rgb, 255, 255, 255), var(--ui-source-14c1a89af6fff7-alpha, 1));
  color: rgba(var(--ui-source-36396f0b314ae9-rgb, 66, 107, 87), var(--ui-source-36396f0b314ae9-alpha, 1));
  font-size: 12px;
  line-height: 20px;
  box-shadow: none;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-pagination button:disabled {
  color: rgba(var(--ui-source-c888d3b2755fbf-rgb, 112, 129, 119), var(--ui-source-c888d3b2755fbf-alpha, 1));
  opacity: .55;
  cursor: default;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-empty-state { color: rgba(var(--ui-source-521d4fd8179a44-rgb, 112, 129, 119), var(--ui-source-521d4fd8179a44-alpha, 1)); }
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-empty-state strong { color: rgba(var(--ui-source-f575fd6616aa67-rgb, 40, 67, 56), var(--ui-source-f575fd6616aa67-alpha, 1)); }

/* Preserve the black/gold identity and red method band of the fourth theme. */
html:not([data-ui="mobile"]) body[data-theme="redbook"] .history-match-workspace .history-workspace-header {
  padding: 5px 12px;
  border: 1px solid var(--rb-gold-line);
  border-radius: 9px;
  background: var(--rb-black);
  color: var(--rb-gold);
}
html:not([data-ui="mobile"]) body[data-theme="redbook"] .history-match-workspace .history-workspace-header button {
  background: var(--rb-dark-raised);
  border-color: var(--rb-gold-line);
  color: var(--rb-gold);
}
html:not([data-ui="mobile"]) body[data-theme="redbook"] .history-match-workspace > .name-combination-mode {
  padding: 4px 6px;
  border: 1px solid var(--rb-action);
  border-radius: 8px;
  background: var(--rb-action);
}
html:not([data-ui="mobile"]) body[data-theme="redbook"] .history-match-workspace > .name-combination-mode > button {
  background: transparent;
  color: #fff;
  border-color: transparent;
}
html:not([data-ui="mobile"]) body[data-theme="redbook"] .history-match-workspace > .name-combination-mode > button.active {
  background: #fff;
  color: #191919;
  border-color: #fff;
}

/* A desktop workbench may be viewed in a narrow window; names retain their
 * actual size while the capacity controller reduces columns. */
html:not([data-ui="mobile"]) body[data-theme] .history-workspace-breadcrumb {
  color: rgba(var(--ui-source-521d4fd8179a44-rgb, 112, 129, 119), var(--ui-source-521d4fd8179a44-alpha, 1));
  font-size: 12px;
  line-height: 20px;
}
html:not([data-ui="mobile"]) body[data-theme] .history-workspace-breadcrumb > span { padding-inline: 9px; }
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace > .name-combination-mode > span[hidden] { display: none !important; }
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-pagination button.page-current {
  background: rgba(var(--ui-source-590e6c27609511-rgb, 40, 105, 85), var(--ui-source-590e6c27609511-alpha, 1));
  border-color: rgba(var(--ui-source-3925b0c75c8553-rgb, 40, 105, 85), var(--ui-source-3925b0c75c8553-alpha, 1));
  color: rgba(var(--ui-source-5db510f491f945-rgb, 255, 255, 255), var(--ui-source-5db510f491f945-alpha, 1));
}
html:not([data-ui="mobile"]) body[data-theme] .main:has(.history-match-workspace) > .smart-compact-context-slot {
  width: 116px;
  height: 30px;
}
html:not([data-ui="mobile"]) body[data-theme] .main:has(.history-match-workspace) .smart-compact-context-trigger {
  display: block;
  width: 116px;
  min-width: 116px;
  max-width: none;
  height: 30px;
  min-height: 30px;
  padding: 4px 12px;
  border: 1px solid rgba(var(--ui-source-a000211438dc2d-rgb, 222, 216, 207), var(--ui-source-a000211438dc2d-alpha, 1));
  border-radius: 0 0 6px 6px;
  font-size: 12px;
  font-weight: 400;
  line-height: 20px;
  white-space: nowrap;
  writing-mode: horizontal-tb;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-action-notice {
  flex: 0 0 auto;
  margin: 0;
  overflow-wrap: anywhere;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-card.has-error {
  border-color: rgba(var(--ui-source-1e6cdd0e228547-rgb, 180, 35, 53), var(--ui-source-1e6cdd0e228547-alpha, 1));
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-actions:has(.history-name-unavailable) {
  align-items: center;
  gap: 4px;
}
html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-unavailable { font-size: 11px; }
@media (max-width: 900px) {
  html:not([data-ui="mobile"]) body[data-theme] .main.screen-main:has(.history-match-workspace) {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  html:not([data-ui="mobile"]) body[data-theme] .main.screen-main:has(.history-match-workspace) > .project-context-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
  }
  html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace { gap: 8px; }
  html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace > .name-combination-mode {
    flex-wrap: nowrap;
    padding-bottom: 6px;
    overflow-x: auto;
  }
  html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace .history-name-results { padding: 10px 10px 0; }
}

@media (forced-colors: active) {
  html:not([data-ui="mobile"]) body[data-theme] .history-match-workspace {
    --history-panel: Canvas; --history-card: Canvas;
    --history-line: ButtonBorder; --history-name: CanvasText;
    --history-text: CanvasText; --history-muted: GrayText;
    --history-accent: Highlight; --history-on-accent: HighlightText;
    --history-button: ButtonFace; --history-button-text: ButtonText;
    --history-button-line: ButtonBorder; --history-selected: Canvas;
  }
}
