* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f6f7f9;
  color: #1b1b1f;
}

header {
  background: #101828;
  color: #fff;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

header h1 {
  margin: 0;
  font-size: 1.8rem;
}

#summary {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.stat {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  min-width: 140px;
}

.stat .label {
  display: block;
  font-size: 0.8rem;
  opacity: 0.8;
}

.stat .value {
  display: block;
  font-size: 1.4rem;
  font-weight: 600;
}

main {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  padding: 1rem;
  min-height: calc(100vh - 180px);
}

aside, #content > section {
  background: #fff;
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.07);
}

aside {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

aside section label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

input[type='text'],
input[type='number'],
select,
textarea {
  padding: 0.6rem 0.75rem;
  border-radius: 0.6rem;
  border: 1px solid #d0d5dd;
  font: inherit;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

button {
  padding: 0.6rem 1rem;
  border-radius: 0.6rem;
  border: none;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

button:hover {
  background: #1d4ed8;
}

button:active {
  transform: translateY(1px);
}

h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.detail-actions a {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 1rem;
  border-radius: 0.6rem;
  border: 1px solid #d0d5dd;
  background: #f8fafc;
  color: #1d4ed8;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}

.detail-actions a:hover {
  background: #e0e7ff;
  border-color: #1d4ed8;
}

.table-wrapper {
  border: 1px solid #e4e7ec;
  border-radius: 0.8rem;
  overflow: hidden;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}

th {
  background: #f8fafc;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #475467;
}

tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

tbody tr:hover {
  background: #f8fafc;
}

tbody tr.selected {
  background: rgba(37, 99, 235, 0.08);
}

.scrollable {
  max-height: 400px;
  overflow: auto;
}

#keyword-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.keyword-detail {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.keyword-item {
  padding: 0.5rem 0.7rem;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
  background: #f9fafb;
}

.keyword-header {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.keyword-meta {
  font-size: 0.6rem;
  color: #64748b;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.keyword-meta-status {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: #475467;
}

.keyword-meta-count {
  color: #0f172a;
}

.keyword-meta .keyword-text {
  flex: 1;
  color: #0f172a;
}

.keyword-meta-count {
  color: #475467;
}

#detail-panel {
  margin-top: 1rem;
}

.hidden {
  display: none;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.detail-grid ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detail-grid li span {
  display: block;
}

.detail-grid li span.label {
  font-size: 0.8rem;
  color: #6b7280;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.video-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.8rem;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.05);
}

.video-thumb-wrapper {
  position: relative;
}

.video-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.video-info {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.video-info:hover {
  background: rgba(37, 99, 235, 0.9);
}

.video-meta {
  padding: 0.75rem;
}

.video-meta h4 {
  margin: 0 0 0.3rem;
  font-size: 0.95rem;
  line-height: 1.3;
}

.video-meta p {
  margin: 0;
  font-size: 0.8rem;
  color: #64748b;
}

#detail-description {
  white-space: pre-wrap;
  line-height: 1.5;
  color: #334155;
}

#video-dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

#video-dialog {
  border: none;
  border-radius: 1rem;
  padding: 0;
  width: min(480px, 90vw);
  max-height: 90vh;
}

#video-dialog-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.2rem;
}

#video-dialog-content header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

#video-dialog-close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  color: #475467;
}

#video-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.9rem;
}

#video-dialog-body pre {
  background: #f1f5f9;
  padding: 0.75rem;
  border-radius: 0.75rem;
  max-height: 220px;
  overflow: auto;
  font-size: 0.8rem;
  margin: 0;
}

@media (max-width: 960px) {
  main {
    grid-template-columns: 1fr;
  }

  header {
    padding: 1.25rem 1.5rem;
  }

  #summary {
    gap: 1rem;
  }
}
.keyword-tag {
  display: inline-block;
  color: #1d4ed8;
}

.keyword-meta .keyword-text {
  flex: 1;
  color: #0f172a;
}
.channel-title {
  max-width: 300px;
}

#detail-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#detail-form label {
  min-width: 100px;
  display: inline-block;
}
#video-dialog-body .video-detail-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #475467;
}

#video-dialog-body p {
  white-space: pre-wrap;
  margin: 0.4rem 0;
}
