/* 袖（そで） — 生成り × 墨 × 藤 */
:root {
  --bg: #f7f4ee;        /* 生成り */
  --paper: #fffdf8;
  --ink: #2b2a28;       /* 墨 */
  --ink-soft: #6f6a62;
  --line: #e2dcd0;
  --fuji: #7b6a8f;      /* 藤 */
  --fuji-weak: #ece7f2;
  --danger: #a4453e;
  --ok: #4a7c59;
  --radius: 12px;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.7;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 16px; color: var(--ink); }

/* ---- ログイン ---- */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 320px; text-align: center; }
.brand { font-family: var(--serif); font-weight: 500; font-size: 64px; letter-spacing: .1em; }
.brand.small { font-size: 22px; }
.brand-sub { font-family: var(--serif); color: var(--ink-soft); font-size: 13px; margin: 4px 0 32px; letter-spacing: .15em; }
.login-box input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); text-align: center; letter-spacing: .3em; margin-bottom: 12px;
}
.msg { font-size: 13px; color: var(--danger); min-height: 1.5em; margin-top: 8px; }

/* ---- ボタン ---- */
.btn {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: var(--radius); padding: 10px 18px; font-size: 15px;
}
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.fuji { background: var(--fuji); color: #fff; border-color: var(--fuji); }
.btn.danger { background: none; color: var(--danger); border-color: transparent; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.ghost { background: none; border: none; color: var(--ink-soft); font-size: 13px; padding: 6px 10px; }

/* ---- レイアウト ---- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-status { flex: 1; font-size: 12px; color: var(--ink-soft); }
main { padding: 16px 16px calc(env(safe-area-inset-bottom) + 84px); max-width: 760px; margin: 0 auto; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: var(--paper); border-top: 1px solid var(--line);
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px);
}
.tab {
  background: none; border: none; color: var(--ink-soft);
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 10px; border-radius: 10px;
}
.tab-ico { font-family: var(--serif); font-size: 20px; line-height: 1.2; }
.tab.active { color: var(--fuji); background: var(--fuji-weak); }

h2.sec { font-family: var(--serif); font-size: 18px; margin: 8px 0 12px; letter-spacing: .06em; }
.hint { font-size: 12.5px; color: var(--ink-soft); }

/* ---- 取り込み ---- */
.ingest-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.ingest-actions .btn { flex: 1; padding: 18px 10px; font-size: 15px; }
.ingest-actions .btn .big { display: block; font-family: var(--serif); font-size: 26px; margin-bottom: 4px; }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card.processing { border-style: dashed; }
.review-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.review-thumb {
  width: 84px; height: 84px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); flex-shrink: 0; cursor: zoom-in; background: var(--bg);
}
.typebar { display: flex; gap: 6px; margin-bottom: 10px; }
.typebar button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px;
  padding: 5px 14px; font-size: 13px; color: var(--ink-soft);
}
.typebar button.on { background: var(--fuji); border-color: var(--fuji); color: #fff; }

.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 3px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.field textarea { min-height: 110px; line-height: 1.8; }
.fields-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.row-btns { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 8px; }
.row-btns .spacer { flex: 1; }

.err-box { background: #f9efee; border: 1px solid #e5cfcd; border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--danger); margin-bottom: 10px; }
.spin { display: inline-block; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 一覧 ---- */
.chipbar { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 5px 14px; font-size: 13px; color: var(--ink-soft);
}
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.note-item { cursor: pointer; }
.note-meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; flex-wrap: wrap; }
.person-chip {
  background: var(--fuji-weak); color: var(--fuji); border-radius: 999px; padding: 1px 10px; font-size: 12px;
}
.kabe-chip { background: #eee9dd; color: #8a7f63; border-radius: 999px; padding: 1px 10px; font-size: 12px; }
.arc-star { margin-left: auto; font-size: 15px; color: #c9c2b4; }
.arc-star.on { color: var(--fuji); }
.note-title { font-weight: 600; font-size: 15px; }
.note-body { font-size: 13.5px; color: var(--ink-soft); white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.person-card { cursor: pointer; }
.person-card .p-name { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.person-card .p-sub { font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
.p-count { font-size: 11px; color: var(--fuji); margin-top: 4px; }

.searchbar { display: flex; gap: 8px; margin-bottom: 14px; }
.searchbar input { flex: 1; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }

.empty { text-align: center; color: var(--ink-soft); font-size: 13.5px; padding: 40px 0; font-family: var(--serif); letter-spacing: .08em; }

/* ---- モーダル ---- */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-back { position: absolute; inset: 0; background: rgba(43, 42, 40, .35); }
.modal-box {
  position: relative; background: var(--bg); width: 100%; max-width: 680px;
  max-height: 92dvh; overflow-y: auto; border-radius: 16px 16px 0 0;
  padding: 20px 18px calc(env(safe-area-inset-bottom) + 24px);
}
@media (min-width: 700px) {
  .modal-wrap { align-items: center; }
  .modal-box { border-radius: 16px; max-height: 86dvh; }
}
.modal-title { font-family: var(--serif); font-size: 18px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.modal-title .close { margin-left: auto; }

.detail-img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); margin-bottom: 12px; }
details.raw { margin: 10px 0; }
details.raw summary { font-size: 12.5px; color: var(--ink-soft); cursor: pointer; }
details.raw pre { white-space: pre-wrap; font-family: var(--sans); font-size: 13px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 6px; }

.timeline { border-left: 2px solid var(--line); margin: 14px 0 0 6px; padding-left: 16px; }
.timeline .card { margin-bottom: 10px; }

/* ---- arc ---- */
.arc-export {
  width: 100%; min-height: 180px; font-size: 13px; line-height: 1.7;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.arc-item { display: flex; gap: 10px; align-items: flex-start; }
.arc-item input[type=checkbox] { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--fuji); }
.done-mark { font-size: 11px; color: var(--ok); }

/* ---- トースト ---- */
.toast {
  position: fixed; bottom: calc(env(safe-area-inset-bottom) + 96px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); border-radius: 999px; padding: 9px 20px;
  font-size: 13.5px; z-index: 100; box-shadow: 0 4px 16px rgba(0,0,0,.18); max-width: 88vw;
}
