:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1f2328; --sub: #5d646d; --line: #dcd9d2;
  --accent: #1d6b5f; --accent-ink: #ffffff; --accent-soft: #e2f0ec;
  --mark: #ffe066; --mark-box: rgba(255, 196, 0, .38); --mark-edge: #e0a800;
  --warn: #9a3412; --warn-soft: #fff1e6; --radius: 10px;
  --font: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.7 var(--font); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.who { margin-right: auto; font-size: 13px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ro .w-only { display: none !important; }
.top nav { display: flex; gap: 4px; }
.top nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--sub); }
.top nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

main { max-width: 1100px; margin: 0 auto; padding: 20px; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 18px; margin: 24px 0 8px; }
.muted { color: var(--sub); font-size: 14px; }

.btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.danger { color: var(--warn); border-color: #f0c7b0; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 4px 10px; font-size: 14px; }

/* 探す */
.searchbar { display: flex; gap: 8px; margin: 8px 0 6px; }
.searchbar input { flex: 1; min-width: 0; font-size: 20px; padding: 12px 16px; border: 2px solid var(--accent); border-radius: 12px; background: var(--panel); }
.searchbar button { font-size: 18px; padding: 0 22px; border-radius: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chip { padding: 3px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 14px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.summary { margin: 12px 0; color: var(--sub); }

.result { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.result h3 { margin: 0; font-size: 18px; }
.result h3 a { text-decoration: none; color: var(--ink); }
.result h3 a:hover { color: var(--accent); text-decoration: underline; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--sub); margin: 2px 0 8px; }
.tag { display: inline-block; padding: 0 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 13px; }
.tag.web { background: #ece6fb; color: #5b3fa8; }
.where { font-size: 13px; color: var(--sub); margin: 0 0 8px; }
.where b { color: var(--ink); font-weight: 600; }
.hits { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.hit { flex: 0 0 auto; width: 250px; display: flex; gap: 10px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fbfaf8; }
.hit:hover { border-color: var(--accent); }
.hit img { width: 64px; height: 90px; object-fit: cover; object-position: top; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.hit .pg { font-size: 13px; font-weight: 700; color: var(--accent); }
.hit .snip { font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; }

/* 見る */
.viewer { display: grid; grid-template-columns: 150px 1fr; gap: 16px; }
.vhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.vhead h1 { margin: 0; font-size: 20px; flex: 1 1 300px; }
.thumbs { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
.thumb { position: relative; display: block; border: 2px solid transparent; border-radius: 6px; text-decoration: none; color: var(--sub); font-size: 12px; text-align: center; }
.thumb img { width: 100%; display: block; border-radius: 4px; border: 1px solid var(--line); background: #fff; }
.thumb.on { border-color: var(--accent); }
.thumb .badge { position: absolute; top: 4px; right: 4px; background: var(--mark-edge); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 0 7px; }
.pagebox { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.pagebox img { display: block; width: 100%; height: auto; }
.pagebox .hl { position: absolute; background: var(--mark-box); outline: 2px solid var(--mark-edge); border-radius: 2px; pointer-events: none; }
.pagebar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.pagebar .count { min-width: 90px; text-align: center; }
.findbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.findbar input { border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; min-width: 0; width: 200px; }
.zoom-wrap { overflow: auto; }

.webdoc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; max-width: 820px; }
.webdoc h2 { border-left: 5px solid var(--accent); padding-left: 10px; }
.webdoc ol, .webdoc ul { padding-left: 1.5em; }
.webdoc li { margin: 6px 0; }
.webdoc .crop { display: block; position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; margin: 8px 0 14px; max-width: 640px; background: #fff; }
.webdoc .crop img { position: absolute; max-width: none; }
.webdoc .cap { font-size: 13px; color: var(--sub); margin-top: -8px; margin-bottom: 14px; }
.note { background: var(--warn-soft); border-left: 4px solid var(--warn); padding: 8px 12px; border-radius: 6px; }

/* 台帳・フォーム */
table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 15px; }
table.list th { background: #efede8; font-size: 13px; color: var(--sub); white-space: nowrap; }
table.list td.num { text-align: right; white-space: nowrap; }
table.list td.nw { white-space: nowrap; }
.form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; max-width: 820px; }
.field { margin: 0 0 14px; }
.field label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.field .hint { font-size: 13px; color: var(--sub); margin-top: 2px; }
.field input[type=text], .field select, .field textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.field textarea { min-height: 120px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; font-weight: 700; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 24px; text-align: center; background: #fbfaf8; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.files { list-style: none; padding: 0; margin: 10px 0; }
.files li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; background: #fff; }
.files li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { margin: 12px 0; }
.progress .bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.warnbox { background: var(--warn-soft); border: 1px solid #f0c7b0; color: var(--warn); border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.tag.pending { background: var(--warn-soft); color: var(--warn); }
.field textarea.tall { min-height: 340px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .spacer { flex: 1; }
.empty { text-align: center; color: var(--sub); padding: 40px 0; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; }
#toast.show { opacity: .94; }

@media (max-width: 720px) {
  main { padding: 14px 16px; }
  .top { padding: 8px 12px; gap: 8px; }
  .brand { font-size: 16px; }
  .who { display: none; }
  .top nav a { padding: 4px 8px; font-size: 14px; }
  .searchbar input { font-size: 17px; padding: 10px 12px; }
  .searchbar button { padding: 0 14px; font-size: 16px; }
  .viewer { grid-template-columns: 1fr; }
  .thumbs { position: static; flex-direction: row; overflow-x: auto; max-height: none; }
  .thumb { flex: 0 0 70px; }
  .row2 { grid-template-columns: 1fr; }
  .webdoc { padding: 16px; }
  table.list .hide-sp { display: none; }
  .hit { width: 220px; }
}
@media print {
  .top, .thumbs, .pagebar, .findbar, .vhead .btn { display: none !important; }
  .viewer { display: block; }
  main { max-width: none; padding: 0; }
}
