/* 悪魔の辞書 — 票が、活字の大きさになる。
   ライト固定（紙）。外部フォント無し。アクセントは朱一色。 */
:root {
  --paper: #faf8f3;
  --ink: #1a1816;
  --ink-2: #4a4540;
  --muted: #6b655d;
  --rule: #ddd6c9;
  --rule-strong: #b9b0a0;
  --field: #ffffff;
  --shu: #a8321c;        /* 朱。リンク・票・印 */
  --shu-wash: #f6e9e4;   /* 朱の薄い地 */
  --focus: #1d4ed8;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic Medium", "Noto Sans JP", -apple-system, system-ui, sans-serif;
  --latin-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --measure: 38rem;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4rem; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 1rem; line-height: 1.8;
  font-feature-settings: "palt" 0;
}
a { color: var(--shu); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }

main { max-width: 44rem; margin: 0 auto; padding: 0 1rem 2rem; }
.narrow { max-width: var(--measure); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.35; letter-spacing: 0.01em; margin: 0; }
h1 { font-size: 1.75rem; margin: 1.6rem 0 0.6rem; }
h2 { font-size: 0.95rem; color: var(--muted); font-family: var(--sans); font-weight: 600; letter-spacing: 0.08em; margin: 2.6rem 0 0.4rem; border-bottom: 1px solid var(--rule); padding-bottom: 0.3rem; }
p { margin: 0.4rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---- 頭 ---- */
header.top { background: var(--paper); position: sticky; top: 0; z-index: 5; }
.top-in {
  max-width: 44rem; margin: 0 auto; padding: 0.8rem 1rem 0.5rem;
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.75rem 1.4rem; align-items: center;
}
header .write { font-weight: 600; color: var(--ink); text-decoration: none; }
header .write:hover { color: var(--shu); }
.logo { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--serif); font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.logo svg { width: 1.1em; height: 1.1em; color: var(--shu); }
header .search { min-width: 0; }
header .search input {
  width: 100%; padding: 0.45rem 0.1rem; font: inherit; font-size: 0.95rem; color: var(--ink);
  border: 0; border-bottom: 1px solid var(--rule-strong); border-radius: 0; background: transparent;
}
header .search input:focus { border-bottom-color: var(--ink); outline: none; }
header .search input::-webkit-search-decoration { -webkit-appearance: none; }
header .search input::placeholder { color: var(--muted); }
header nav { display: flex; gap: 0.9rem; align-items: center; font-size: 0.9rem; white-space: nowrap; }
header nav a { text-decoration: none; }
header nav .me { max-width: 9em; overflow: hidden; text-overflow: ellipsis; }

/* ---- ボタン ---- */
.btn {
  display: inline-block; padding: 0.45rem 1rem; border: 1px solid var(--ink); border-radius: 2px;
  background: transparent; color: var(--ink); font: inherit; font-size: 0.95rem; cursor: pointer; text-decoration: none;
  line-height: 1.4;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.primary, .btn.write { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover, .btn.write:hover { background: var(--shu); border-color: var(--shu); }
.btn.danger { border-color: var(--shu); color: var(--shu); }
.btn.danger:hover { background: var(--shu); color: #fff; }
.btn.small { padding: 0.15rem 0.6rem; font-size: 0.85rem; }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* ---- 見本（表紙の一語） ---- */
.specimen { margin: 3rem 0 0; }
.specimen .kicker { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.08em; margin: 0 0 1.5rem; }
.specimen .headword { font-family: var(--serif); font-size: clamp(2.2rem, 7vw, 3.2rem); line-height: 1.15; margin: 0; }
.specimen .headword a { color: var(--ink); text-decoration: none; }
.specimen .headword a:hover { color: var(--shu); }
.specimen .body { font-family: var(--serif); font-size: 1.3rem; line-height: 1.7; margin: 0.6rem 0 0.2rem; }

/* ---- 語の頭 ---- */
.word-head { padding: 2.4rem 0 0.9rem; border-bottom: 1px solid var(--rule-strong); }
.word-head h1 { font-size: clamp(2.2rem, 7vw, 3.2rem); line-height: 1.15; margin: 0; }
ruby { ruby-position: over; }
rt { font-family: var(--sans); font-weight: 400; font-size: 0.3em; color: var(--muted); letter-spacing: 0.08em; }
.word-head ruby rt { font-size: 0.28em; }
.index rt, .word-list rt { font-size: 0.55em; }
.share-line { margin: 1.2rem 0 0; font-size: 0.85rem; }
.share-line a { color: var(--muted); }
.login-cta { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }

/* ---- 定義。順位が組版になる ---- */
.defs { counter-reset: def; }
.def { position: relative; padding: 1.3rem 0 1.1rem 2.1rem; border-bottom: 1px solid var(--rule); }
.defs .def:only-child { padding-left: 0; }
.def .num {
  position: absolute; left: 0; top: 1.45rem; width: 1.5rem; height: 1.5rem; line-height: 1.45rem; text-align: center;
  border: 1px solid var(--ink-2); border-radius: 50%; font-size: 0.72rem; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.def .body { margin: 0; font-size: 1.02rem; line-height: 1.85; }
.def.top { padding-top: 1.6rem; padding-bottom: 1.5rem; }
.def.top .num { border-color: var(--shu); color: var(--shu); background: var(--shu-wash); }
.def.top .body { font-family: var(--serif); font-size: 1.3rem; line-height: 1.7; }
.def .example { margin: 0.5rem 0 0; color: var(--ink-2); font-size: 0.93rem; padding-left: 0.8rem; border-left: 2px solid var(--rule-strong); }
.def-held { opacity: 0.8; border-left: 2px dashed var(--rule-strong); padding-left: 2.4rem; }
.def-word { margin: 0 0 0.2rem; font-size: 1.1rem; }
.def-word a { color: var(--ink); text-decoration: none; }
.def-word a:hover { color: var(--shu); }
.def-meta { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.7rem; font-size: 0.82rem; color: var(--muted); }
.votes { display: flex; gap: 0.3rem; align-items: center; }
.vote {
  display: inline-flex; align-items: center; gap: 0.3rem; min-height: 2.25rem; padding: 0 0.7rem;
  border: 1px solid var(--rule-strong); border-radius: 2px; background: transparent; color: var(--ink-2);
  font: inherit; font-size: 0.85rem; cursor: pointer; font-variant-numeric: tabular-nums;
}
.vote svg { width: 0.85em; height: 0.85em; }
.vote:hover { border-color: var(--ink); color: var(--ink); }
.vote.on { border-color: var(--shu); color: var(--shu); background: var(--shu-wash); }
.vote b { font-weight: 600; }
.def-meta .by { display: inline-flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
details.report { position: relative; display: inline-block; margin-left: 0.3rem; }
details.report summary { list-style: none; cursor: pointer; color: var(--muted); font-size: 0.8rem; padding: 0.4rem 0.3rem; min-height: 2.25rem; display: inline-flex; align-items: center; text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 0.2em; }
details.report summary::-webkit-details-marker { display: none; }
details.report summary:hover { color: var(--ink-2); text-decoration: underline; }
details.report[open] summary { color: var(--ink); }
.report-form { position: absolute; right: 0; top: 100%; z-index: 3; display: flex; gap: 0.5rem; align-items: flex-end; padding: 0.7rem; background: var(--field); border: 1px solid var(--rule-strong); border-radius: 2px; box-shadow: 0 2px 0 var(--rule); min-width: 15rem; }
.report-form label { display: block; flex: 1; font-size: 0.85rem; }
.report-form select { display: block; width: 100%; margin-top: 0.2rem; padding: 0.35rem 0.5rem; font: inherit; font-size: 0.9rem; border: 1px solid var(--rule-strong); border-radius: 2px; background: var(--field); color: var(--ink); }
.report-done { font-size: 0.82rem; color: var(--muted); }
.held-note { color: var(--shu); font-size: 0.85rem; margin: 0.5rem 0 0; }

/* ---- 並び替え ---- */
.sorts { display: flex; gap: 1rem; flex-wrap: wrap; align-items: baseline; margin: 1.6rem 0 0; font-size: 0.85rem; color: var(--muted); }
.sorts a { color: var(--muted); text-decoration: none; padding: 0.25rem 0; }
.sorts a:hover { color: var(--ink); }
.sorts a.on { color: var(--ink); border-bottom: 1px solid var(--ink); }
h2 .more { float: right; font-weight: 400; letter-spacing: 0; text-decoration: none; }
h2 .more:hover { text-decoration: underline; }

.alt-login { margin-top: 1.2rem; font-size: 0.9rem; color: var(--muted); }

/* ---- 本人の操作 ---- */
.owner-actions { display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; margin: 0.7rem 0 0; font-size: 0.85rem; }
.owner-actions details.delete { display: inline-block; }
.owner-actions details.delete summary { list-style: none; cursor: pointer; color: var(--muted); text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 0.2em; }
.owner-actions details.delete summary::-webkit-details-marker { display: none; }
.owner-actions details.delete[open] summary { color: var(--shu); }
.owner-actions details.delete form { margin: 0.3rem 0 0; }

/* ---- 辞書のツメ ---- */
.thumb { position: sticky; top: var(--header-h, 3.3rem); z-index: 4; display: flex; gap: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 1.2rem 0 0.2rem; padding: 0.3rem 0; background: var(--paper); border-bottom: 1px solid var(--rule); font-family: var(--serif); }
.thumb::-webkit-scrollbar { display: none; }
.thumb a { flex: 1 0 auto; min-width: 1.9rem; padding: 0.25rem 0.1rem; text-align: center; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; font-size: 0.95rem; }
.thumb a:hover { color: var(--ink); }
.thumb a.on { color: var(--shu); border-bottom-color: var(--shu); }
.group { scroll-margin-top: calc(var(--header-h, 3.3rem) + 3rem); }
.group-label { font-family: var(--serif); font-size: 1.4rem; color: var(--shu); border: 0; margin: 1.8rem 0 0; padding: 0; letter-spacing: 0; }
.group .word-list { margin-top: 0.2rem; }

/* ---- 一覧の項目: 見出し語と、いちばん上の定義 ---- */
.entries li { display: grid; grid-template-columns: 9rem 1fr; gap: 0.2rem 1rem; align-items: baseline; font-family: var(--sans); font-size: 1rem; padding: 0.8rem 0; }
.entries .hw { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.entries .hw:hover { color: var(--shu); }
.entries .gloss { margin: 0; color: var(--ink-2); line-height: 1.75; }
.entries .gloss .more { margin-left: 0.4rem; white-space: nowrap; }
@media (max-width: 560px) { .entries li { grid-template-columns: 1fr; gap: 0.1rem; } }

/* ---- ホーム ---- */
.specimen-meta { margin-top: 0.8rem; }
.feed .def { padding-left: 0; }
.feed .def-word { font-size: 1.15rem; }
.feed .def-word rt { font-size: 0.5em; }

/* ---- 索引（新着など） ---- */
.index { list-style: none; margin: 0; padding: 0; }
.index li { display: grid; grid-template-columns: 9rem 1fr; gap: 0.5rem 1rem; padding: 0.75rem 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.index .hw { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; line-height: 1.4; }
.index .hw a { color: var(--ink); text-decoration: none; }
.index .hw a:hover { color: var(--shu); }
.index .snippet { margin: 0; color: var(--ink-2); font-size: 0.95rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.index .by { font-size: 0.78rem; color: var(--muted); margin: 0.1rem 0 0; }

/* ---- 書く ---- */
.compose { margin-top: 2.4rem; }
.compose-form { max-width: var(--measure); }
.compose-form label { display: block; margin: 1rem 0; font-size: 0.92rem; }
.compose-form label .muted { font-weight: 400; }
.compose-form input[type="text"], .compose-form input[type="email"], .compose-form textarea, .compose-form select {
  display: block; width: 100%; margin-top: 0.3rem; padding: 0.6rem 0.75rem; font: inherit; font-size: 1rem; line-height: 1.6;
  border: 1px solid var(--rule-strong); border-radius: 2px; background: var(--field); color: var(--ink);
}
.compose-form input:focus, .compose-form textarea:focus, .compose-form select:focus { border-color: var(--ink); }
.compose-form textarea { font-family: var(--serif); font-size: 1.05rem; resize: vertical; }
.compose-form .row { display: flex; gap: 1rem; }
.compose-form .row .grow { flex: 1; }
.compose-form label.check { display: flex; gap: 0.5rem; align-items: flex-start; }
.compose-form label.check input { margin: 0.35rem 0 0; }
.error { color: var(--shu); border-left: 2px solid var(--shu); padding: 0.3rem 0.8rem; }
.notice { border-left: 2px solid var(--ink); padding: 0.3rem 0.8rem; }
form.inline { display: inline-block; margin: 0.4rem 0.4rem 0 0; }
.word-list { list-style: none; padding: 0; margin: 0.5rem 0; }
.word-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--rule); font-family: var(--serif); font-size: 1.15rem; }
.word-list li a { color: var(--ink); text-decoration: none; }
.word-list li a:hover { color: var(--shu); }
.report-list { list-style: none; padding: 0; }
.report-list li { padding: 0.8rem 0; border-bottom: 1px solid var(--rule); }
.admin-item { margin-bottom: 1rem; }
.legal h2 { border: 0; margin-top: 1.8rem; color: var(--ink); font-family: var(--serif); font-size: 1.05rem; letter-spacing: 0; }
.legal ul { padding-left: 1.2rem; }


footer { max-width: 44rem; margin: 3rem auto 0; padding: 1.2rem 1rem 2rem; border-top: 1px solid var(--rule-strong); font-size: 0.82rem; color: var(--muted); }
footer p { margin: 0.2rem 0; }
footer a { color: var(--muted); }

@media (max-width: 560px) {
  .top-in { grid-template-columns: 1fr auto; grid-template-areas: "logo nav" "search search"; padding: 0.55rem 1rem 0.2rem; }
  header .search input { padding-bottom: 0.35rem; }
  .specimen { margin-top: 2rem; }
  .logo { grid-area: logo; }
  header .search { grid-area: search; }
  header nav { grid-area: nav; gap: 0.7rem; }
  .btn.write { padding: 0.35rem 0.8rem; }
  .index li { grid-template-columns: 1fr; gap: 0.15rem; }
  .compose-form .row { flex-direction: column; gap: 0; }
  .def { padding-left: 1.9rem; }
  .def-meta { flex-direction: column; align-items: stretch; }
  .votes { justify-content: flex-start; }
  .votes { flex-wrap: wrap; }
  .vote { min-height: 2.75rem; padding: 0 0.45rem; font-size: 0.8rem; white-space: nowrap; gap: 0.2rem; }
  details.report summary { min-height: 2.75rem; padding: 0.5rem 0.3rem; white-space: nowrap; }
  .report-form { position: fixed; left: 1rem; right: 1rem; top: auto; bottom: 1rem; min-width: 0; box-shadow: 0 0 0 1px var(--rule), 0 8px 24px rgba(26, 24, 22, 0.18); }
  .def-meta { gap: 0.2rem; }
}
