.bp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px minmax(280px, 0.95fr);
  gap: 0 8px;
  padding: 12px 0 32px;
  align-items: start;
  transition: grid-template-columns 180ms ease;
}

.bp-layout.is-sidebar-collapsed {
  grid-template-columns: 0 14px minmax(0, 1fr);
  gap: 0 4px;
}

.bp-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  transition: opacity 150ms ease, transform 150ms ease;
}

.bp-layout.is-sidebar-collapsed .bp-main {
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transform: translateX(-8px);
  visibility: hidden;
  height: 0;
  min-height: 0;
}

.bp-sidebar-divider {
  position: sticky;
  top: 72px;
  align-self: stretch;
  width: 14px;
  min-height: 200px;
  max-height: calc(100vh - 96px);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.bp-sidebar-divider-line {
  position: absolute;
  inset: 12px auto 12px 50%;
  width: 1px;
  transform: translateX(-50%);
  background: var(--border);
}

.bp-sidebar-divider-toggle {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 10px;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.bp-sidebar-divider:hover .bp-sidebar-divider-line {
  background: var(--brand);
}

.bp-sidebar-divider:hover .bp-sidebar-divider-toggle {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

.bp-layout.is-sidebar-collapsed .bp-reader {
  max-width: none;
}

.bp-card {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 2px;
  padding: 14px 16px;
}

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

.bp-card-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.bp-upload-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bp-dropzone {
  position: relative;
  display: block;
  border: 1px dashed #cbd5e1;
  background: var(--bg-subtle);
  border-radius: 2px;
  min-height: 120px;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.bp-dropzone:hover,
.bp-dropzone.is-dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.bp-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.bp-dropzone-inner {
  pointer-events: none;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  text-align: center;
}

.bp-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.bp-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.bp-field-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
  text-transform: uppercase;
}

.bp-field input,
.bp-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.55rem 0.7rem;
  background: #fff;
  color: var(--text);
}

.bp-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bp-job-list,
.bp-report-list {
  display: flex;
  flex-direction: column;
}

.bp-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 8px;
  display: grid;
  gap: 6px;
}

.bp-item:last-child {
  border-bottom: 0;
}

.bp-item-title {
  font-weight: 600;
  word-break: break-word;
}

.bp-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.8125rem;
}

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

.bp-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 2px;
  font-size: 0.75rem;
  font-family: var(--mono);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}

.bp-badge.queued {
  color: #92400e;
  background: #fffbeb;
  border-color: #fde68a;
}

.bp-badge.analyzing {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.bp-badge.done {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.bp-badge.failed {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

.bp-search {
  margin-bottom: 8px;
}

.bp-reader {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  min-height: 280px;
  min-width: 0;
}

.bp-layout.is-sidebar-collapsed .bp-reader {
  max-height: calc(100vh - 88px);
}

.bp-reader-empty {
  color: var(--muted);
  padding: 24px 8px;
}

.bp-reader-content {
  font-size: 0.95rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.bp-reader-content h1,
.bp-reader-content h2,
.bp-reader-content h3 {
  line-height: 1.3;
}

.bp-reader-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 12px 0;
}

.bp-reader-content th,
.bp-reader-content td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  vertical-align: top;
}

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

.bp-empty {
  color: var(--muted);
  padding: 12px 4px;
  font-size: 0.875rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 2px;
  z-index: 50;
  max-width: min(92vw, 420px);
  font-size: 0.875rem;
}

@media (max-width: 960px) {
  .bp-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .bp-layout.is-sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .bp-sidebar-divider {
    display: none;
  }

  .bp-layout.is-sidebar-collapsed .bp-main {
    display: none;
    opacity: 1;
    visibility: visible;
    height: auto;
    transform: none;
  }

  .bp-layout.is-sidebar-collapsed .bp-reader {
    position: static;
    max-height: none;
  }

  .bp-reader {
    position: static;
    max-height: none;
  }

  .bp-form-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .topbar-side {
    flex-wrap: wrap;
  }
}
