:root {
  --bg: #fbf7f0;
  --surface: #ffffff;
  --border: #e3dbcd;
  --text: #2b2a26;
  --muted: #6f6a60;
  --accent: #b4531f;
  --accent-weak: #f6e7dc;
  --focus: #1f6feb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(43, 42, 38, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --surface: #201e18;
    --border: #3a362c;
    --text: #f0ece2;
    --muted: #a9a294;
    --accent: #f0a26a;
    --accent-weak: #33261b;
    --focus: #6ea8fe;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', Meiryo,
    sans-serif;
  line-height: 1.7;
  font-size: 16px;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- layout */

.layout {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

.site-header {
  padding: 16px 0 8px;
}

.header-inner {
  position: relative;
  display: block;
  line-height: 0;
  text-decoration: none;
}

.header-image {
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: cover;
  object-position: 70% 35%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ヘッダー画像は背景が白の一枚絵なので、文字色はテーマに依存させない */
.wordmark {
  position: absolute;
  left: 5%;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 18px;
  line-height: 1.1;
  color: #2b2a26;
  background: rgba(255, 255, 255, 0.78);
  border-radius: var(--radius);
}

.site-title {
  font-size: clamp(1.6rem, 6vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.14em;
}

.site-tagline {
  font-size: clamp(0.7rem, 1.8vw, 0.95rem);
  letter-spacing: 0.04em;
  color: #6f6a60;
}

.columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  align-items: start;
}

@media (min-width: 768px) {
  .columns {
    grid-template-columns: 260px minmax(0, 1fr);
    grid-template-areas: 'sidebar main';
  }

  main {
    grid-area: main;
  }

  /* モバイルではメインコンテンツの下にサイドバーを表示する */
  .sidebar {
    grid-area: sidebar;
    position: sticky;
    top: 16px;
  }
}

/* --------------------------------------------------------------- sidebar */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.sidebar-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  box-shadow: var(--shadow);
}

.sidebar-section h2 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.sidebar ol,
.sidebar ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking li,
.newest li,
.search-results li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

.ranking li:first-child,
.newest li:first-child,
.search-results li:first-child {
  border-top: none;
}

.ranking .count {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

.newest .reading {
  color: var(--muted);
}

.newest time {
  width: 100%;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- forms */

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

input[type='text'],
input[type='search'] {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

button {
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.turnstile-holder:empty,
.cf-turnstile:empty {
  min-height: 0;
}

.preview {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
}

/* ------------------------------------------------------------------ main */

main {
  min-width: 0;
}

.home-title,
.word-title {
  margin: 0 0 8px;
  font-size: 1.9rem;
  line-height: 1.3;
  word-break: break-word;
}

.word-title {
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
}

.lead {
  margin: 0 0 24px;
  color: var(--muted);
}

.home-words {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.home-word {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.home-word h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.home-note {
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.pronunciations {
  margin: 16px 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pronunciation {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.pronunciation.voted {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.pronunciation .reading {
  font-size: 1.15rem;
  font-weight: 600;
  word-break: break-word;
}

.pronunciation .count {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.count-unit {
  margin-left: 2px;
  font-size: 0.75rem;
}

.voted-badge {
  padding: 2px 8px;
  font-size: 0.75rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  white-space: nowrap;
}

.pronunciations.readonly .count {
  margin-left: auto;
}

/* 新しい読み方の登録フォームはスクロールしても見えるようにする */
.register-inline {
  position: sticky;
  bottom: 0;
  margin-top: 24px;
  padding: 14px 16px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -2px 12px rgba(43, 42, 38, 0.08);
}

.register-inline h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.notice {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.empty {
  color: var(--muted);
}

.error-text {
  color: #b3261e;
}

.info-text {
  color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  .error-text {
    color: #f2b8b5;
  }
}

.loading {
  color: var(--muted);
}

/* ----------------------------------------------------------------- error */

.error-status {
  margin: 0;
  font-size: 3rem;
}

.error-message {
  font-size: 1.1rem;
}

.error-code code {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ----------------------------------------------------------- static pages */

.prose h1 {
  margin-top: 0;
}

.prose h2 {
  margin-top: 32px;
  font-size: 1.15rem;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.prose li {
  margin: 4px 0;
}

.prose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.copyright {
  margin: 8px 0 0;
}
