:root {
  --brand: #0176d3;
  --brand-dark: #014486;
  --bg: #f3f3f3;
  --panel: #ffffff;
  --line: #dddbda;
  --text: #181818;
  --muted: #706e6b;
  --danger: #ba0517;
  font-family: "Yu Gothic UI", "Yu Gothic", "Meiryo", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 13px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); min-height: 100vh; }
button, select, input { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 5px 14px; cursor: pointer; }
button:hover { background: #f3f3f3; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
select, input { border: 1px solid var(--line); border-radius: 4px; padding: 5px 8px; background: #fff; min-width: 0; }
input:focus, select:focus { outline: 2px solid rgba(1,118,211,.35); border-color: var(--brand); }
code { background: #f3f3f3; padding: 0 4px; border-radius: 3px; font-size: 12px; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--brand-dark); }
.brand small { font-weight: 400; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; font-size: 10px; }

.top-actions { display: flex; align-items: center; gap: 14px; }
.top-link { color: var(--brand); text-decoration: none; }
.top-link:hover { text-decoration: underline; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px; }
.headline { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
h1 { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0; }
.stats { color: var(--muted); }
.stats b { color: var(--text); font-size: 18px; margin: 0 2px; }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 20px; }
.filters #q { width: 260px; }
.filters .sp { flex: 1; }
.filters .rec { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.filters .rec select { max-width: 340px; color: var(--text); }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, border-color .15s; }
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); border-color: #c9c7c5; }
.thumb { position: relative; display: block; background: #e5e7eb; height: 250px; overflow: hidden; cursor: pointer; border-bottom: 1px solid var(--line); }
.thumb .sheet { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.2); overflow: hidden; }
.thumb iframe { border: 0; transform-origin: 0 0; pointer-events: none; background: #fff; }
.thumb .open { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(1,68,134,.0); color: #fff; font-weight: 700; opacity: 0; transition: .15s; }
.thumb:hover .open, .thumb:focus-visible .open { opacity: 1; background: rgba(1,68,134,.55); }
.card .body { padding: 12px 14px 8px; flex: 1; }
.card h3 { font-size: 15px; margin: 0 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .id { font-family: Consolas, monospace; font-size: 11px; color: var(--muted); }
.card .desc { color: var(--muted); font-size: 12px; margin: 6px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chip { font-size: 11px; background: #f3f3f3; border-radius: 10px; padding: 1px 8px; color: #444; }
.chip.obj { background: #e5f2ff; color: var(--brand-dark); }
.card .meta { font-size: 11px; color: var(--muted); margin-top: 8px; }
.card .foot { display: flex; gap: 4px; padding: 8px 10px 10px; border-top: 1px solid #f0f0f0; }
.card .foot button { padding: 4px 10px; font-size: 12px; }
.card .foot .primary { flex: 1; }
.card .foot .del { color: var(--danger); }

.card.new { border: 2px dashed #c9c7c5; background: transparent; align-items: center; justify-content: center; min-height: 380px; cursor: pointer; color: var(--muted); font-size: 14px; gap: 8px; }
.card.new:hover { border-color: var(--brand); color: var(--brand); box-shadow: none; background: #fff; }
.card.new .plus { font-size: 40px; line-height: 1; }

.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px; background: var(--panel); border: 1px dashed var(--line); border-radius: 8px; }

/* dialogs */
.dlg { border: 0; border-radius: 10px; padding: 0; width: min(560px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.dlg.small { width: min(440px, 94vw); }
.dlg::backdrop { background: rgba(8,7,7,.45); }
.dlg form { padding: 20px 24px; }
.dlg h2 { font-size: 17px; margin: 0 0 14px; }
.f { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 4px 10px; margin-bottom: 10px; }
.f > span { color: #444; }
.f em { color: var(--danger); font-style: normal; }
.f small { grid-column: 2; color: var(--muted); font-size: 11px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 12px; padding: 8px 12px 10px; }
legend { color: #444; padding: 0 4px; }
.radio { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.radio select { margin-left: 6px; flex: 1; }
.paper { display: flex; gap: 10px; }
.paper label { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 6px; padding: 10px 4px 8px; cursor: pointer; font-size: 12px; }
.paper input { position: absolute; opacity: 0; pointer-events: none; }
.paper i { display: block; width: calc(var(--w) * 1.6px); height: calc(var(--h) * 1.6px); border: 1.5px solid #aaa; background: #fff; border-radius: 2px; }
.paper label:has(input:checked) { border-color: var(--brand); background: #e5f2ff; color: var(--brand-dark); font-weight: 700; }
.paper label:has(input:checked) i { border-color: var(--brand); }
.paper label:has(input:focus-visible) { outline: 2px solid rgba(1,118,211,.4); }
.dlg .is-copy .blank-only, .dlg .is-copy .no-copy, .dlg .is-format .blank-only { display: none; }
.format-note { display: none; margin: 0 0 6px 22px; font-size: 11px; color: var(--muted); line-height: 1.5; }
.dlg .is-format .format-note { display: block; }
.err { color: var(--danger); min-height: 1em; margin: 4px 0 0; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #032d60; color: #fff; padding: 8px 18px; border-radius: 6px; opacity: 0; transition: .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.how .radio { align-items: flex-start; flex-wrap: wrap; } .how .radio small { flex-basis: 100%; margin-left: 22px; color: var(--muted); font-size: 11px; }

/* 選択式の入力: 入力して絞り込み → 候補から選ぶ (pick.js) */
.pick-combo { position: relative; display: block; grid-column: 2; min-width: 0; }
.pick-input { width: 100%; box-sizing: border-box; }
.pick-list { position: absolute; z-index: 1000; left: 0; right: 0; top: calc(100% + 2px); max-height: 280px; overflow: auto; background: #fff; border: 1px solid #c8d3d6; border-radius: 4px; box-shadow: 0 6px 16px rgba(0, 0, 0, .15); font-size: 12px; text-align: left; }
.pick-grp { position: sticky; top: 0; padding: 4px 8px; font-weight: 700; color: #556; background: #f1f5f6; }
.pick-opt { padding: 5px 10px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #222; }
.pick-opt.active { background: #dcefF1; }
.pick-opt.cur { font-weight: 700; }
.pick-none { padding: 6px 10px; color: #888; }

/* 表示条件 */
.dlg.wide-cond { width: min(760px, 96vw); }
.dlg h2 small { font-size: 12px; font-weight: normal; color: #666; margin-left: 6px; }
.cond-match { display: flex; gap: 16px; margin: 10px 0; }
.cond-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.cond-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.2fr) minmax(0, 1.6fr) auto; gap: 6px; align-items: center; }
.cond-row select, .cond-row input { width: 100%; min-width: 0; box-sizing: border-box; }
.cond-row .pick-combo { min-width: 0; }
.cond-row .rm { color: var(--danger); padding: 4px 8px; }
.cond-hint { margin-top: 10px; }
.dlg .actions .sp { flex: 1; }
.chip.cond { background: #fef3c7; color: #92400e; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) { .cond-row { grid-template-columns: 1fr 1fr; } }
