:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --code-bg: #f1f5f9;
  --error: #b91c1c;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #1f2937;
    --accent: #60a5fa;
    --accent-text: #0b1120;
    --code-bg: #0f172a;
    --error: #f87171;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.7 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

a { color: var(--accent); }

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  max-width: 64rem;
  margin: 0 auto;
  padding: 1rem;
}

.brand {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

nav { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.95rem; }
nav a[aria-current] { color: var(--text); font-weight: 700; text-decoration: none; }

main { max-width: 64rem; margin: 0 auto; padding: 0 1rem 2rem; }

section {
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

h2 { margin: 0 0 0.75rem; font-size: 1.2rem; }

.lead { font-size: 1.05rem; }
.note { color: var(--muted); font-size: 0.92rem; }
.error { color: var(--error); font-weight: 600; }

label { display: block; margin-bottom: 0.25rem; font-weight: 600; }

textarea {
  width: 100%;
  padding: 0.75rem;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.actions { margin: 0.75rem 0 0; }

button {
  padding: 0.5rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: 0.5rem;
  cursor: pointer;
}

button.secondary {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}

button:focus-visible, a:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* The editor's own look, through its public CSS variables only. */
ohashi-rich-text-editor {
  --orte-editor-bg: var(--surface);
  --orte-text-color: var(--text);
  --orte-border-color: var(--border);
  --orte-accent-color: var(--accent);
  --orte-toolbar-bg: var(--code-bg);
  --orte-muted-color: var(--muted);
  --orte-code-bg: var(--code-bg);
  --orte-code-color: var(--text);
  --orte-min-height: 12rem;
}

.compare { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }

figure { margin: 1rem 0 0; min-width: 0; }
figcaption { margin-bottom: 0.35rem; font-weight: 600; font-size: 0.95rem; }

pre {
  margin: 0;
  padding: 0.75rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

/* Saved HTML as a site would show it. */
.rendered {
  padding: 0.75rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 0.5rem;
}
.rendered :first-child { margin-top: 0; }
.rendered :last-child { margin-bottom: 0; }
.rendered blockquote { margin: 1rem 0; padding-left: 1rem; color: var(--muted); border-left: 3px solid var(--border); }
.rendered pre code { white-space: pre; }
.rendered img { max-width: 100%; height: auto; }

#result form { margin-top: 1rem; }

footer { max-width: 64rem; margin: 0 auto; padding: 1rem; color: var(--muted); font-size: 0.85rem; }
