:root {
  --bg: #fff;
  --fg: #09090b;
  --muted: #71717a;
  --muted-bg: #f4f4f5;
  --border: #e4e4e7;
  --primary: #18181b;
  --primary-fg: #fafafa;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --success: #15803d;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.header {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 30;
}

.brand {
  font-weight: 650;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user {
  font-size: 13px;
  color: var(--muted);
}

main {
  padding: 28px;
  max-width: 1680px;
  margin: 0 auto;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: 24px;
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.02em;
  word-break: break-all;
}

.page-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.btn {
  height: 36px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 7px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 520;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover {
  background: #fafafa;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-fg);
}

.btn.primary:hover {
  background: #27272a;
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.btn.danger:hover {
  background: #b91c1c;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.small {
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.icon-btn {
  width: 34px;
  padding: 0;
}

.link-btn {
  border: 0;
  background: transparent;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
  cursor: pointer;
  color: inherit;
}

.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.toolbar-left {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search {
  width: 360px;
}

.input,
.select,
.textarea {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: white;
  outline: none;
}

.input {
  height: 36px;
  padding: 0 10px;
  width: 100%;
}

.select {
  height: 36px;
  padding: 0 30px 0 10px;
  min-width: 190px;
}

.textarea {
  padding: 9px 10px;
  width: 100%;
  min-height: 84px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  box-shadow: 0 0 0 2px #e4e4e7;
}

.selection {
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  background: #fafafa;
}

.selection strong {
  font-weight: 600;
}

.subtle {
  color: var(--muted);
}

.table-card {
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 1280px;
}

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

th {
  height: 42px;
  background: #fafafa;
  color: #52525b;
  font-size: 12px;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

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

tbody tr:hover {
  background: #fafafa;
}

tbody tr.selected {
  background: #f4f4f5;
}

.col-check {
  width: 42px;
}

.thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafafa;
  display: block;
}

.thumb-button {
  border: 0;
  padding: 0;
  background: none;
  display: block;
  cursor: zoom-in;
}

.thumb-button:hover .thumb,
.thumb-button:focus-visible .thumb {
  border-color: #a1a1aa;
}

.filename {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.filename-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.filename-link {
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.original,
.comment {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.original {
  width: 220px;
  max-width: 220px;
}

.comment {
  width: 280px;
  max-width: 280px;
  min-width: 220px;
}

.creator {
  width: 220px;
}

.creator,
.date {
  white-space: nowrap;
}

.size-cell {
  font-size: 12px;
  white-space: nowrap;
  line-height: 1.4;
}

.size-cell span {
  display: block;
}

.url-cell {
  min-width: 410px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.url-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: nowrap;
  -webkit-user-select: all;
  user-select: all;
  cursor: text;
}

.row-check {
  width: 16px;
  height: 16px;
}

.menu {
  position: relative;
}

.menu-pop {
  position: fixed;
  width: 190px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  display: none;
  z-index: 40;
}

.menu.open .menu-pop {
  display: block;
}

.menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 9px;
  border-radius: 6px;
}

.menu-item:hover {
  background: var(--muted-bg);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  gap: 16px;
}

.pagination-left,
.pagination-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-buttons {
  display: flex;
  gap: 4px;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: white;
}

.page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #52525b;
  margin-bottom: 18px;
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.upload-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.7fr);
  gap: 18px;
}

.section {
  padding: 18px;
}

.section h2 {
  font-size: 15px;
  margin: 0 0 14px;
}

.drop {
  border: 1px dashed #cbd5e1;
  border-radius: 9px;
  background: #fafafa;
  padding: 34px 20px;
  text-align: center;
}

.drop.dragover {
  border-color: #71717a;
  background: #f4f4f5;
}

.drop strong {
  display: block;
  margin-bottom: 4px;
}

.drop p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
}

.file-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-row.invalid {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.file-preview {
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafafa;
  object-fit: contain;
}

.file-info {
  min-width: 0;
  flex: 1;
}

.file-info strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info span {
  font-size: 12px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field-help {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.field-error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.result {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.result-row:last-child {
  border-bottom: 0;
}

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

.status {
  font-size: 12px;
  border-radius: 999px;
  padding: 2px 9px;
  border: 1px solid var(--border);
  background: #fafafa;
  white-space: nowrap;
}

.status.done {
  color: var(--success);
  background: var(--success-bg);
  border-color: var(--success-border);
}

.status.failed {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.status.unconfirmed {
  color: #92400e;
  background: var(--warning-bg);
  border-color: var(--warning-border);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(500px, 1.1fr);
  gap: 18px;
}

.preview-large {
  min-height: 420px;
  display: grid;
  place-items: center;
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 18px;
}

.preview-large img {
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
}

.preview-large .thumb-button {
  max-width: 100%;
}

.preview-large .thumb-button img {
  display: block;
}

.detail-list {
  margin: 0;
}

.detail-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row dt {
  color: var(--muted);
  white-space: nowrap;
}

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

.badge {
  display: inline-flex;
  border: 1px solid var(--border);
  background: #fafafa;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  margin-right: 5px;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.warning {
  border: 1px solid var(--warning-border);
  background: var(--warning-bg);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 13px;
}

.warning.danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.dialog-backdrop.show {
  display: flex;
}

.dialog {
  width: min(620px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.dialog-head,
.dialog-body,
.dialog-actions {
  padding: 18px;
}

.dialog-head {
  border-bottom: 1px solid var(--border);
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.dialog-actions {
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #18181b;
  color: white;
  padding: 10px 13px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.18s;
  pointer-events: none;
  z-index: 200;
  max-width: 420px;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.tooltip {
  position: fixed;
  z-index: 300;
  background: #18181b;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.tooltip.show {
  opacity: 1;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
  z-index: 150;
}

.lightbox.show {
  display: flex;
}

.lightbox img {
  max-width: 95vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.toast.error {
  background: var(--danger);
}

.loading {
  padding: 48px;
  text-align: center;
  color: var(--muted);
}

.empty {
  padding: 48px;
  text-align: center;
  color: var(--muted);
}

.reload-row {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.manual-copy {
  width: 100%;
  min-height: 160px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

@media (max-width: 1100px) {
  main {
    padding: 20px;
  }
  .upload-layout,
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .header {
    padding: 0 20px;
  }
}
