:root {
  --bg: #0b0b0f;
  --text: #e6e6eb;
  --muted: #9aa0a6;
  --acc1: #8ab4f8;
  --acc2: #f28b82;
  --acc3: #81c995;
  --panel: #111216;
  --border: #272a33;
  --pad: 16px;
  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #60a5fa;
  --nav-height: 0px;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --text: #111217;
  --muted: #6b7280;
  --acc1: #1e40af;
  --acc2: #c2410c;
  --acc3: #047857;
  --panel: #f8fafc;
  --border: #e5e7eb;
  --success: #059669;
  --warning: #d97706;
  --error: #dc2626;
  --info: #2563eb;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.app-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "brand . theme"
    "links links links";
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.app-nav__brand {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.03em;
  grid-area: brand;
}

.app-nav__links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
  grid-area: links;
}

.app-nav__btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.app-nav__btn:hover {
  border-color: var(--acc1);
}

.app-nav__btn.is-active {
  background: rgba(138, 180, 248, 0.14);
  border-color: var(--acc1);
  color: var(--text);
}

.app-nav__theme {
  align-self: center;
  grid-area: theme;
  flex-shrink: 0;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

@media (max-width: 720px) {
  .app-nav {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand theme"
      "links links";
    gap: 8px 10px;
  }
  .app-nav__theme {
    margin-top: 0;
  }
}

.topbar {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: min-content;
  row-gap: 10px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: var(--nav-height, 0px);
  z-index: 10;
}

.topbar .left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar .right {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  width: 100%;
}

@media (min-width: 1280px) {
  /* Force single-column layout at all widths so URL stays full-width and controls drop below */
  .topbar {
    grid-template-columns: 1fr;
    row-gap: 10px;
  }

  .topbar .left {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .topbar .right {
    justify-content: flex-start;
    width: 100%;
  }
}

.topbar input[type="url"],
.topbar input[type="text"],
.topbar select,
.topbar button {
  height: 36px;
  line-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.topbar input[type="url"] {
  width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}

.topbar select#mode {
  width: 120px;
  min-width: 110px;
}

.topbar button:hover { border-color: var(--acc1); }
#validateManifest {
  display: none;
}

main {
  padding: 12px;
  flex: 1 0 auto;
}

.pane {
  display: grid;
  grid-template-columns: 320px 1fr;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
}

.meta-panel {
  padding: var(--pad);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  min-width: 280px;
}

#meta .item {
  display: flex;
  flex-direction: column;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-all;
}

#meta .item strong {
  color: var(--text);
  margin-bottom: 2px;
  font-weight: 600;
}

#meta .item span {
  color: var(--muted);
  margin-left: 0.5em; 
}

.code-panel {
  padding: var(--pad);
  overflow: auto;
}

.dash-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}

.dash-empty-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 0;
  padding: 0;
}

.dash-empty-rep {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
}

.dash-empty-summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.dash-empty-summary::-webkit-details-marker {
  display: none;
}

.dash-empty-summary::before {
  content: '▸';
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--acc3);
}

.dash-empty-rep[open] .dash-empty-summary::before {
  transform: rotate(90deg);
}

.dash-empty-link {
  color: var(--acc3);
  text-decoration: underline;
  font-weight: 600;
}

.dash-empty-link:hover {
  color: var(--acc1);
}

.dash-empty-title {
  color: var(--text);
  font-weight: 600;
}

.dash-empty-body {
  padding: 6px 10px 10px;
  color: var(--muted);
  font-size: 12px;
}

pre {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

code {
  font-size: 10px;
  white-space: pre;
  display: block;
  overflow-x: auto;
}

.validation-results {
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 14px;
  white-space: normal;
  padding: 0;
  background: transparent;
}

.validation-results .validation-container {
  display: grid;
  gap: 16px;
}

.validation-results .validation-summary {
  font-size: 14px;
  color: var(--muted);
}

.validation-results .validation-sections {
  display: grid;
  gap: 12px;
}

.validation-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
}

.validation-section h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.validation-section.kind-error {
  border-color: var(--error);
}
.validation-section.kind-warning {
  border-color: var(--warning);
}
.validation-section.kind-info {
  border-color: var(--info);
}
.validation-section.kind-success {
  border-color: var(--success);
}

.validation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.validation-item .message {
  font-size: 14px;
  color: var(--text);
}

.validation-item .meta {
  font-size: 12px;
  color: var(--muted);
}

.validation-banner {
  grid-column: 1 / -1;
  background: rgba(96, 165, 250, 0.12);
  border: 1px dashed var(--info);
  color: var(--info);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 8px;
}

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

.validation-children {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.validation-child {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
}

.validation-child > summary {
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
}

.validation-child > summary::-webkit-details-marker {
  display: none;
}

.validation-child > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  color: var(--acc3);
  transition: transform 0.15s ease;
}

.validation-child[open] > summary::before {
  transform: rotate(90deg);
}

.validation-child-body {
  padding: 6px 10px 10px;
  font-size: 12px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.validation-child-list {
  margin: 0;
  padding-left: 16px;
}

.validation-child-list--error {
  color: var(--error);
}

.validation-child-list--warning {
  color: var(--warning);
}

.token.tag {
  color: var(--acc1);
}
.token.attr-name,
.token.directive {
  color: var(--acc2);
}
.token.attr-value,
.token.uri {
  color: var(--acc3);
}
.token.comment {
  color: var(--muted);
}
.token.key {
  color: var(--acc2);
}
.token.value {
  color: var(--acc3);
}
.token.string {
  color: var(--acc3);
}
.token.number {
  color: var(--acc1);
}
.token.boolean,
.token.null {
  color: var(--acc2);
}
.token.time {
  color: var(--acc1);
  font-weight: 600;
}

footer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  color: var(--muted);
  background: var(--panel);
  text-align: center;
}

.footer-content {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.footer-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.supporters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
}

.supporters__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  transition: transform 0.2s ease;
  text-decoration: none;
  line-height: 1;
}

.supporters__logo:hover {
  transform: translateY(-1px);
}

.supporters__logo img {
  height: 18px;
  width: auto;
  display: block;
}

.pane {
  display: flex; 
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
}

.meta-panel {
  padding: var(--pad);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 12px;
}

.code-panel {
  padding: var(--pad);
  overflow: auto;
}

code.mp4-view {
  white-space: normal;
  font-size: 12px;
}

.mp4-viewer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mp4-viewer-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.mp4-viewer-header a {
  color: var(--acc1);
  text-decoration: underline;
  word-break: break-all;
}

.mp4-header-meta {
  color: var(--muted);
  font-size: 12px;
}

.mp4-warning {
  font-size: 12px;
  color: #f28b82;
  background: rgba(242, 139, 130, 0.08);
  border: 1px solid rgba(242, 139, 130, 0.4);
  border-radius: 8px;
  padding: 6px 8px;
}

.mp4-viewer-main {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 260px) 1fr;
}

@media (max-width: 980px) {
  .mp4-viewer-main {
    grid-template-columns: 1fr;
  }
}

.mp4-tree {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  min-height: 200px;
  max-height: 420px;
  overflow: auto;
}

.mp4-tree-group {
  display: block;
}

.mp4-tree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
}

.mp4-tree-row:hover {
  background: rgba(138, 180, 248, 0.15);
}

.mp4-tree-row.selected {
  background: rgba(138, 180, 248, 0.25);
}

.mp4-toggle {
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}

.mp4-toggle:disabled {
  cursor: default;
  opacity: 0.4;
}

.mp4-toggle--empty {
  visibility: hidden;
}

.mp4-node-type {
  font-weight: 600;
}

.mp4-node-size {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.mp4-node-offset {
  margin-left: 12px;
  color: var(--muted);
  font-size: 11px;
}

.mp4-children {
  border-left: 1px dashed var(--border);
}

.mp4-details {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  min-height: 200px;
  overflow: auto;
}

.mp4-details h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.mp4-details table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.mp4-details th,
.mp4-details td {
  border: 1px solid var(--border);
  padding: 4px 6px;
  text-align: left;
}

.mp4-details tbody tr:nth-child(odd) {
  background: rgba(138, 180, 248, 0.08);
}

.mp4-placeholder {
  color: var(--muted);
  font-size: 12px;
}

.dash-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.dash-toolbar select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  padding: 2px 8px;
}

.dash-inspector {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  background: var(--panel);
}

.dash-inspector-summary {
  cursor: pointer;
  padding: 8px 12px;
  font-weight: 600;
  list-style: none;
}

.dash-inspector summary::-webkit-details-marker {
  display: none;
}

.dash-inspector-summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}

.dash-inspector[open] .dash-inspector-summary::before {
  transform: rotate(90deg);
}

.dash-inspector-body {
  display: none;
  padding: 10px 12px 12px;
}

.dash-inspector[open] .dash-inspector-body {
  display: block;
}

.dash-rep-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.dash-rep {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.dash-rep summary {
  cursor: pointer;
  font-weight: 600;
  padding: 6px 10px;
  list-style: none;
}

.dash-rep summary::-webkit-details-marker {
  display: none;
}

.dash-rep summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}

.dash-rep[open] summary::before {
  transform: rotate(90deg);
}

.dash-rep--highlight {
  box-shadow: 0 0 0 2px var(--acc3);
}

.dash-init {
  padding: 0 10px 6px;
  font-size: 12px;
}

.dash-init a {
  color: var(--acc3);
  text-decoration: underline;
}

.dash-init a:hover {
  color: var(--acc1);
}

.dash-segment-list {
  padding: 0 10px 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px;
}

.dash-segment-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.dash-segment-item a {
  color: var(--acc3);
  text-decoration: underline;
}

.dash-segment-item a:hover {
  color: var(--acc1);
}

.dash-segment-meta {
  color: var(--muted);
  font-size: 10px;
}

.dash-template-link {
  cursor: pointer;
  text-decoration: underline;
  color: var(--acc3);
}

.dash-template-link:hover {
  color: var(--acc1);
}

.token.uri,
a[data-hls-uri] {
  color: var(--acc3);
  text-decoration: underline;
  cursor: pointer;
}
a[data-hls-uri]:hover {
  color: var(--acc1);
}

.headers-panel {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.headers-panel[hidden] {
  display: none;
}

.headers-panel__dialog {
  width: min(720px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--text);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  line-height: 1.45;
}

.headers-panel__header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.headers-panel__header h2 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.headers-panel__close {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.headers-panel__close:hover {
  border-color: var(--acc1);
  color: var(--acc1);
}

.headers-panel__description {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.headers-panel__add {
  align-self: flex-start;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.headers-panel__add:hover {
  border-color: var(--acc1);
}

.headers-panel__table-wrapper {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  margin-bottom: 8px;
}

.headers-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
}

.headers-table thead {
  background: rgba(138, 180, 248, 0.12);
}

.headers-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.headers-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.headers-table tbody tr:last-child td {
  border-bottom: none;
}

.headers-table__enabled-col {
  width: 48px;
  text-align: center;
}
.headers-table__actions-col {
  width: 64px;
  text-align: center;
}

.headers-table__actions {
  text-align: center;
  padding: 4px;
}

.headers-enabled-cell {
  text-align: center;
  vertical-align: middle;
}
.headers-enabled {
  width: 16px;
  height: 16px;
}

.headers-table__input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.headers-table__input:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.headers-table__input:focus {
  outline: 2px solid var(--acc1);
  outline-offset: 0;
}

.headers-remove {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* UA reset icon: icon-only button, no box/border (same sizing/feel as the remove icon) */
.headers-reset {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.headers-remove:hover {
  color: var(--error);
}

/* Subtle hover color for reset icon */
.headers-reset:hover {
  color: var(--acc1);
}

.headers-remove:disabled {
  cursor: default;
  color: var(--border);
}

.headers-panel__error {
  min-height: 18px;
  font-size: 12px;
  color: var(--error);
}

.headers-panel__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.headers-panel__actions button {
  height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.headers-panel__actions button:hover {
  border-color: var(--acc1);
}

.headers-panel__save {
  background: var(--acc1);
  color: #0d1117;
  border-color: var(--acc1);
}

.headers-panel__save:hover {
  border-color: var(--acc1);
}

.headers-panel__spacer {
  flex: 1;
}

html[data-theme="light"] .headers-panel {
  background: rgba(17, 24, 39, 0.4);
}

/* Theme-specific color for GitHub logo in footer */
footer a[aria-label="GitHub repository"] {
  color: #fff !important; /* default (dark mode) */
}
html[data-theme="light"] footer a[aria-label="GitHub repository"] {
  color: #000 !important; /* light mode: black logo */
}

html[data-theme="dark"] .supporters__logo img {
  filter: brightness(0) invert(1);
}

html[data-theme="light"] .supporters__logo img {
  filter: brightness(0);
}
