:root {
  --ink: #1A1D21;
  --ink-2: #474C54;
  --muted: #7D828A;
  --bg: #EDEEE9;
  --surface: #FFFFFF;
  --surface-2: #F6F6F3;
  --line: #DCDDD7;
  --accent: #F2B705;
  --accent-soft: #FDF3D0;
  --ok: #1F7A45;   --ok-bg: #E2F3E8;
  --fix: #B4480F;  --fix-bg: #FCEBDD;
  --err: #B42318;  --err-bg: #FCE6E4;
  --info: #2B5FAA; --info-bg: #E7EEF9;
  --k-photo: #2B5FAA; --k-video: #6F3BA8; --k-audio: #0E7466; --k-text: #8A6400;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(26,29,33,.06), 0 4px 14px rgba(26,29,33,.06);
  --tabbar-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 枠（ヘッダー・タブ） ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: .02em; text-decoration: none; display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; }
.brand-name { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) { .brand { font-size: 15px; } .me-btn { max-width: 30vw; } }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; }
.topnav { display: none; margin-left: 12px; gap: 4px; }
.topnav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; color: #C9CBC6; font-size: 15px; }
.topnav a.on { background: rgba(255,255,255,.12); color: #fff; }
.fb-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent); color: var(--ink); border: 0; border-radius: 999px;
  padding: 6px 12px; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.fb-btn svg { width: 18px; height: 18px; }
.me { position: relative; }
.me-btn { background: rgba(255,255,255,.1); border: 0; color: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 14px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); color: var(--ink); border-radius: 12px; box-shadow: var(--shadow); min-width: 200px; padding: 6px; }
.me-menu .who { padding: 8px 10px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.me-menu button { width: 100%; text-align: left; background: none; border: 0; padding: 10px; border-radius: 8px; cursor: pointer; }
.me-menu button:hover { background: var(--surface-2); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 600;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--ink); }
.tabbar a.on svg { color: var(--ink); }
.tabbar a.on .tab-dot { background: var(--accent); }
.tab-dot { width: 28px; height: 4px; border-radius: 2px; background: transparent; margin-bottom: 2px; }

@media (min-width: 820px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 32px; }
}

main { max-width: 960px; margin: 0 auto; padding: 18px 16px; }
.narrow { max-width: 640px; }

h1 { font-size: 22px; line-height: 1.35; margin: 4px 0 4px; }
h2 { font-size: 18px; margin: 28px 0 10px; }
.lead { color: var(--ink-2); margin: 0 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- 部品 ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #1A1D21); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--err); border-color: #F1C3BE; }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn svg { width: 20px; height: 20px; }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.input, textarea.input, select.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(242,183,5,.35); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.6; }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip-photo { background: #E7EEF9; color: var(--k-photo); }
.chip-video { background: #F0E8F8; color: var(--k-video); }
.chip-audio { background: #E1F2EF; color: var(--k-audio); }
.chip-text  { background: #F8EFD6; color: var(--k-text); }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-fix { background: var(--fix-bg); color: var(--fix); }
.chip-err { background: var(--err-bg); color: var(--err); }
.chip-busy { background: var(--info-bg); color: var(--info); }
.chip-admin { background: var(--ink); color: #fff; }

.notice { border-radius: 12px; padding: 12px 14px; margin: 12px 0; font-size: 15px; }
.notice-info { background: var(--info-bg); color: #1D3F73; }
.notice-err { background: var(--err-bg); color: #7A1810; }
.notice-ok { background: var(--ok-bg); color: #14532D; }

.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 50; max-width: min(92vw, 520px);
  box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 15px;
}
@media (min-width: 820px) { .toast { bottom: 28px; } }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; margin: 0 auto 8px; opacity: .6; }

/* ---------- 投稿 ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  border: 0; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); cursor: pointer;
  padding: 18px 14px; min-height: 132px; text-align: left; display: flex; flex-direction: column; justify-content: space-between;
  -webkit-tap-highlight-color: transparent; position: relative; overflow: hidden;
}
.tile:active { transform: scale(.985); }
.tile-icon { width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center; }
.tile-icon svg { width: 26px; height: 26px; }
.tile b { display: block; font-size: 18px; margin-top: 12px; }
.tile small { color: var(--muted); font-size: 13px; }
.tile.photo .tile-icon { background: #E7EEF9; color: var(--k-photo); }
.tile.video .tile-icon { background: #F0E8F8; color: var(--k-video); }
.tile.audio .tile-icon { background: #E1F2EF; color: var(--k-audio); }
.tile.text  .tile-icon { background: #F8EFD6; color: var(--k-text); }
@media (min-width: 820px) { .tiles { grid-template-columns: repeat(4, 1fr); } }

.composer { margin-top: 4px; }
.composer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.composer-head h2 { margin: 0; font-size: 18px; }
.composer-head .btn { margin-left: auto; }
.previews { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.previews img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.previews .noprev { aspect-ratio: 1; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 12px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px; }
.file-line { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--surface-2); border-radius: 12px; margin-bottom: 14px; }
.file-line svg { width: 22px; height: 22px; flex: none; }
.file-line .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
video.preview, audio.preview { width: 100%; border-radius: 12px; margin-bottom: 14px; background: #000; }
audio.preview { background: transparent; }

.recorder { text-align: center; padding: 8px 0 4px; }
.rec-btn {
  width: 92px; height: 92px; border-radius: 50%; border: 6px solid #F4D2CF; background: #D92D20; color: #fff;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent;
}
.rec-btn svg { width: 34px; height: 34px; }
.rec-btn.recording { background: var(--ink); border-color: #C9CBC6; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(217,45,32,.15); } }
.rec-time { font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 700; margin: 10px 0 2px; }

.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 12px 0 6px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.recent { display: flex; flex-direction: column; gap: 8px; }
.recent a { display: flex; gap: 12px; align-items: center; padding: 10px; text-decoration: none; }
.recent .th { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); display: flex; align-items: center; justify-content: center; }
.recent .th svg { width: 24px; height: 24px; }
.recent .body { min-width: 0; flex: 1; }
.recent .line1 { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.recent .ex { color: var(--ink-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- ライブラリ ---------- */
.searchbar { position: relative; margin-bottom: 10px; }
.searchbar svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); }
.searchbar .input { padding-left: 44px; border-radius: 999px; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.fbtn { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 600; cursor: pointer; }
.fbtn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.fsep { flex: none; width: 1px; background: var(--line); margin: 4px 2px; }
.summary-line { font-size: 13px; color: var(--muted); margin: 0 0 12px; }

.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .grid { grid-template-columns: 1fr 1fr 1fr; } }
.ccard { display: flex; flex-direction: column; text-decoration: none; overflow: hidden; }
.ccard .cover { aspect-ratio: 16 / 10; background: var(--surface-2); position: relative; display: flex; align-items: center; justify-content: center; }
.ccard .cover img { width: 100%; height: 100%; object-fit: cover; }
.ccard .cover svg { width: 40px; height: 40px; opacity: .55; }
.ccard .cover .count { position: absolute; right: 8px; bottom: 8px; background: rgba(26,29,33,.78); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.ccard .cbody { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.ccard .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.ccard .ex { font-size: 15px; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 1.6em; }
.ccard .meta { font-size: 13px; color: var(--muted); margin-top: auto; display: flex; justify-content: space-between; gap: 8px; }
.rv { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.rv .bar { flex: 1; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.rv .bar i { display: block; height: 100%; background: var(--ok); }
.cover.k-audio { background: #E1F2EF; color: var(--k-audio); }
.cover.k-text { background: #F8EFD6; color: var(--k-text); }
.cover.k-video { background: #F0E8F8; color: var(--k-video); }
.cover.k-photo { background: #E7EEF9; color: var(--k-photo); }

/* ---------- 事例の詳細 ---------- */
.back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--ink-2); font-weight: 600; margin-bottom: 8px; }
.back svg { width: 18px; height: 18px; }
.case-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.quote { border-left: 4px solid var(--accent); background: var(--surface); padding: 12px 14px; border-radius: 0 12px 12px 0; margin: 12px 0; white-space: pre-wrap; }
.items { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.item { overflow: hidden; }
.item .img { background: #111; cursor: zoom-in; }
.item .img img { width: 100%; max-height: 70vh; object-fit: contain; }
.item .ibody { padding: 14px 16px 16px; }
.item .itop { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.item .num { font-weight: 700; font-size: 14px; color: var(--ink-2); }
.item .txt { font-size: 17px; white-space: pre-wrap; word-break: break-word; }
.item .txt.empty-txt { color: var(--muted); font-size: 15px; }
.item .raw { margin-top: 8px; font-size: 14px; color: var(--muted); background: var(--surface-2); padding: 8px 10px; border-radius: 10px; }
.item .edit-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.review { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.rbtn { min-height: 46px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.rbtn svg { width: 18px; height: 18px; }
.rbtn.ok.on { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.rbtn.fix.on { background: var(--fix-bg); border-color: var(--fix); color: var(--fix); }
.review .rnote { grid-column: 1 / -1; }
.review .rwho { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.danger-zone { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.confirm-box { width: 100%; background: var(--err-bg); border-radius: 12px; padding: 12px; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 60; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; }

/* ---------- ルールブック ---------- */
.md { line-height: 1.8; overflow-wrap: anywhere; }
.md h1 { font-size: 22px; margin: 8px 0 12px; }
.md h2 { font-size: 19px; margin: 26px 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--accent); }
.md h3 { font-size: 17px; margin: 20px 0 6px; }
.md h4, .md h5, .md h6 { font-size: 16px; margin: 16px 0 4px; }
.md p { margin: 8px 0; }
.md ul, .md ol { padding-left: 1.4em; margin: 6px 0; }
.md code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.md .tbl { overflow-x: auto; margin: 10px 0; }
.md table { border-collapse: collapse; font-size: 14px; min-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.versions { display: flex; flex-direction: column; gap: 6px; }
.versions button { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.versions button.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.rb-layout { display: grid; gap: 16px; }
@media (min-width: 900px) { .rb-layout { grid-template-columns: 1fr 260px; align-items: start; } }

/* ---------- 管理 ---------- */
.users { display: flex; flex-direction: column; gap: 10px; }
.urow { padding: 14px 16px; display: grid; gap: 8px; }
.urow .uname { font-weight: 700; font-size: 17px; }
.urow .uid { font-size: 13px; color: var(--muted); }
.urow .uchips { display: flex; gap: 6px; flex-wrap: wrap; }
.urow .uacts { display: flex; gap: 8px; flex-wrap: wrap; }
.urow.disabled { opacity: .65; }
@media (min-width: 820px) {
  .urow { grid-template-columns: 1.4fr 1fr auto; align-items: center; }
}
.linkbox { display: flex; gap: 8px; margin: 10px 0; }
.linkbox .input { font-size: 14px; min-width: 0; }
.linkbox .btn { flex: none; white-space: nowrap; }
.modal-back { position: fixed; inset: 0; background: rgba(26,29,33,.5); z-index: 55; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 620px) { .modal-back { align-items: center; } .modal { border-radius: 18px; } }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.row2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 620px) { .row2 { grid-template-columns: 1fr 1fr; } }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { flex: 1; text-align: center; padding: 8px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 15px; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--surface); box-shadow: var(--shadow); }

/* ---------- ログイン ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; padding: 28px 22px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; margin-bottom: 18px; }
.auth-brand .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 76px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: var(--surface-2); border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.err-text { color: var(--err); font-size: 14px; min-height: 1.4em; margin: 4px 0 10px; }
