.compare-page {
  background: var(--color-surface);
  font-family: system-ui, sans-serif;
}

.compare-page .wrap {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.compare-page main {
  width: min(1440px, calc(100% - 64px));
  display: block;
  margin: 0 auto;
  padding: 4px 0 28px;
}

.compare-heading-icon {
  position: relative;
  z-index: 1;
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 64px;
  height: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--color-primary);
  cursor: pointer;
}

.compare-page .compare-heading-icon:hover:not(:disabled) {
  background: transparent;
  color: var(--color-primary);
}

.file-import-dialog {
  width: min(420px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 24px;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 16px 64px #0003;
}

.file-import-dialog::backdrop {
  background: #0006;
}

.file-import-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.file-import-head h2 {
  margin: 0;
  font-size: 18px;
}

.file-import-dialog p {
  margin: 12px 0 0;
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.6;
}

.file-import-targets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.file-import-targets button {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 18px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.file-import-targets span {
  color: var(--color-muted);
  font-size: 12px;
}

.file-import-dialog .file-import-help {
  font-size: 11px;
}

.file-import-status {
  position: fixed;
  z-index: 1100;
  right: 16px;
  bottom: 16px;
  max-width: min(400px, calc(100% - 32px));
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 12px;
  overflow-wrap: anywhere;
  box-shadow: 0 6px 24px #0002;
}

.editor-shell.is-file-dragover {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.editor-shell.is-file-dragover .CodeMirror,
.editor-shell.is-file-dragover > textarea {
  background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface));
}

.compare-heading-icon svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace-breadcrumb {
  color: var(--color-muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-decoration: none;
}

.workspace-breadcrumb span {
  padding: 0 7px;
  opacity: 0.5;
}

.title-dot {
  color: var(--color-primary);
}

.compare-page .compare-workspace {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--color-border) 75%, var(--color-surface));
  border-radius: 12px;
  background: var(--color-surface);
  box-shadow: 0 5px 24px #00000004;
}

.workspace-toolbar,
.workspace-options,
.compare-summary,
.summary-counts,
.change-navigation,
.editor-card-head,
.editor-card-actions,
.workspace-status,
.workspace-status > div {
  display: flex;
  align-items: center;
}

.workspace-toolbar {
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--color-muted) 7%, var(--color-surface));
}

.workspace-options {
  gap: 18px;
}

.editor-card-option,
.sync-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-muted);
  font-size: 12px;
}

.editor-card-option {
  margin: 0;
}

.editor-card-option input {
  width: 13px;
  height: 13px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--color-primary);
}

.compare-summary {
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-muted) 5%, var(--color-surface));
  color: var(--color-muted);
  font-size: 12px;
}

.summary-counts {
  flex-wrap: wrap;
  gap: 18px;
}

.summary-counts strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.total-count {
  color: var(--color-text);
}

.added-count {
  color: #16804d;
}

.removed-count {
  color: #c34747;
}

.change-navigation {
  gap: 4px;
  flex-shrink: 0;
}

#changePosition {
  min-width: 42px;
  padding-right: 8px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.compare-page .editor-action,
.compare-page .workspace-control,
.compare-page .conversion-direction,
.compare-page .plain-icon-btn,
.compare-page .modal-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 7px;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  margin: 0;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--color-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.compare-page .reset-action,
.compare-page .modal-close-btn {
  width: auto;
  padding: 7px 12px;
  border-color: var(--color-border);
}

.compare-page button:hover:not(:disabled),
.compare-page .editor-card-option:hover {
  background: color-mix(in srgb, var(--color-muted) 9%, var(--color-surface));
  color: var(--color-text);
}

.compare-page .workspace-control {
  width: auto;
  padding: 6px 8px;
  border-color: var(--color-border);
  background: var(--color-surface);
  white-space: nowrap;
}

.compare-page .workspace-control[aria-pressed='true'],
.compare-page .editor-card-option:has(input:checked) {
  border-color: color-mix(in srgb, var(--color-primary) 25%, var(--color-border));
  background: color-mix(in srgb, var(--color-primary) 8%, var(--color-surface));
  color: var(--color-primary);
}

.sync-label > [aria-hidden] {
  font-size: 15px;
  line-height: 1;
}

.compare-page button:disabled {
  opacity: 0.35;
  cursor: default;
}

.compare-page button:focus-visible,
.compare-page .editor-card-option:has(input:focus-visible),
.compare-page summary:focus-visible,
.unified-panel:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.editor-action svg,
.conversion-direction svg,
.plain-icon-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.compare-card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  margin: 0;
}

.editor-shell {
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.editor-empty-hint {
  position: absolute;
  z-index: 5;
  inset: 48px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: var(--color-muted);
  font:
    12px/1.5 system-ui,
    sans-serif;
  text-align: center;
  pointer-events: none;
}

.editor-empty-hint[hidden] {
  display: none;
}

.editor-empty-hint svg {
  width: 28px;
  height: 28px;
  margin-bottom: 6px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.65;
}

.editor-empty-hint strong {
  font-size: 13px;
  font-weight: 500;
}

.editor-empty-hint span {
  font-size: 11px;
  opacity: 0.8;
}

.editor-shell + .editor-shell {
  border-left: 1px solid var(--color-border);
}

.editor-card-head {
  justify-content: space-between;
  gap: 8px;
  height: 48px;
  padding: 0 14px 0 20px;
  border-bottom: 1px solid var(--color-border);
}

.compare-page .editor-card-head h3 {
  margin: 0;
  color: var(--color-text);
  font-size: 12px;
  font-weight: 550;
}

.editor-card-head > span {
  color: var(--color-muted);
  font-size: 11px;
}

.editor-card-actions {
  gap: 2px;
}

.compare-page .CodeMirror,
.compare-page textarea {
  background: var(--color-surface);
  color: var(--color-text);
  font:
    13px/1.8 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
}

.compare-page .CodeMirror {
  height: clamp(480px, 55vh, 600px);
}

.compare-page .CodeMirror-lines {
  padding: 16px 0;
}

.compare-page .CodeMirror-gutters {
  border: 0;
  background: var(--color-surface);
}

.compare-page .CodeMirror-linenumber {
  padding: 0 9px;
  color: var(--color-muted);
  opacity: 0.65;
}

.compare-page .CodeMirror-cursor {
  border-color: var(--color-text);
}

.compare-page .CodeMirror-selected {
  background: color-mix(in srgb, var(--color-primary) 20%, transparent);
}

.diff-gutter {
  width: 16px;
}

.diff-marker {
  color: var(--color-muted);
  font-weight: 700;
}

.diff-line-added,
#panel-right .diff-line-modified,
.unified-row.is-added {
  background: color-mix(in srgb, #21a366 12%, transparent);
}

.diff-line-removed,
#panel-left .diff-line-modified,
.unified-row.is-removed {
  background: color-mix(in srgb, #df5555 11%, transparent);
}

#panel-left .highlight-line {
  background: color-mix(in srgb, #df5555 22%, transparent);
}

#panel-right .highlight-line {
  background: color-mix(in srgb, #21a366 24%, transparent);
}

.diff-current {
  box-shadow: inset 3px 0 var(--color-primary);
}

.compare-page textarea {
  width: 100%;
  min-height: 480px;
  padding: 16px;
  border: 0;
  resize: vertical;
}

.workspace-status {
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 8px 20px;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 10px;
}

.workspace-status > div {
  gap: 20px;
}

.workspace-status strong {
  font-weight: 400;
}

.comparison-details {
  position: relative;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 12px;
}

.comparison-details summary {
  padding: 15px 64px 15px 20px;
  cursor: pointer;
}

.comparison-details summary span {
  margin-left: 10px;
  font-size: 10px;
  opacity: 0.7;
}

.comparison-details-body {
  max-width: 820px;
  padding: 0 20px 20px;
}

.comparison-details > .plain-icon-btn {
  position: absolute;
  top: 8px;
  left: calc(8px + (min(100%, 820px) - 40px) * 0.93);
}

.compare-chart {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 12px;
  font:
    12px system-ui,
    sans-serif;
}

.compare-chart text {
  fill: currentColor;
}

.comparison-message {
  margin: 0;
  padding: 12px 20px;
  color: var(--color-text);
  font-size: 12px;
}

.workspace-footnote {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin: 14px 2px 0;
  color: var(--color-muted);
  font-size: 10px;
}

.hidden-sync,
.mobile-editor-actions,
.workspace-tabs,
.unified-panel[hidden] {
  display: none;
}

.workspace-mobile-toolbar {
  display: contents;
}

.unified-panel {
  min-width: 0;
}

.unified-diff {
  height: 50dvh;
  overflow: auto;
  padding: 12px 0;
  font:
    12px/1.8 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
}

.unified-row {
  display: grid;
  grid-template-columns: 30px 30px 20px minmax(0, 1fr);
  min-height: 24px;
  padding-right: 12px;
}

.unified-row > span {
  color: var(--color-muted);
  font-size: 10px;
  text-align: center;
}

.unified-row code {
  color: var(--color-text);
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diff-empty {
  margin: 0;
  padding: 48px 24px;
  color: var(--color-muted);
  font:
    12px/1.7 system-ui,
    sans-serif;
  text-align: center;
}

.compare-page .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 1100;
  transform: translateX(-50%);
  padding: 12px 20px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 8px 30px #0002;
}

.editor-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0008;
}

.editor-modal.is-open {
  display: flex;
}

.editor-modal-dialog {
  display: flex;
  flex-direction: column;
  width: min(100%, 1100px);
  max-height: calc(100dvh - 48px);
  padding: 20px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  color: var(--color-text);
}

.editor-modal-head,
.editor-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-modal-body {
  min-height: 0;
  overflow: auto;
  margin: 16px 0;
}

.compare-page .editor-modal-textarea {
  height: 60dvh;
  min-height: 160px;
  border: 1px solid var(--color-border);
}

.editor-modal-actions {
  justify-content: flex-end;
}

.calculator-button,
.calculator-ghost-button {
  padding: 10px 15px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

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

@media (prefers-color-scheme: dark) {
  .added-count {
    color: #6acb93;
  }

  .removed-count {
    color: #f18c8c;
  }
}

@media (max-width: 768px) {
  .compare-page main {
    width: 100%;
    padding-top: 0;
  }

  .compare-heading .workspace-breadcrumb {
    display: block;
    line-height: 1.4;
  }

  .compare-heading-icon {
    width: 36px;
    height: 28px;
    min-height: 28px;
    margin-bottom: 0;
    padding: 0;
    border-radius: 10px;
  }

  .compare-heading-icon svg {
    width: 26px;
    height: 26px;
  }

  .compare-page .compare-workspace {
    margin-top: 0;
  }

  .workspace-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    min-height: 50px;
    padding: 12px 16px;
  }

  .workspace-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    flex-basis: 100%;
    gap: 8px;
  }

  .compare-page .workspace-options > .workspace-control,
  .compare-page .workspace-options > .reset-action {
    gap: clamp(3px, 1vw, 6px);
    width: 100%;
    min-width: 0;
    height: 34px;
    min-height: 34px;
    margin: 0;
    padding: 4px;
    font-size: clamp(10px, 2.8vw, 12px);
    white-space: nowrap;
  }

  .workspace-options .editor-card-option input,
  .workspace-options button svg {
    flex-shrink: 0;
  }

  .compare-page .sync-label,
  .workspace-footnote {
    display: none;
  }

  .compare-summary {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 10px 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    font-size: clamp(10px, 2.8vw, 11px);
  }

  .summary-counts {
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: clamp(6px, 2vw, 12px);
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .summary-counts > span {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .change-navigation {
    align-self: flex-end;
  }

  .workspace-mobile-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 16px;
  }

  .mobile-editor-actions {
    display: flex;
    flex-shrink: 0;
  }

  .compare-page .mobile-editor-actions .editor-action {
    width: 36px;
    min-width: 36px;
    height: 40px;
    min-height: 40px;
    padding: 8px;
  }

  .workspace-tabs {
    display: flex;
    flex: 1;
    min-width: 0;
    gap: 2px;
    margin: 0;
    padding: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .compare-page .workspace-tabs button {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 40px;
    margin: 0;
    padding: 8px 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--color-muted);
    font-family: system-ui, sans-serif;
    font-size: clamp(10px, 2.9vw, 12px);
    cursor: pointer;
  }

  .compare-page .workspace-tabs button[aria-selected='true'] {
    background: transparent;
    color: var(--color-primary);
    font-weight: 600;
  }

  .workspace-tabs button[aria-selected='true']::after {
    position: absolute;
    right: 4px;
    bottom: -1px;
    left: 4px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--color-primary);
    content: '';
  }

  .compare-page .workspace-tabs button:focus-visible {
    outline-color: var(--color-text);
    outline-offset: -3px;
  }

  .compare-card-grid {
    display: block;
    height: var(--mobile-editor-height, 50dvh);
    min-height: 96px;
  }

  .editor-shell.is-mobile-active,
  .unified-panel:not([hidden]) {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
  }

  .editor-shell:not(.is-mobile-active) {
    display: none;
  }

  .editor-shell + .editor-shell {
    border-left: 0;
  }

  .editor-card-head {
    flex-shrink: 0;
    height: 46px;
    padding: 0 16px;
  }

  .compare-card-grid .editor-card-head {
    display: none;
  }

  .editor-empty-hint {
    top: 0;
  }

  .compare-page .CodeMirror,
  .compare-page .editor-shell > textarea,
  .unified-diff {
    flex: 1;
    height: 0;
    min-height: 0;
  }

  .compare-page .editor-action {
    width: 34px;
    height: 34px;
  }

  .compare-page .reset-action {
    width: auto;
  }

  .workspace-status {
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px;
  }

  .workspace-status > div {
    gap: 12px;
  }

  .comparison-details {
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.6;
  }

  .comparison-details summary {
    padding: 14px 60px 14px 16px;
  }

  .comparison-details > .plain-icon-btn {
    top: 10px;
    right: 16px;
    left: auto;
  }

  .comparison-details-body {
    padding-inline: 16px;
  }

  .compare-chart {
    font-size: 13px;
  }

  .comparison-details summary span {
    display: none;
  }

  .editor-modal {
    padding: 10px;
  }

  .editor-modal-dialog {
    max-height: calc(100dvh - 20px);
    padding: 14px;
  }
}
