/* 管理画面だけの見た目。共通の見た目（色・ボタン・入力・タグ・状態の印・アイコン・断面の絵など）は
   /base.css（web-ui/styles/base.css）。閲覧サイトと見分けるのは、上の帯の添え字（「LIBRARY 管理画面」の赤）。
   CSP の style-src 'self' のため、見た目はすべて CSS のファイルに書く（HTML に style 属性を書かない）。 */

/* ---- 最初のページ ---- */


.home-menu {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-menu__link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--text);
  text-decoration: none;
}

.home-menu__link:hover {
  border-color: var(--creation);
  color: var(--text);
  text-decoration: none;
}

.home-menu__label {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 800;
}

/* ---- 入力の並び ---- */

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.form h2 {
  margin-top: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin: 12px 0 16px;
}

.toolbar .field {
  min-width: 200px;
}

.search-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

input[type="file"] {
  color: var(--text);
  font: inherit;
}

/* ---- 表と行 ---- */

/* 表：パネルと同じ地と角の丸み。見出しの行は薄い文字 */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table th,
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table th {
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8125rem;
}

.table tbody tr:hover td {
  background: rgb(255 255 255 / 0.02);
}

.nowrap {
  white-space: nowrap;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.row--deleted {
  border-style: dashed;
  opacity: 0.85;
}

.row__main {
  display: flex;
  gap: 12px;
  min-width: 0;
  flex: 1 1 320px;
}

.row__shape {
  width: 64px;
  flex-shrink: 0;
  background: var(--surface-2);
  border-radius: 10px;
}

.row__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.row__title {
  font-weight: 700;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.row__author {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.row__form {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag--static {
  cursor: default;
}

/* ---- 発行した招待リンク ---- */

/* 発行した招待リンク（見本の「お知らせ」の形。注意の文は金色） */
.issued {
  border-color: #3d3a6d;
  background: linear-gradient(90deg, rgb(74 91 255 / 0.1), rgb(139 92 246 / 0.08)), var(--surface);
  margin-bottom: 24px;
}

.issued h2 {
  margin-top: 0;
}

.issued__warning {
  color: var(--gold);
}

.issued__warning strong {
  color: var(--gold);
}

.issued__link {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.issued__link input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* ---- 作者を決める部品 ---- */

.author-picker {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.author-picker .check {
  margin: 4px 0;
}

.author-picker__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 8px 28px;
  max-width: 480px;
}

/* ---- まとめて登録 ---- */

.import-table__shape {
  width: 72px;
}

.import-table__invalid td {
  background: rgb(229 72 95 / 0.06);
}

.problems {
  margin: 0;
  padding-left: 1.2em;
  color: var(--destruction-text);
  font-size: 0.875rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ---- 操作の記録 ---- */

.audit-table {
  table-layout: fixed;
}

.audit-table__time {
  width: 160px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.audit-table__actor {
  width: 22%;
}

.audit-table__action {
  width: 22%;
}

.audit-table__target {
  width: 6.5em;
  white-space: nowrap;
}

.audit-table__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-table__row {
  cursor: pointer;
}

.audit-table__row:hover td {
  background: var(--surface-2);
}

.audit-table__row--open td {
  background: var(--surface-2);
  border-bottom-color: transparent;
}

.audit-table__toggle {
  color: var(--text);
}

.audit-table__toggle:hover {
  text-decoration: none;
  color: var(--creation);
}

.audit-table__detail td {
  background: var(--surface-2);
}

.audit-detail {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 16px;
  margin: 0;
}

.audit-detail dt {
  color: var(--muted);
  font-size: 0.875rem;
}

.audit-detail dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.audit-detail__json {
  margin: 0;
  padding: 8px 10px;
  max-height: 320px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.8125rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---- スマホの幅 ---- */

@media (max-width: 720px) {
  .table {
    display: block;
    overflow-x: auto;
  }

  .issued__link {
    flex-direction: column;
  }

  /* 操作の記録は、スマホの幅では1件ずつの札にする（項目名を前に付ける） */
  .audit-table,
  .audit-table tbody,
  .audit-table tr,
  .audit-table td {
    display: block;
    width: auto;
  }

  .audit-table thead {
    display: none;
  }

  .audit-table__row {
    padding: 8px 0;
    border-top: 1px solid var(--line);
  }

  .audit-table__row td {
    display: grid;
    grid-template-columns: 6.5em minmax(0, 1fr);
    gap: 8px;
    padding: 2px 4px;
    border-bottom: 0;
    white-space: normal;
  }

  .audit-table__row td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.8125rem;
  }

  .audit-detail {
    grid-template-columns: minmax(0, 1fr);
  }
}
