/* =================================================================
   バナー管理ツール
   スクリーンショットの配色に合わせたダーク基調
   ================================================================= */
:root {
  --bg:        #141414;
  --bg-panel:  #1f1f1f;
  --bg-raise:  #262626;
  --line:      #333;
  --line-soft: #2b2b2b;
  --fg:        #ececec;
  --fg-dim:    #a8a8a8;
  --fg-faint:  #7a7a7a;

  --accent:      #e0503a;   /* 追加する・主ボタン */
  --accent-hover:#c94530;
  --amber:       #c99a3a;   /* 現在配信中のバナー・未仕分け */
  --green:       #3f9e63;   /* 仕分け済み */

  --card:      #fff;
  --card-fg:   #1c1c1c;
  --card-dim:  #6b6b6b;

  --radius: 6px;
  --radius-lg: 10px;
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN",
          "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 14px; line-height: 1.7;
}
a { color: inherit; }
code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }

/* ---------- 汎用レイアウト ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 20px 64px; }
.wrap.narrow { max-width: 860px; }
.stack { display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; }
.inline { display: inline; }
.hidden-form { display: none; }
.right { text-align: right; }
.num { text-align: right; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.muted { opacity: .5; }

.brand {
  font-size: 11px; letter-spacing: .18em; font-weight: 700;
  color: var(--accent); display: flex; align-items: center; gap: 7px;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; }

.page-title { font-size: 22px; font-weight: 700; margin: 4px 0 0; letter-spacing: .02em; }
.section-title { font-size: 15px; font-weight: 700; margin: 32px 0 10px; color: var(--fg-dim); }
.section-label { font-size: 12px; color: var(--fg-dim); margin: 0; }
.lead { color: var(--fg-dim); margin: 0 0 4px; }
.hint { color: var(--fg-faint); font-size: 12px; margin: 2px 0 0; line-height: 1.6; }
.meta { color: var(--fg-faint); font-size: 12px; }
.empty { color: var(--fg-faint); text-align: center; padding: 48px 0; }

/* ---------- トップバー ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: #111;
}
.topbar-brand { text-decoration: none; font-size: 11px; letter-spacing: .18em;
  font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 7px; }
.topbar-tenants { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.chip {
  font-size: 12px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--fg-dim); text-decoration: none;
}
.chip:hover { border-color: #4a4a4a; color: var(--fg); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.topbar-link { font-size: 12px; color: var(--fg-dim); text-decoration: none; }
.topbar-link:hover { color: var(--fg); }
.as-button { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: 12px; }

.foot {
  border-top: 1px solid var(--line); padding: 18px 20px; text-align: center;
  color: var(--fg-faint); font-size: 11.5px;
}
.foot .sep { margin: 0 8px; opacity: .5; }

/* ---------- フラッシュ ---------- */
.flash-area { max-width: 1200px; margin: 14px auto 0; padding: 0 20px; display: grid; gap: 8px; }
.flash {
  padding: 10px 14px; border-radius: var(--radius); font-size: 13px;
  border: 1px solid; line-height: 1.6;
}
.flash.ok  { background: #16301f; border-color: #2f5c3f; color: #b9e6c8; }
.flash.err { background: #341a17; border-color: #6b332b; color: #f0b8ae; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none;
  font-family: inherit; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.amber { background: var(--amber); color: #241c08; }
.btn.amber:hover { background: #b98b2f; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--fg-dim); }
.btn.ghost:hover { border-color: #4d4d4d; color: var(--fg); }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

.tool-link {
  background: none; border: 0; padding: 0; font: inherit; font-size: 12px;
  color: var(--fg-dim); text-decoration: underline; cursor: pointer;
}
.tool-link:hover { color: var(--fg); }
.tool-link.danger { color: #d9705f; }
.page-tools { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 28px; }

/* ---------- フォーム ---------- */
label { display: block; font-size: 12px; color: var(--fg-dim); }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=search], input[type=month], textarea, select {
  width: 100%; margin-top: 5px; padding: 9px 11px;
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--fg); font: inherit; font-size: 13px;
}
input:focus, textarea:focus, select:focus {
  outline: 0; border-color: var(--accent); background: #2c2c2c;
}
input:disabled { opacity: .55; }
textarea { resize: vertical; }
::placeholder { color: #6a6a6a; }

.panel {
  background: var(--bg-panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg); padding: 20px;
}

.field { margin-bottom: 16px; }
.field-label { display: block; font-size: 12px; color: var(--fg-dim); margin-bottom: 7px; }

.checks, .opts { display: flex; flex-wrap: wrap; gap: 7px; }
.check, .opt {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  padding: 5px 11px; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--fg-dim); cursor: pointer; user-select: none; background: var(--bg-raise);
}
.check:hover, .opt:hover { border-color: #4d4d4d; }
.check input, .opt input { accent-color: var(--accent); margin: 0; }
.check:has(input:checked), .opt:has(input:checked) {
  border-color: var(--accent); color: #fff; background: #2e1c19;
}

.segmented { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.seg {
  font-size: 12.5px; padding: 6px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--fg-dim); cursor: pointer; background: var(--bg-raise);
}
.seg input { display: none; }
.seg.on, .seg:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- ページ見出し ---------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 22px;
}
.page-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.head-sub-link { font-size: 11.5px; color: var(--fg-dim); flex-basis: 100%; text-align: right; }

/* ---------- 絞り込み ---------- */
.filters {
  background: var(--bg-panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg); padding: 18px; margin-bottom: 26px;
}
.filter-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 20px;
}
.filter-col { min-width: 0; }
.filter-label { display: block; font-size: 11.5px; color: var(--fg-faint); margin-bottom: 8px; }
.filter-foot {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}
.filter-search { max-width: 260px; flex: 1; }
.filter-foot-right { display: flex; align-items: center; gap: 12px; }
.count { font-size: 12px; color: var(--fg-dim); }

/* ---------- カード ---------- */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  /* 既定では行内で最も高いカードに合わせて全体が伸び、
     縦横比の違う画像が並ぶと下に余白ができるため上寄せにする */
  align-items: start;
}
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; color: var(--card-fg);
}
.card.is-deleted { opacity: .55; }
.card-visual {
  position: relative; border: 0; padding: 0; margin: 0; cursor: pointer;
  background: #f2f2f2; display: block; width: 100%; min-height: 130px;
  /* 市松模様。透過画像であることが分かるようにする */
  background-image:
    linear-gradient(45deg, #e3e3e3 25%, transparent 25%, transparent 75%, #e3e3e3 75%),
    linear-gradient(45deg, #e3e3e3 25%, transparent 25%, transparent 75%, #e3e3e3 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.card-visual img { display: block; width: 100%; height: auto; }
.status-dot {
  position: absolute; top: 9px; left: 9px; width: 9px; height: 9px; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,255,255,.85); z-index: 1;
}
.status-dot.unsorted { background: var(--amber); }
.status-dot.sorted   { background: var(--green); }
.kind-badge {
  position: absolute; bottom: 8px; right: 8px; font-size: 10px; font-weight: 700;
  background: rgba(0,0,0,.72); color: #fff; padding: 2px 7px; border-radius: 3px;
}
.video-ph {
  display: grid; place-items: center; gap: 4px; padding: 44px 0;
  background: #2a2a2a; color: #cfcfcf;
}
.video-ph-icon { font-size: 22px; }
.video-ph-text { font-size: 11px; letter-spacing: .1em; }

.card-body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { font-size: 13px; font-weight: 600; margin: 0; line-height: 1.5; word-break: break-word; }
.card-title.unset { color: var(--card-dim); font-weight: 400; font-size: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-size: 10.5px; padding: 1px 6px; border: 1px solid #d6d6d6;
  border-radius: 3px; color: #575757; line-height: 1.6;
}
.tag.intent { border-color: #c3c3c3; background: #f4f4f4; color: #3f3f3f; }
.card-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: auto; font-size: 11px; flex-wrap: wrap;
}
.card-foot .meta { color: var(--card-dim); white-space: nowrap; }
.state { font-size: 11px; font-weight: 600; white-space: nowrap; }
.state.unsorted { color: #b07d16; }
.state.sorted   { color: #2f7d4d; }
.state.deleted  { color: #a34a3c; }

.more { text-align: center; margin-top: 28px; }

/* ---------- テーブル ---------- */
.table { width: 100%; border-collapse: collapse; margin-bottom: 8px; font-size: 13px; }
.table th, .table td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
.table th { font-size: 11.5px; color: var(--fg-faint); font-weight: 600; }
.table.dense th, .table.dense td { padding: 6px 10px; font-size: 12px; }
.table .empty { padding: 32px 0; }
.badge {
  display: inline-block; font-size: 10px; padding: 1px 7px; border-radius: 3px;
  border: 1px solid var(--line); color: var(--fg-dim); margin-left: 6px;
}
.badge.amber { border-color: #6b5520; color: var(--amber); }

/* ---------- 領域選択 ---------- */
.tenant-list { display: grid; gap: 10px; }
.tenant-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 18px; background: var(--bg-panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg); text-decoration: none;
}
.tenant-row:hover { border-color: #454545; background: var(--bg-raise); }
.tenant-name { font-size: 15px; font-weight: 600; }
.tenant-stats { display: flex; align-items: center; gap: 10px; }

/* ---------- モーダル ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: start center;
         overflow-y: auto; padding: 32px 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.68); }
.modal-panel {
  position: relative; width: 100%; max-width: 520px; background: #fbfbfb; color: #1c1c1c;
  border-radius: var(--radius-lg); padding: 22px; box-shadow: 0 24px 64px rgba(0,0,0,.5);
}
.modal-title { font-size: 16px; font-weight: 700; margin: 0; }
.modal-sub { font-size: 11.5px; color: #7a7a7a; margin: 3px 0 18px; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 20px; padding-top: 16px; border-top: 1px solid #e4e4e4;
}
.modal-foot-right { display: flex; gap: 10px; }

/* モーダル内は明色。フォーム部品の配色を上書きする */
.modal-panel label { color: #5a5a5a; }
.modal-panel .field-label { color: #5a5a5a; }
.modal-panel input[type=text], .modal-panel input[type=month],
.modal-panel textarea, .modal-panel select {
  background: #fff; border-color: #d5d5d5; color: #1c1c1c;
}
.modal-panel input:focus, .modal-panel textarea:focus { background: #fff; border-color: var(--accent); }
.modal-panel .check {
  background: #fff; border-color: #d5d5d5; color: #4a4a4a;
}
.modal-panel .check:has(input:checked) { border-color: var(--accent); color: var(--accent); background: #fdf2f0; }
.modal-panel .seg { background: #fff; border-color: #d5d5d5; color: #4a4a4a; }
.modal-panel .seg:has(input[value=unsorted]:checked) { background: var(--amber); border-color: var(--amber); color: #241c08; }
.modal-panel .seg:has(input[value=sorted]:checked)  { background: #fff; border-color: #b9b9b9; color: #1c1c1c; font-weight: 700; }
.modal-panel .hint { color: #8a8a8a; }
.modal-panel .btn.ghost { border-color: #cfcfcf; color: #5a5a5a; }
.modal-panel .btn.ghost:hover { border-color: #9a9a9a; color: #1c1c1c; }

/* 追加・アップロードモーダル：ドロップゾーンとプレビュー */
.dropzone {
  display: grid; place-items: center; padding: 26px 16px; text-align: center;
  border: 2px dashed #cfcfcf; border-radius: var(--radius); background: #fff;
  cursor: pointer; color: #7a7a7a; font-size: 13px;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: #fdf4f2; color: var(--accent); }
.dropzone-sub { font-size: 11.5px; color: #9a9a9a; }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 12px; }
.pv { position: relative; border-radius: 4px; overflow: hidden; background: #eee; aspect-ratio: 1; }
.pv img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-del {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border: 0;
  border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; cursor: pointer;
  font-size: 13px; line-height: 20px; padding: 0;
}
.pv-name {
  position: absolute; bottom: 0; left: 0; right: 0; font-size: 9px; padding: 2px 4px;
  background: rgba(0,0,0,.6); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 仕分けモーダル：画像プレビュー */
.detail-visual { margin-bottom: 12px; border-radius: var(--radius); overflow: hidden; background: #eee; }
.detail-visual img { display: block; width: 100%; height: auto; max-height: 420px; object-fit: contain; background: #f4f4f4; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.detail-actions .btn { flex: 1; }
.detail-actions .btn.ghost { border-color: #cfcfcf; color: #5a5a5a; background: #fff; }

/* 2回押しではなく明示的な確認にするための削除ボタン */
.delete-zone { display: flex; align-items: center; gap: 10px; }
.delete-zone .tool-link { color: #b5493a; }
.delete-confirm { font-size: 11.5px; color: #b5493a; }

/* ---------- 未認証画面 ---------- */
body.plain { display: grid; place-items: center; min-height: 100vh; }
.auth-shell { width: 100%; padding: 24px; }
.auth-card {
  max-width: 380px; margin: 0 auto; background: var(--bg-panel);
  border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 28px;
}
.auth-title { font-size: 18px; font-weight: 700; margin: 14px 0 16px; }
.auth-lead { font-size: 13px; color: var(--fg-dim); margin: 0 0 18px; line-height: 1.7; }
.auth-sub { font-size: 12px; color: var(--fg-dim); margin: 16px 0 0; text-align: center; }
.auth-card .flash { margin-bottom: 14px; }

/* ---------- 狭い画面 ---------- */
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-head-actions { width: 100%; justify-content: flex-start; }
  .head-sub-link { text-align: left; }
  .filter-foot { flex-direction: column; align-items: stretch; }
  .card-foot { flex-direction: column; align-items: flex-start; gap: 3px; }
  .area-title { font-size: 21px; }
  .tab { padding: 12px 18px; font-size: 14px; }
  .area-bar { align-items: stretch; }
  .area-actions { padding-bottom: 12px; }
  /* 狭い画面でも縦に積まず、両方を縮める */
  .tenant-nav { width: 100%; gap: 8px; }
  .tenant-pick { flex: 1 1 0; }
  .tenant-find { flex: 1 1 0; }
  .find-results { width: min(300px, calc(100vw - 32px)); }
  .filter-search { max-width: none; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---------- 選択肢（配信意図）の編集 ---------- */
.filter-edit {
  font-size: 10.5px; color: var(--fg-faint); text-decoration: underline;
  margin-left: 6px;
}
.filter-edit:hover { color: var(--accent); }

.panel.note { margin-bottom: 22px; }
.panel.note p { margin: 0 0 8px; color: var(--fg-dim); font-size: 13px; }
.panel.note ul { margin: 0; padding-left: 1.2em; color: var(--fg-faint); font-size: 12.5px; line-height: 1.9; }
.panel.note strong { color: var(--fg); font-weight: 600; }

.options-table th { white-space: nowrap; }
.options-table td { vertical-align: middle; }
.options-table input[type=text] { margin-top: 0; }
.options-table .code {
  display: block; margin-top: 3px; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10.5px; color: #5f5f5f;
}
.options-table .narrow-num { margin-top: 0; text-align: right; }
.options-table input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.options-table .center { text-align: center; }
.options-table tr.add-head td { border-bottom: 0; padding-top: 22px; padding-bottom: 2px; }
.options-table tr.add-head .section-label { color: var(--fg-faint); }
.modal-panel .check.retired {
  border-style: dashed; color: #8a6a20; background: #fdf8ec; border-color: #d8bd76;
}

/* ---------- 領域の見出しとタブ ---------- */
.area-title {
  font-size: 26px; font-weight: 700; letter-spacing: .01em;
  margin: 0 0 18px; line-height: 1.4;
}
.area-bar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); margin-bottom: 20px;
}
.tabs { display: flex; gap: 4px; margin-bottom: -1px; }
.tab {
  padding: 14px 28px; font-size: 15px; font-weight: 700; text-decoration: none;
  color: var(--fg-dim); border: 1px solid transparent; border-bottom: 0;
  border-radius: 8px 8px 0 0; background: transparent;
}
.tab:hover { color: var(--fg); background: #1c1c1c; }
/* 選択中は下の枠線を消して、コンテンツと地続きに見せる */
.tab.on {
  color: var(--fg); background: var(--bg-panel);
  border-color: var(--line); position: relative;
}
.tab.on::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 1px; background: var(--bg-panel);
}
.area-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 10px;
}
.area-sub { margin: -8px 0 22px; font-size: 12.5px; color: var(--fg-dim); }
.area-sub a { color: var(--fg-dim); }
.area-sub a:hover { color: var(--accent); }

/* ---------- 期間の範囲入力 ---------- */
.range { display: flex; align-items: center; gap: 6px; }
.range input { margin-top: 0; }
.range-sep { color: var(--fg-faint); font-size: 12px; flex: 0 0 auto; }
.filter-col.wide { grid-column: span 2; }
.check.mt { margin-top: 10px; }
.opt.empty { opacity: .45; }
.opt-n { font-size: 10px; color: var(--fg-faint); margin-left: 3px; }

/* ---------- メディア一覧 ---------- */
.media-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.file-card .card-visual { min-height: 118px; display: grid; place-items: center; }
.file-name {
  font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-icon {
  display: grid; place-items: center; gap: 5px; width: 100%; padding: 30px 8px;
  background: #ececec; color: #4a4a4a;
}
.file-icon.big { padding: 60px 8px; border-radius: var(--radius); }
.file-ext {
  font-size: 17px; font-weight: 700; letter-spacing: .06em;
  padding: 5px 12px; border-radius: 4px; background: #fff; border: 1px solid #cfcfcf;
}
.file-cat { font-size: 10.5px; color: #7a7a7a; }
/* 種別ごとに色を変えて、一覧で見分けやすくする */
.file-icon.cat-pdf          { background: #f6e4e2; } .cat-pdf .file-ext          { color: #b03a2b; border-color: #e0b8b2; }
.file-icon.cat-document     { background: #e3ebf7; } .cat-document .file-ext     { color: #2c5aa0; border-color: #b8c9e4; }
.file-icon.cat-spreadsheet  { background: #e2f0e6; } .cat-spreadsheet .file-ext  { color: #2c7a45; border-color: #b4d6c0; }
.file-icon.cat-presentation { background: #fbeade; } .cat-presentation .file-ext { color: #b5651d; border-color: #e5c9a9; }
.file-icon.cat-video        { background: #e8e4f3; } .cat-video .file-ext        { color: #5a3fa0; border-color: #c6bce0; }
.file-icon.cat-archive      { background: #eeeadd; } .cat-archive .file-ext      { color: #7a6a2c; border-color: #d5cbaa; }

.used-badge {
  position: absolute; top: 8px; right: 8px; font-size: 10px; font-weight: 700;
  background: rgba(224,80,58,.9); color: #fff; padding: 2px 7px; border-radius: 3px;
}

/* ---------- メディアから選ぶ（ピッカー） ---------- */
.field-link { font-size: 11px; margin-left: 8px; color: var(--accent); }
.modal-panel.wide { max-width: 640px; }
.picker-search {
  margin-bottom: 10px; background: #fff; border-color: #d5d5d5; color: #1c1c1c;
}
.picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px; max-height: 260px; overflow-y: auto; padding: 10px;
  border: 1px solid #e0e0e0; border-radius: var(--radius); background: #fff;
}
.pick {
  position: relative; display: block; cursor: pointer; border: 2px solid transparent;
  border-radius: 4px; overflow: hidden; background: #f4f4f4; padding: 0;
}
.pick[hidden] { display: none; }
.pick input { position: absolute; top: 4px; left: 4px; z-index: 2; accent-color: var(--accent); }
.pick img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.pick-icon {
  display: grid; place-items: center; aspect-ratio: 1; font-size: 12px;
  font-weight: 700; color: #5a5a5a; background: #e8e8e8;
}
.pick-name {
  display: block; font-size: 9.5px; padding: 3px 4px; color: #5a5a5a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pick:has(input:checked) { border-color: var(--accent); }
.pick:has(input:checked) .pick-name { background: var(--accent); color: #fff; }

/* アップロード前プレビューの拡張子表示 */
.pv-ext {
  display: grid; place-items: center; width: 100%; height: 100%;
  font-size: 12px; font-weight: 700; color: #5a5a5a; background: #e6e6e6;
}

/* ファイル詳細のプレビュー */
.detail-visual video { display: block; width: 100%; max-height: 420px; background: #000; }
.detail-visual iframe { display: block; width: 100%; height: 420px; border: 0; background: #fff; }

/* ---------- カードの高さを揃える ---------- */
/* メディアはファイル管理なので、WordPress のように正方形タイルで並べる */
.media-grid .card-visual { aspect-ratio: 1; padding: 0; overflow: hidden; }
.media-grid .card-visual img { width: 100%; height: 100%; object-fit: cover; }
.media-grid .file-icon { width: 100%; height: 100%; padding: 8px; }

/* バナーは中身を確認する画面なので全体を見せる。
   ただし 9:16 のような縦長で極端に伸びないよう高さを抑える */
.grid:not(.media-grid) .card-visual {
  display: grid; place-items: center; max-height: 300px;
}
.grid:not(.media-grid) .card-visual img {
  width: auto; height: auto; max-width: 100%; max-height: 300px;
}

/* ---------- 拡張子チップ ---------- */
.opt.ext { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; font-weight: 600; }
.opt.ext.cat-image        { border-left: 3px solid #4a90c4; }
.opt.ext.cat-video        { border-left: 3px solid #7a5fc0; }
.opt.ext.cat-pdf          { border-left: 3px solid #c4574a; }
.opt.ext.cat-document     { border-left: 3px solid #4a6fc4; }
.opt.ext.cat-spreadsheet  { border-left: 3px solid #4aa06a; }
.opt.ext.cat-presentation { border-left: 3px solid #c4854a; }
.opt.ext.cat-archive      { border-left: 3px solid #9a8a4a; }
.opt.ext.cat-other        { border-left: 3px solid #6a6a6a; }

/* ---------- ログイン画面のサイト名 ---------- */
.auth-brand {
  font-size: 13px; font-weight: 700; color: var(--fg-dim);
  letter-spacing: .04em; margin-bottom: 4px;
}

/* ---------- 領域の切り替え ---------- */
/* プルダウンと検索窓を横並びにし、間を少し開ける。
   幅が狭くても縦に折り返さず、両方が縮むようにしている。 */
.tenant-nav {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: nowrap; min-width: 0;
}
.tenant-pick { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 210px; }
.tenant-find { position: relative; min-width: 0; flex: 0 1 190px; }

/* 高さと余白を揃える。
   select と input[type=search] は既定の内寸が違うので明示的に合わせる。 */
select#tenant-select,
input.find-input {
  margin-top: 0; height: 34px; padding: 0 10px; font-size: 13px;
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--fg);
  width: 100%; min-width: 0;
}
select#tenant-select { font-weight: 600; cursor: pointer; }
select#tenant-select:hover,
input.find-input:hover { border-color: #4d4d4d; }
input.find-input::placeholder { color: #6a6a6a; }

.find-results {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  list-style: none; margin: 0; padding: 6px;
  width: 300px; max-width: calc(100vw - 32px); max-height: 320px; overflow-y: auto;
  background: #1b1b1b; border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: 0 16px 40px rgba(0,0,0,.55);
}
.find-results[hidden] { display: none; }
.find-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius); text-decoration: none;
  color: var(--fg-dim); font-size: 13px;
}
.find-item:hover, .find-item.on {
  background: var(--bg-raise); color: var(--fg);
}
.find-item.on { box-shadow: inset 0 0 0 1px var(--accent); }
.find-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.find-slug {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10.5px; color: var(--fg-faint); flex: 0 0 auto;
}
.find-empty {
  padding: 12px 10px; font-size: 12px; color: var(--fg-faint); text-align: center;
}

/* バナーを追加できない利用者への案内 */
.area-note {
  margin: -6px 0 22px; padding: 10px 14px; font-size: 12.5px; line-height: 1.8;
  color: var(--fg-dim); background: var(--bg-panel);
  border: 1px solid var(--line-soft); border-radius: var(--radius);
}
.area-note a { color: var(--accent); }

/* ---------- ゴミ箱の操作 ---------- */
.trash-zone { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trash-sep { color: #c4c4c4; }
.trash-zone .restore { color: #2c7a45; }
.used-trashed { font-weight: 400; opacity: .85; }

/* 利用者一覧の種別変更 */
.inline-role { display: inline-block; }
.inline-role select {
  width: auto; min-width: 120px; margin-top: 0; padding: 4px 8px; font-size: 12px;
}
