:root {
  --bg: #f7f7f7;
  --panel: #ffffff;
  --border: #ddd;
  --text: #222;
  --muted: #666;
  --accent: #2e6df5;
  --error-bg: #fbd5d5;
  --error-fg: #a01f1f;
}

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

* { 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: 1400px;
  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: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.field select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  min-width: 9rem;
}

.checkbox {
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding-bottom: 0.4rem;
}

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

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

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

#format-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#format-btn:hover {
  filter: brightness(1.08);
}

.panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.pane {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
}

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

.pane-header label {
  font-weight: 600;
  font-size: 0.9rem;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.pane-actions {
  display: flex;
  gap: 0.5rem;
}

.pane-actions button {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

textarea {
  width: 100%;
  min-height: 55vh;
  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(--bg);
  color: var(--text);
  tab-size: 4;
}

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

#output {
  background: var(--panel);
}

.error {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  background: var(--error-bg);
  color: var(--error-fg);
  border-radius: 4px;
  font-size: 0.85rem;
  white-space: pre-wrap;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

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