:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d7dee6;
  --ink: #1d2a36;
  --muted: #607284;
  --brand: #005f73;
  --brand-weak: #e5f4f6;
  --ok: #1c7c54;
  --bad: #ad1f3d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 0% 0%, #eef4f8 0%, var(--bg) 35%);
}

.layout {
  max-width: 1800px;
  margin: 0 auto;
  padding: 10px 12px 16px;
}

.toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.toolbar-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.toolbar-title h1 {
  font-size: 16px;
  margin: 0;
}

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

.toolbar-controls {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.check-label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  height: 30px;
  margin-top: 18px;
  color: var(--ink);
}

.check-label input[type="checkbox"] {
  min-width: 16px;
  width: 16px;
  height: 16px;
  margin: 0;
}

select,
input {
  height: 30px;
  min-width: 130px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  color: var(--ink);
  background: #fff;
}

input {
  min-width: 220px;
}

.btn {
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

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

.job-bar {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.content {
  margin-top: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.tab-bar-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--line);
}

.tab-bar {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  min-width: 0;
}

.tab {
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: #f6f8fa;
  color: var(--muted);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.tab.active {
  background: var(--brand-weak);
  color: var(--brand);
  border-color: #b6d7df;
}

.table-wrap {
  overflow-y: auto;
  max-height: calc(100vh - 220px);
  padding: 8px;
}

.card-masonry {
  column-count: 2;
  column-gap: 10px;
}

.file-card {
  break-inside: avoid;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px;
}

.file-card.file-excluded {
  opacity: 0.65;
}

.file-card-head {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(200px, auto) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.file-card-meta {
  min-width: 0;
}

.file-card-player {
  min-width: 200px;
}

.file-card-player audio {
  width: 100%;
  max-width: 260px;
}

.file-card-actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-card-actions .btn-row {
  width: auto;
  height: 22px;
  padding: 0 8px;
}

.file-results-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-multi {
  position: relative;
  min-width: 180px;
  max-width: 360px;
  margin-bottom: 8px;
}

.filter-multi-trigger {
  width: 100%;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  text-align: left;
  padding: 0 26px 0 8px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-multi-trigger::after {
  content: "▾";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: #6e8196;
  pointer-events: none;
}

.filter-multi-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 300px;
  max-width: min(70vw, 360px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(18, 35, 53, 0.14);
  z-index: 30;
  padding: 6px 0;
}

.filter-multi-options {
  max-height: 260px;
  overflow-y: auto;
}

.filter-multi-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink);
  padding: 6px 10px;
  cursor: pointer;
}

.filter-multi-item:hover {
  background: #f4f8fb;
}

.filter-multi-item input[type="checkbox"] {
  margin: 0;
  width: 14px;
  height: 14px;
  min-width: 14px;
}

.file-cell {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.file-exclude-btn {
  height: 22px;
  border: 1px solid #d9b06d;
  border-radius: 6px;
  background: #fff5e7;
  color: #8a5300;
  font-size: 11px;
  line-height: 1;
  padding: 0 8px;
  cursor: pointer;
  white-space: nowrap;
}

.file-exclude-btn.active {
  border-color: #95a2b2;
  background: #edf1f6;
  color: #5a697b;
}

.file-exclude-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.filename {
  word-break: break-all;
}

.file-context-btn {
  height: 22px;
  border: 1px solid #b2c6dc;
  border-radius: 6px;
  background: #eef4fb;
  color: #2d4e6c;
  font-size: 11px;
  line-height: 1;
  padding: 0 8px;
  cursor: pointer;
  white-space: nowrap;
}

.file-context-btn.active {
  border-color: #5f8fbb;
  background: #dbeaf8;
  color: #1d4262;
}

.file-context-panel {
  display: none;
  margin-top: 6px;
}

.file-context-panel.open {
  display: block;
}

.file-context-input {
  min-width: 280px;
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  resize: vertical;
}

.file-context-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.file-excluded {
  opacity: 0.65;
}

.file-excluded audio {
  filter: grayscale(1);
}

.excluded-results {
  color: #6f7e8f;
  font-style: italic;
}

audio {
  width: 100%;
  max-width: 220px;
  height: 28px;
}

.btn-row {
  width: 100%;
  height: 28px;
  font-size: 12px;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 5px;
  background: #fff;
}

.result-row.success {
  border-color: #bfdccc;
  background: #f3fbf6;
}

.result-row.failed {
  border-color: #e4c0cb;
  background: #fff4f6;
}

.result-row.badcase {
  border-color: #e3b24d;
  background: #fff9ee;
}

.result-provider {
  display: inline-flex;
  align-items: center;
  max-width: 320px;
  padding: 0 5px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid #bfd2e4;
  background: #edf4fb;
  color: #294a66;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help;
}

.result-text {
  color: #425970;
  font-size: 12px;
  word-break: break-word;
  line-height: 1.2;
}

.result-delete {
  height: 18px;
  border: 1px solid #d6a8b2;
  border-radius: 5px;
  background: #fff0f3;
  color: #9f2d47;
  font-size: 10px;
  line-height: 1;
  padding: 0 5px;
  cursor: pointer;
}

.result-delete:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.result-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.result-badcase {
  height: 18px;
  border: 1px solid #e3c17f;
  border-radius: 5px;
  background: #fff8eb;
  color: #9b6700;
  font-size: 10px;
  line-height: 1;
  padding: 0 5px;
  cursor: pointer;
}

.result-badcase.active {
  border-color: #c68706;
  background: #f8c744;
  color: #4e3400;
}

.result-badcase:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.empty-results {
  color: var(--muted);
}

.badcase-panel {
  border-top: 1px solid var(--line);
  padding: 10px 8px;
}

.badcase-panel h2 {
  margin: 0 0 6px;
  font-size: 13px;
  color: #4c6074;
}

.badcase-summary {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
}

.badcase-item {
  border: 1px solid #f0cc8b;
  border-radius: 999px;
  padding: 3px 8px;
  background: #fff9ef;
  color: #6e4b00;
}

@media (max-width: 960px) {
  .layout {
    padding: 6px;
  }

  .tab-bar-shell {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .card-masonry {
    column-count: 1;
  }

  .file-card-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .file-card-player {
    min-width: 0;
  }

  .result-row {
    grid-template-columns: 1fr;
    row-gap: 3px;
    align-items: start;
  }

  .result-actions {
    justify-content: flex-start;
  }

  .result-provider {
    max-width: 100%;
  }

  .filter-multi {
    width: 100%;
    max-width: none;
    margin-bottom: 0;
  }

  .filter-multi-menu {
    right: auto;
    left: 0;
    width: 100%;
    max-width: none;
  }
}
