:root {
  --added-bg: #d4f4dd;
  --added-fg: #1f7a3d;
  --removed-bg: #fbd5d5;
  --removed-fg: #a01f1f;
  --bg: #f7f7f7;
  --panel: #ffffff;
  --border: #ddd;
  --text: #222;
  --muted: #666;
  --accent: #2e6df5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --added-bg: #143d22;
    --added-fg: #7fd99a;
    --removed-bg: #4a1818;
    --removed-fg: #f4a3a3;
    --bg: #181a1f;
    --panel: #23262d;
    --border: #3a3d44;
    --text: #e6e6e6;
    --muted: #999;
    --accent: #6da0ff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
}

header h1 {
  margin: 0;
  font-size: 1.4rem;
}

header p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.lang-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.lang-switch button {
  padding: 0.4rem 0.75rem;
  border: 0;
  border-radius: 0;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.85rem;
  font: inherit;
  cursor: pointer;
}

.lang-switch button.active {
  background: var(--accent);
  color: #fff;
}

.lang-switch button:not(.active):hover {
  background: var(--bg);
  color: var(--text);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

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

.mode-group {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.75rem 0.5rem;
  margin: 0;
  background: var(--panel);
}

.mode-group legend {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0 0.25rem;
}

.mode-group label {
  margin-right: 0.75rem;
  font-size: 0.95rem;
}

.checkbox {
  font-size: 0.95rem;
}

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

button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}

button:hover {
  border-color: var(--accent);
}

.inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
  .inputs { grid-template-columns: 1fr; }
  .buttons { margin-left: 0; }
}

.input-col label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

textarea {
  width: 100%;
  min-height: 220px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  resize: vertical;
  background: var(--panel);
  color: var(--text);
}

textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.result {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
}

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

.result-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.legend {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.swatch.added { background: var(--added-bg); }
.swatch.removed { background: var(--removed-bg); }

#diff-output {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
  overflow: auto;
  min-height: 4rem;
}

#diff-output:empty::before {
  content: attr(data-empty-hint);
  color: var(--muted);
  font-style: italic;
}

#diff-output .added {
  background: var(--added-bg);
  color: var(--added-fg);
}

#diff-output .removed {
  background: var(--removed-bg);
  color: var(--removed-fg);
  text-decoration: line-through;
}

footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

footer a {
  color: var(--muted);
}
