:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --notice-bg: #fef3c7;
  --notice-border: #f59e0b;
  --notice-text: #92400e;
  --editor-font: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #38bdf8;
    --primary-hover: #7dd3fc;
    --notice-bg: rgba(245, 158, 11, 0.12);
    --notice-border: #f59e0b;
    --notice-text: #fcd34d;
  }
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.material-symbols-outlined {
  font-size: 1.25rem;
  vertical-align: middle;
}

code {
  font-family: var(--editor-font);
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(2, 132, 199, 0.1);
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-header__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.site-header__nav {
  display: flex;
  gap: 1.25rem;
}

.site-header__nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.site-header__nav a:hover {
  color: var(--primary);
}

.page {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.page__eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
}

.page h1 {
  margin: 0 0 0.75rem;
  font-size: 1.75rem;
  font-weight: 600;
}

.page__lead {
  margin: 0 0 0.5rem;
  max-width: 52rem;
  color: var(--text-muted);
}

.page__note {
  margin: 0 0 1.5rem;
  max-width: 52rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.page__notice {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0 0 1.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--notice-border);
  border-radius: 8px;
  background: var(--notice-bg);
  color: var(--notice-text);
  font-size: 0.95rem;
}

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

.toolbar__status {
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.toolbar__status--error {
  color: #dc2626;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn--primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn--secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn--secondary:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn--ghost:hover {
  color: var(--text);
}

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  min-height: 420px;
}

@media (max-width: 768px) {
  .panels {
    grid-template-columns: 1fr;
  }
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 360px;
}

.panel__label {
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.legend__swatch {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  margin-right: 0.35rem;
  border-radius: 3px;
  vertical-align: -0.1rem;
}

.legend__swatch--removed {
  background: rgba(239, 68, 68, 0.35);
}

.legend__swatch--moved {
  background: rgba(249, 115, 22, 0.35);
}

.legend__swatch--added {
  background: rgba(34, 197, 94, 0.35);
}

.editor-stack {
  position: relative;
  flex: 1;
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.editor-highlight,
.editor-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0.85rem 1rem;
  border: none;
  font-family: var(--editor-font);
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
  tab-size: 2;
}

.editor-highlight {
  pointer-events: none;
  color: transparent;
  background: var(--surface);
}

.editor-highlight .hl-removed {
  background: rgba(239, 68, 68, 0.22);
  color: transparent;
}

.editor-highlight .hl-moved {
  background: rgba(249, 115, 22, 0.22);
  color: transparent;
}

.editor-highlight .hl-added {
  background: rgba(34, 197, 94, 0.22);
  color: transparent;
}

.editor-input {
  resize: none;
  color: var(--text);
  background: transparent;
  caret-color: var(--text);
}

.editor-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.editor-input--readonly {
  background: transparent;
}

.changes-summary {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.9rem;
}

.changes-summary summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
}

.changes-summary__body {
  margin: 0.75rem 0 0;
  max-height: 240px;
  overflow: auto;
  font-family: var(--editor-font);
  font-size: 0.8rem;
}

.changes-summary__item {
  display: flex;
  gap: 0.65rem;
  align-items: baseline;
  padding: 0.25rem 0.45rem;
  border-radius: 4px;
  line-height: 1.45;
}

.changes-summary__label {
  flex: 0 0 4.5rem;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

.changes-summary__path {
  color: var(--text-muted);
  word-break: break-word;
}

.changes-summary__item--removed {
  background: rgba(239, 68, 68, 0.12);
}

.changes-summary__item--removed .changes-summary__label {
  color: #dc2626;
}

.changes-summary__item--moved {
  background: rgba(249, 115, 22, 0.12);
}

.changes-summary__item--moved .changes-summary__label {
  color: #ea580c;
}

.changes-summary__item--added {
  background: rgba(34, 197, 94, 0.12);
}

.changes-summary__item--added .changes-summary__label {
  color: #16a34a;
}

@media (prefers-color-scheme: dark) {
  .changes-summary__item--removed .changes-summary__label {
    color: #f87171;
  }

  .changes-summary__item--moved .changes-summary__label {
    color: #fb923c;
  }

  .changes-summary__item--added .changes-summary__label {
    color: #4ade80;
  }
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--primary);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}
