* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  background: #0f172a;
  color: #e2e8f0;
}

.header {
  padding: 16px;
  background: #111827;
  border-bottom: 1px solid #1f2937;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header.compact .header-row {
  justify-content: flex-start;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1040px;
  margin: 0 auto;
}

.ad-slot-wrapper {
  display: flex;
  justify-content: center;
  padding: 8px 12px 0;
  margin: 0 auto;
  overflow: hidden;
}

.ad-slot-iframe {
  width: 100%;
  max-width: 728px;
  height: 100px;
  border: 0;
  display: block;
  margin: 0 auto;
  background: transparent;
  vertical-align: top;
}


.title {
  font-size: 24px;
  font-weight: 700;
}

.subtitle {
  color: #9ca3af;
  margin-top: 4px;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px;
}

.panel {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.panel-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.input,
.select,
.textarea {
  background: #0b1220;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 160px;
  flex: 1;
}

.textarea {
  min-height: 140px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
}

.btn.primary {
  background: #38bdf8;
  color: #0f172a;
}

.btn.secondary {
  background: #1f2937;
  color: #e2e8f0;
  border: 1px solid #374151;
}

.file-input-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #0b1220;
  border: 1px solid #1f2937;
  cursor: pointer;
  font-size: 13px;
}

.filter-pill.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.status {
  margin-bottom: 12px;
  color: #a5b4fc;
}

.media-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}


.media-card {
  background: #0b1220;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: none;
  overflow: hidden;
}

.platform-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #334155;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.platform-pill.platform-niconico {
  border-color: #ffffff;
  color: #ffffff;
}

.platform-pill.platform-youtube {
  border-color: #ef4444;
  color: #ef4444;
}

.platform-pill.platform-youtube-brand {
  text-transform: none;
  gap: 6px;
  text-decoration: none;
}

.platform-pill.platform-youtube-brand .youtube-logo {
  width: 16px;
  height: 16px;
  color: #ff0000;
}

.platform-pill.platform-niconico-brand {
  text-transform: none;
  gap: 6px;
  text-decoration: none;
  color: #ffffff;
  border-color: #ffffff;
}

.platform-pill.platform-niconico-brand .niconico-logo {
  width: 16px;
  height: 16px;
  color: #ffffff;
}

.media-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  position: relative;
  flex-wrap: wrap;
}

.media-title {
  font-weight: 600;
}

.media-meta {
  color: #9ca3af;
  font-size: 12px;
}

.media-embed {
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
}

.media-viewer-embed {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-viewer-pin {
  position: fixed;
  top: 56px;
  left: 50%;
  width: min(960px, 90vw);
  height: calc(100vh - 80px);
  transform: translateX(-50%);
  z-index: 120;
}

.media-viewer-embed iframe,
.media-viewer-embed video,
.media-viewer-embed img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.media-clickable {
  cursor: pointer;
}

.media-embed iframe,
.media-embed video,
.media-embed img {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
  display: block;
  object-fit: cover;
}

.media-viewer .media-viewer-embed iframe,
.media-viewer .media-viewer-embed video,
.media-viewer .media-viewer-embed img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.media-thumb-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

.media-embed-placeholder {
  cursor: pointer;
}

.media-play-overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.75);
  color: #f8fafc;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.media-title-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 8px;
  font-size: clamp(11px, 1.6vw, 14px);
  color: #f8fafc;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0) 0%, rgba(2, 6, 23, 0.75) 100%);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-embed.platform-niconico {
  aspect-ratio: 4 / 3;
}

.media-thumb {
  width: 100%;
  border-radius: 8px;
  background: #1f2937;
}

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

.media-menu-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.media-expand-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.media-menu-list {
  position: absolute;
  top: 36px;
  right: 0;
  background: #0b1220;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 6px;
  z-index: 95;
  min-width: 180px;
}

.media-menu-item {
  background: #111827;
  color: #e2e8f0;
  border: 1px solid #1f2937;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}

.media-menu-item:hover {
  background: #1f2937;
}

.loader {
  text-align: center;
  color: #94a3b8;
  padding: 16px;
  display: none;
}

.notice {
  font-size: 12px;
  color: #cbd5f5;
  margin-bottom: 8px;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: min(360px, 85vw);
  background: #0f172a;
  border-right: 1px solid #1f2937;
  padding: 16px;
  transform: translateX(-105%);
  transition: transform 0.2s ease;
  z-index: 70;
  overflow-y: auto;
}

.sidebar-header {
  align-items: center;
  justify-content: space-between;
}

.sidebar.open {
  transform: translateX(0);
}

.container {
  padding-left: 16px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
}

.modal {
  background: #0b1220;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 20px;
  width: min(520px, 90vw);
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  gap: 12px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 90;
}

.modal-section {
  display: grid;
  gap: 8px;
}

.modal-label {
  font-size: 12px;
  color: #94a3b8;
}

.pill-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: #0b1220;
  color: #e2e8f0;
  cursor: pointer;
  font-size: 12px;
}

.pill.active {
  background: #38bdf8;
  color: #0f172a;
  border-color: #38bdf8;
}

.pill.disabled {
  background: #0b1220;
  color: #64748b;
  border-color: #1f2937;
}

.list-tag-add-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.list-tag-add-wrap .input {
  min-width: 120px;
  flex: 1;
}

.list-tag-current {
  font-size: 0.85em;
  color: #94a3b8;
  font-weight: normal;
}

.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  z-index: 80;
}

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 6, 23, 0.85);
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 24px;
}

.media-viewer-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 130;
}

.media-viewer-content {
  width: min(960px, 90vw);
  height: calc(100vh - 96px);
  margin-top: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.media-viewer-content iframe {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  border: none;
}

.media-viewer-content video,
.media-viewer-content img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 12px;
  border: none;
  object-fit: contain;
}

.viewer-debug {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: min(420px, 90vw);
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 8px;
  z-index: 2;
}

.viewer-debug-text {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: #e2e8f0;
  max-height: 35vh;
  overflow: auto;
  white-space: pre-wrap;
}

@media (min-width: 1024px) {
  .media-list {
    grid-template-columns: repeat(3, minmax(260px, 1fr));
    justify-items: center;
  }
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  color: #cbd5f5;
  white-space: pre-line;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-checkbox {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: #cbd5f5;
}

.hidden {
  display: none !important;
}
