/* ── Dark matte-instrument theme ───────────────────────────────────── */
.diff-checker-page {
  --dc-bg: #0d1117;
  --dc-surface: #161b22;
  --dc-surface-2: #1c2130;
  --dc-border: rgba(48, 80, 58, 0.55);
  --dc-emerald: #059669;
  --dc-emerald-hi: #34d399;
  --dc-emerald-tint: rgba(5, 150, 105, 0.15);
  --dc-coral: #e63946;
  --dc-coral-tint: rgba(230, 57, 70, 0.14);
  --dc-amber: #f59e0b;
  --dc-unchanged: #374151;
  --dc-text: #e6edf3;
  --dc-text-muted: #8b949e;
  --dc-label: #7ee8c0;
  --dc-frame-width: 1040px;

  /* Override shared tokens so discovery block reads correctly on dark bg */
  --color-bg: var(--dc-bg);
  --color-surface: var(--dc-surface);
  --color-surface-2: var(--dc-surface-2);
  --color-text: var(--dc-text);
  --color-text-muted: var(--dc-text-muted);
  --color-border: var(--dc-border);

  background: var(--dc-bg);
  color: var(--dc-text);
}

.diff-checker-page .tool-frame {
  max-width: var(--dc-frame-width);
}

.diff-checker-page .tool-header-block {
  max-width: 640px;
  margin-bottom: 0.4rem;
}

.diff-checker-page .page-title {
  font-size: clamp(1.85rem, 4vw, 2.7rem);
  line-height: 1.0;
  letter-spacing: -0.03em;
  color: var(--dc-text);
}

.diff-checker-page .page-subtitle {
  max-width: 52ch;
  color: var(--dc-text-muted);
  font-size: 1rem;
  line-height: 1.4;
}

.dc-meta-line {
  margin: 0.3rem 0 0;
  font-size: 0.78rem;
  color: var(--dc-text-muted);
  opacity: 0.75;
}

/* ── Tool shell ──────────────────────────────────────────────────────── */
.diff-checker-page .tool-shell {
  padding: 1.25rem;
  border-radius: 1.3rem;
  border: 1px solid var(--dc-border);
  background: var(--dc-surface);
  box-shadow:
    0 0 0 1px rgba(5, 150, 105, 0.08),
    0 20px 48px rgba(0, 0, 0, 0.45);
}

/* ── Input panels ─────────────────────────────────────────────────────── */
.dc-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dc-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.dc-panel-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}

.dc-panel-eyebrow-rule {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--dc-emerald);
  flex-shrink: 0;
}

.dc-panel-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dc-label);
}

/* Distinguish the two panels instead of mirroring them: ORIGINAL reads as the
   muted baseline; MODIFIED keeps the emerald accent that ties it to the green
   added-line colour, so the eye knows which side holds the changes. */
.dc-panels .dc-panel:first-child .dc-panel-eyebrow-rule {
  background: var(--dc-unchanged);
}
.dc-panels .dc-panel:first-child .dc-panel-label {
  color: var(--dc-text-muted);
}

.dc-textarea {
  width: 100%;
  min-height: 10rem;
  padding: 0.75rem;
  background: var(--dc-bg);
  color: var(--dc-text);
  border: 1px solid var(--dc-border);
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.5;
  font-family: "Menlo", "Consolas", "Monaco", monospace;
  resize: vertical;
  box-sizing: border-box;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dc-textarea::placeholder {
  color: var(--dc-text-muted);
  opacity: 0.5;
}

.dc-textarea:focus {
  outline: none;
  border-color: var(--dc-emerald);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.3),
    0 0 0 2px rgba(5, 150, 105, 0.25);
}

/* ── Toolbar ─────────────────────────────────────────────────────────── */
.dc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* Toolbar buttons: override shared .button min-height so row stays compact */
.diff-checker-page .dc-toolbar .button {
  min-height: 0;
  height: 32px;
  padding: 0 12px;
  font-size: 0.78rem;
}

/* Toolbar hierarchy (was a flat row of 5 identical tiles):
   - Copy Diff is the takeaway action → emerald primary
   - the two example loaders are onboarding helpers → muted + a ▸ "try this" cue
   - Swap / Clear stay as neutral secondary buttons */
.diff-checker-page .dc-toolbar #dc-copy {
  background: var(--dc-emerald);
  border-color: var(--dc-emerald);
  color: #052016;
  font-weight: 700;
}
.diff-checker-page .dc-toolbar #dc-copy:hover {
  background: var(--dc-emerald-hi);
  border-color: var(--dc-emerald-hi);
}
.diff-checker-page .dc-toolbar #dc-load-cjk,
.diff-checker-page .dc-toolbar #dc-load-en {
  color: var(--dc-text-muted);
  background: transparent;
}
.diff-checker-page .dc-toolbar #dc-load-cjk::before,
.diff-checker-page .dc-toolbar #dc-load-en::before {
  content: "\25B8"; /* ▸ */
  margin-right: 5px;
  color: var(--dc-emerald-hi);
  font-size: 0.72em;
}
.diff-checker-page .dc-toolbar #dc-load-cjk:hover,
.diff-checker-page .dc-toolbar #dc-load-en:hover {
  color: var(--dc-text);
}
/* a small gap separating the example-loader pair from the operation buttons */
.diff-checker-page .dc-toolbar #dc-swap {
  margin-inline-start: 4px;
}

/* Focus-visible overrides scoped to this page */
.diff-checker-page .button-primary:focus-visible {
  outline: 2px solid var(--dc-emerald-hi);
  outline-offset: 2px;
}

.diff-checker-page .button-secondary:focus-visible {
  outline: 2px solid var(--dc-emerald);
  outline-offset: 2px;
}

/* ── Controls row ────────────────────────────────────────────────────── */
.dc-controls-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

/* ── Granularity chips ───────────────────────────────────────────────── */
.dc-granularity {
  display: flex;
  gap: 4px;
  background: var(--dc-bg);
  border: 1px solid var(--dc-border);
  border-radius: 8px;
  padding: 3px;
}

.dc-chip {
  padding: 3px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--dc-text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
  min-height: 0;
}

.dc-chip:hover {
  color: var(--dc-text);
  background: rgba(255, 255, 255, 0.05);
}

.dc-chip--active {
  background: var(--dc-emerald);
  color: #fff;
  box-shadow: 0 0 8px rgba(5, 150, 105, 0.5);
}

.dc-chip--active:hover {
  background: var(--dc-emerald);
  color: #fff;
}

.dc-chip:focus-visible {
  outline: 2px solid var(--dc-emerald-hi);
  outline-offset: 2px;
}

/* ── CJK pip ─────────────────────────────────────────────────────────── */
.dc-cjk-pip {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dc-amber);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
  cursor: help;
}

.dc-cjk-pip[hidden] {
  display: none;
}

/* ── Badge ────────────────────────────────────────────────────────────── */
.dc-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--dc-surface-2);
  border: 1px solid var(--dc-border);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.dc-badge[hidden] {
  display: none;
}

.dc-badge-adds {
  color: var(--dc-emerald-hi);
}

.dc-badge-dels {
  color: var(--dc-coral);
}

.dc-badge-neutral {
  color: var(--dc-text-muted);
}

/* ── Diff output ─────────────────────────────────────────────────────── */
.dc-output-wrap {
  margin-top: 10px;
  border: 1px solid var(--dc-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--dc-bg);
  min-height: 200px;
}

.dc-output {
  overflow-x: auto;
  font-size: 0.84rem;
  font-family: "Menlo", "Consolas", "Monaco", monospace;
  line-height: 1.55;
}

.dc-placeholder {
  padding: 1.5rem;
  margin: 0;
  color: var(--dc-text-muted);
  font-size: 0.84rem;
  text-align: center;
  opacity: 0.6;
  font-family: inherit;
}

/* ── Diff rows ───────────────────────────────────────────────────────── */
.dc-diff-row {
  display: flex;
  align-items: stretch;
  min-width: max-content;
  width: 100%;
}

.dc-diff-row--added {
  background: rgba(5, 150, 105, 0.07);
}

.dc-diff-row--removed {
  background: rgba(230, 57, 70, 0.07);
}

.dc-diff-row--unchanged {
  background: transparent;
}

/* Gutter: 4px solid left border strip */
.dc-diff-gutter {
  flex-shrink: 0;
  width: 4px;
}

.dc-diff-row--added .dc-diff-gutter {
  background: var(--dc-emerald);
}

.dc-diff-row--removed .dc-diff-gutter {
  background: var(--dc-coral);
}

.dc-diff-row--unchanged .dc-diff-gutter {
  background: var(--dc-unchanged);
}

/* Prefix (+/-/ ) */
.dc-diff-prefix {
  flex-shrink: 0;
  width: 1.6em;
  padding: 3px 0 3px 6px;
  font-weight: 700;
  user-select: none;
}

.dc-diff-row--added .dc-diff-prefix {
  color: var(--dc-emerald-hi);
}

.dc-diff-row--removed .dc-diff-prefix {
  color: var(--dc-coral);
}

.dc-diff-row--unchanged .dc-diff-prefix {
  color: transparent;
}

/* Content cell */
.dc-diff-content {
  flex: 1;
  padding: 3px 10px 3px 4px;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: break-word;
  min-width: 0;
  color: var(--dc-text);
}

/* ── Inline token highlights ─────────────────────────────────────────── */
.diff-token-added {
  background: var(--dc-emerald-tint);
  color: var(--dc-emerald-hi);
  border-radius: 2px;
  padding: 0 1px;
}

.diff-token-removed {
  background: var(--dc-coral-tint);
  color: #ff6b75;
  border-radius: 2px;
  padding: 0 1px;
}

/* Inline note on a row whose line exceeded the 500-token inline-diff guard */
.dc-line-note {
  display: inline-block;
  margin-right: 8px;
  padding: 0 6px;
  border: 1px solid var(--dc-amber);
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--dc-amber);
  background: rgba(245, 158, 11, 0.1);
  white-space: nowrap;
  vertical-align: middle;
  cursor: help;
}

/* ── Toast ────────────────────────────────────────────────────────────── */
.dc-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 20px;
  background: var(--dc-surface-2);
  border: 1px solid var(--dc-emerald);
  color: var(--dc-emerald-hi);
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  opacity: 1;
  transition: opacity 0.3s;
}

.dc-toast[hidden] {
  display: none;
}

.dc-toast--fading {
  opacity: 0;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .dc-panels {
    grid-template-columns: 1fr;
  }

  .dc-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  /* WCAG 2.5.5: touch targets ≥44px on mobile. Desktop keeps the compact
     32px row; on touch viewports the buttons/chips must be tappable. */
  .diff-checker-page .dc-toolbar .button {
    width: 100%;
    justify-content: center;
    height: auto;
    min-height: 44px;
  }

  .dc-chip {
    min-height: 44px;
    padding: 3px 14px;
  }

  .diff-checker-page .tool-shell {
    padding: 0.875rem;
  }
}

@media (max-width: 440px) {
  .dc-toolbar {
    grid-template-columns: 1fr;
  }
}
