/* ==========================================================================
   クラスレスCSS
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", MeiRyo, sans-serif;
  --font-mono: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;

  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-border: #e2e8f0;
  --color-code-bg: #f1f5f9;
  --color-blockquote-bg: #f8fafc;
  --color-header-bg: rgba(255, 255, 255, 0.85);

  --max-width: 760px;
  --radius: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-primary: #3b82f6;
    --color-primary-hover: #60a5fa;
    --color-border: #334155;
    --color-code-bg: #0f172a;
    --color-blockquote-bg: #1e293b;
    --color-header-bg: rgba(15, 23, 42, 0.85);
  }
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.8;
  letter-spacing: 0.02em;
  word-break: break-word;
}

body > header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1rem;
}

body > header > div,
body > header {
  max-width: var(--max-width);
  margin: 0 auto;
}

body > header h1,
body > header h2 {
  font-size: 1.35rem;
  margin: 0 0 0.5rem 0;
  border: none;
  padding: 0;
  text-align: center;
}

body > header h1 a,
body > header h2 a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: bold;
}

nav {
  margin: 0 auto;
  padding: 0.25rem 0;
}

nav ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 0.5rem 1rem;
}

nav li {
  margin: 0;
  padding: 0;
}

nav a {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--radius);
  transition: background-color 0.2s, color 0.2s;
}

nav a:hover,
nav a[aria-current="page"] {
  background-color: var(--color-primary);
  color: #ffffff;
}

body > main {
  max-width: var(--max-width);
  margin: 2rem auto;
  padding: 2rem 1.25rem;
  background-color: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 60vh;
}

body > footer {
  max-width: var(--max-width);
  margin: 2rem auto 0;
  padding: 2rem 1.25rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

body > footer nav {
  margin-bottom: 1rem;
}

body > footer nav a {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.4;
  font-weight: 700;
  color: var(--color-text);
}

main h1 {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  margin-top: 0;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-primary);
}

main h2 {
  font-size: clamp(1.3rem, 4vw, 1.6rem);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-left: 0.75rem;
  border-left: 4px solid var(--color-primary);
}

main h3 {
  font-size: clamp(1.1rem, 3vw, 1.3rem);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

p {
  margin-top: 0;
  margin-bottom: 1.5rem;
}

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}

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

ul, ol {
  margin-top: 0;
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

li::marker {
  color: var(--color-primary);
}

blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background-color: var(--color-blockquote-bg);
  border-left: 4px solid var(--color-text-muted);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
}

blockquote p:last-child {
  margin-bottom: 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--color-code-bg);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: var(--color-code-bg);
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  overflow-x: auto;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

pre code {
  background-color: transparent;
  padding: 0;
  border: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

@media (min-width: 600px) {
  table {
    display: table;
    white-space: normal;
  }
}

th, td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  text-align: left;
}

th {
  background-color: var(--color-code-bg);
  font-weight: bold;
}

img, video {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
  margin: 1.5rem auto;
}

figure {
  margin: 1.5rem 0;
  text-align: center;
}

figcaption {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2.5rem 0;
}

input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background-color: var(--color-bg);
  color: var(--color-text);
  appearance: none;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--color-primary);
  border-color: transparent;
}

button, input[type="submit"] {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  background-color: var(--color-primary);
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.2s;
  width: auto;
}

button:hover, input[type="submit"]:hover {
  background-color: var(--color-primary-hover);
}

aside {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background-color: #fef3c7;
  border: 1px solid #f59e0b;
  border-left: 6px solid #d97706;
  border-radius: var(--radius);
  color: #92400e;
}

@media (prefers-color-scheme: dark) {
  aside {
    background-color: #451a03;
    border-color: #b45309;
    border-left-color: #f59e0b;
    color: #fde68a;
  }
}

aside p:last-child {
  margin-bottom: 0;
}