:root {
  --fg: #1f2328; --muted: #59636e; --bg: #fff; --line: #d0d7de; --accent: #0b5cad;
  --soft: #f6f8fa; --green: #1a7f37; --warn: #9a6700;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; color: var(--fg); background: var(--bg); font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif; line-height: 1.6; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 1rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header { border-bottom: 1px solid var(--line); background: var(--soft); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding-top: .6rem; padding-bottom: .6rem; }
.brand { font-weight: 700; color: var(--fg); font-size: 1.05rem; }
.site-header nav { margin-left: auto; display: flex; gap: .9rem; flex-wrap: wrap; }
.site-header nav a.active { font-weight: 700; }
.site-header nav a.lang, .site-header nav a.variant { border: 1px solid var(--line); padding: 0 .5rem; border-radius: 4px; background: #fff; }
.site-header nav a.variant { font-size: .85rem; color: var(--muted); }
.badge { font-size: .75rem; background: var(--warn); color: #fff; padding: .05rem .5rem; border-radius: 999px; }
body.internal .site-header { background: #fff7e0; }

main { padding: 1.2rem 1rem 3rem; min-height: 60vh; }
footer { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); padding: 1rem; }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.8rem 0 .6rem; padding-bottom: .2rem; border-bottom: 2px solid var(--line); }
h3 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* year grid on top page */
.years { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.2rem, 1fr)); gap: .3rem; }
.years a { display: block; text-align: center; border: 1px solid var(--line); border-radius: 4px; padding: .2rem 0; background: #fff; }
.years a small { display: block; color: var(--muted); font-size: .7rem; line-height: 1; padding-bottom: .1rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }

/* publication entries */
ol.pubs { padding-left: 1.6rem; }
ol.pubs > li { margin: 0 0 .9rem; }
.pub .ttl { font-weight: 600; }
.pub .meta { color: var(--fg); }
.pub .authors { color: var(--muted); }
.pub .extra { font-size: .85rem; color: var(--muted); }
.pub .extra a { margin-right: .6rem; }
.pub .note { font-size: .9rem; }
.pub .note .blink, .pub .note #red, .note .blink, .note #red { color: #c00; font-weight: 600; }
.awards { margin: .15rem 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.award { display: inline-block; font-size: .85rem; font-weight: 600; color: #7a4b00; background: #fff4d6; border: 1px solid #f0c36d; border-radius: 999px; padding: 0 .6rem; }
.award::before { content: '🏆'; margin-right: .3rem; }
.pub .tag { display: inline-block; font-size: .72rem; border: 1px solid var(--line); border-radius: 3px; padding: 0 .35rem; margin-right: .3rem; color: var(--muted); background: var(--soft); }
.pub .tag.internal { color: var(--warn); border-color: var(--warn); }

.toc { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin: .5rem 0 1rem; font-size: .9rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin: .5rem 0 1rem; font-size: .9rem; }

/* detail table */
table.detail { border-collapse: collapse; width: 100%; margin: .5rem 0 1rem; }
table.detail th, table.detail td { border: 1px solid var(--line); padding: .35rem .6rem; text-align: left; vertical-align: top; }
table.detail th { width: 11rem; background: var(--soft); font-weight: 600; white-space: nowrap; }
pre.bib { background: var(--soft); border: 1px solid var(--line); border-radius: 4px; padding: .7rem; overflow-x: auto; font-size: .85rem; }
.abstract { white-space: pre-wrap; }

/* search / export */
form.search { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .6rem .9rem; background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: .9rem; }
form.search label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); gap: .15rem; }
form.search input, form.search select, .export select, .export input, .export textarea { font: inherit; padding: .3rem .4rem; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--fg); }
form.search .row { display: flex; gap: .4rem; align-items: center; }
form.search .full { grid-column: 1 / -1; }
button { font: inherit; padding: .35rem .9rem; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 4px; cursor: pointer; }
button.secondary { background: #fff; color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
.export { border: 1px solid var(--line); border-radius: 6px; padding: .9rem; margin: 1rem 0; }
.export .options { display: flex; flex-wrap: wrap; gap: .6rem .9rem; align-items: center; margin-bottom: .6rem; }
.export textarea { width: 100%; min-height: 16rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; white-space: pre-wrap; }
.export .tpl { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.export details { font-size: .85rem; color: var(--muted); margin: .4rem 0; }
.export code { background: var(--soft); padding: 0 .25rem; border-radius: 3px; }

.hint { display: block; font-size: .78rem; color: var(--muted); }
details.filter { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .9rem; margin-bottom: .6rem; }
details.filter[open] > summary { margin-bottom: .6rem; }
details.filter > summary, details.export.collapsible > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .5rem; }
details.filter > summary::-webkit-details-marker, details.export.collapsible > summary::-webkit-details-marker { display: none; }
details.filter > summary::before, details.export.collapsible > summary::before { content: '▶'; font-size: .8rem; color: var(--accent); }
details.filter[open] > summary::before, details.export.collapsible[open] > summary::before { content: '▼'; }
details.filter > summary h2, details.export.collapsible > summary h2 { margin: 0; border: 0; padding: 0; display: inline; }
details.export.collapsible:not([open]) { padding: .5rem .9rem; }
details.export.collapsible[open] > summary { margin-bottom: .6rem; }
.export .tpl { min-height: 3.6rem; white-space: pre; overflow-x: auto; resize: vertical; margin: .3rem 0; }
.export details.x-tpl-box { margin: .2rem 0 .6rem; font-size: .9rem; }
.export details.x-tpl-box > summary { cursor: pointer; color: var(--accent); }
.export details.sub { margin-left: .5rem; }
.export .x-out-label { display: block; margin-bottom: .2rem; }
.export.compact { position: static; margin: 0; }
.export.compact textarea.x-out { min-height: 9rem; }
.export .tpl:disabled { background: var(--soft); color: var(--muted); }
.export textarea#out { min-height: 14rem; }
.toolbar.tight { margin: .2rem 0; }
button.small { padding: .1rem .5rem; font-size: .8rem; }
.hidden { display: none !important; }

/* attachment manager (internal site) */
.filebox { border: 1px solid var(--line); border-radius: 6px; padding: .6rem .9rem; }
.filebox h3 { margin: .2rem 0 .4rem; }
.filebox ul.files { padding-left: 1.2rem; }
.filebox ul.files li { margin: .2rem 0; }
.filebox form.upload { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; font-size: .9rem; }
button.danger { color: #b3261e; border-color: #b3261e; }

/* search results rendered in the selected export style */
.results li .styled { white-space: pre-wrap; overflow-wrap: anywhere; }
.results li .styled.bib { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; background: var(--soft); border-radius: 4px; padding: .3rem .5rem; overflow-x: auto; white-space: pre; }
.results li .extra { margin-top: .1rem; }
.permalink { font-size: .9rem; overflow-wrap: anywhere; margin: .2rem 0 .8rem; }
.pub .extra a.file::before { content: '📎'; margin-right: .15rem; }

/* ---- editor (internal) ---- */
form.editor { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem 1.2rem; background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 1rem; }
form.editor .row { grid-column: 1 / -1; display: flex; flex-direction: column; gap: .2rem; }
form.editor .row.short { grid-column: auto; }
form.editor .row > label { font-weight: 600; font-size: .9rem; }
form.editor .req { color: var(--warn); }
form.editor input, form.editor select, form.editor textarea { font: inherit; padding: .3rem .4rem; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--fg); width: 100%; box-sizing: border-box; }
form.editor .row.short input, form.editor .row.short select { max-width: 16rem; }
form.editor .inline { display: flex; gap: .4rem; align-items: center; }
form.editor .inline input { flex: 1; }
form.editor .pair { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
form.editor label.sub { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: .15rem; }
form.editor table.authors { width: 100%; border-collapse: collapse; }
form.editor table.authors th { font-size: .78rem; color: var(--muted); font-weight: 500; text-align: left; padding: 0 .3rem; }
form.editor table.authors td { padding: .15rem .3rem; }
form.editor table.authors td.n { width: 2rem; color: var(--muted); }
form.editor table.authors td.ops { white-space: nowrap; width: 7rem; }
form.editor .awards-edit { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
form.editor .awards-edit .inline { margin: .2rem 0; }
form.editor .sublabel, .preview .sublabel { display: block; font-size: .78rem; color: var(--muted); }
form.editor .checks { display: flex; flex-wrap: wrap; gap: .2rem 1rem; }
form.editor .checks label.check { font-size: .9rem; }
form.editor .checks input { width: auto; }
form.editor .addfield select { max-width: 20rem; }
form.editor .actions { grid-column: 1 / -1; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
form.editor .actions button.danger { margin-left: auto; }
button.danger { color: #c00; border-color: #c00; }
.status.error { color: #c00; }
.preview .pv { margin: .5rem 0; }
.preview .styled { padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
@media (max-width: 700px) { form.editor { grid-template-columns: 1fr; } form.editor .pair, form.editor .awards-edit { grid-template-columns: 1fr; } }
form.editor input.warn { border-color: var(--warn); background: #fff8f0; }
form.editor .newfield { margin-top: .3rem; }
form.editor .warnings { background: #fff6e0; border: 1px solid #e0b040; border-radius: 4px; padding: .5rem .8rem; }
form.editor .warnings ul { margin: .2rem 0 0; padding-left: 1.2rem; }
form.editor .replaced { color: var(--muted); font-size: .78rem; }
.export .x-tpl-box.edited > summary { color: var(--warn); font-weight: 600; }
.pub .styled-row { display: flex; align-items: flex-start; gap: .5rem; }
.pub .styled-row .styled { flex: 1; min-width: 0; }
.pub .copy-one { flex: none; opacity: .55; white-space: nowrap; }
.pub:hover .copy-one, .pub .copy-one:focus { opacity: 1; }
