:root {
  --blue: #0033cc;
  --tab-blue: #b9cbed;
  --tab-active: #d8d8d8;
  --line: #b6b6b6;
  --panel: #f2f2f2;
  --heading: #d7d7d7;
}

* { box-sizing: border-box; }
html { overflow-x: hidden; }
body {
  margin: 0;
  background: #fff;
  color: #222;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
a { color: var(--blue); text-decoration: underline; }
a:hover, a:focus { color: #c00; }
img, video { max-width: 100%; }
button, input, textarea, select {
  font: inherit;
  max-width: 100%;
}
button, .classic-button {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid #888;
  border-radius: 2px;
  background: linear-gradient(#fff, #d8d8d8);
  color: #111;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .classic-button:hover { background: #eee; color: #111; }
button.primary, .classic-button.primary {
  border-color: #274c87;
  background: linear-gradient(#e8f0ff, #adc4e9);
  font-weight: bold;
}
button:disabled { cursor: wait; opacity: .65; }
.site-shell { width: min(960px, calc(100% - 24px)); margin: 0 auto; }
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 20;
  padding: 8px; background: #fff; border: 1px solid #000;
}
.skip-link:focus { left: 8px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.site-header { padding-top: 7px; }
.masthead {
  min-height: 73px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { flex: 0 1 320px; display: block; text-decoration: none; background: transparent; }
.brand img { display: block; width: auto; height: auto; max-width: 100%; max-height: 66px; object-fit: contain; object-position: left center; background: transparent; }
.header-tools { flex: 1 1 520px; min-width: 0; text-align: right; }
.utility-links { margin-bottom: 17px; white-space: nowrap; }
.utility-links span { margin: 0 7px; color: #777; }
.search-form { display: flex; justify-content: flex-end; gap: 8px; }
.search-form input { width: min(100%, 400px); height: 27px; border: 1px solid #777; padding: 3px 5px; }
.search-form button { min-height: 27px; }
.main-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  align-items: end;
}
.main-tabs a {
  display: block;
  padding: 8px 5px 7px;
  border-radius: 8px 8px 0 0;
  background: var(--tab-blue);
  border-bottom: 1px solid #aaa;
  text-align: center;
  font-size: 15px;
  font-weight: bold;
}
.main-tabs a.active { background: var(--tab-active); color: #222; text-decoration: none; }
.subnav {
  min-height: 34px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 7px;
  background: #ddd;
  border-bottom: 1px solid #bbb;
  font-size: 14px;
  font-weight: bold;
}
main { padding: 14px 0 22px; min-height: 430px; }
.panel { border: 1px solid var(--line); background: var(--panel); margin-bottom: 15px; }
.panel-heading {
  min-height: 31px; padding: 5px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--heading); border-bottom: 1px solid var(--line);
}
.panel-heading h1, .panel-heading h2 { margin: 0; font-size: 16px; }
.home-columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(230px, 1fr); gap: 13px; align-items: start; }
.video-list { padding: 8px; }
.video-list .video-card { padding: 8px 0; border-bottom: 1px solid #ccc; }
.video-list .video-card:last-child { border-bottom: 0; }
.video-card { display: flex; gap: 10px; min-width: 0; }
.thumb-link {
  position: relative; flex: 0 0 154px; height: 116px;
  background: #111; border: 1px solid #888; overflow: hidden;
}
.video-thumb { display: block; width: 100%; height: 100%; object-fit: cover; }
.duration {
  position: absolute; right: 3px; bottom: 3px; padding: 1px 3px;
  color: #fff; background: rgba(0,0,0,.8); font-size: 10px;
}
.video-card-body { min-width: 0; }
.video-card h3 { margin: 0 0 5px; font-size: 14px; line-height: 1.2; }
.video-card p { margin: 2px 0; }
.meta { color: #555; font-size: 11px; }
.excerpt { margin-top: 6px !important; color: #333; }
.featured-panel { min-width: 0; }
.featured-item { display: flex; gap: 7px; padding: 8px; border-bottom: 1px solid #ccc; }
.featured-item:last-child { border: 0; }
.featured-item > a { flex: 0 0 94px; height: 70px; border: 1px solid #888; background: #111; }
.featured-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.featured-item p { margin: 5px 0 0; font-size: 11px; color: #555; }
.video-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 13px; padding: 12px; }
.video-grid .video-card { display: block; }
.video-grid .thumb-link { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; margin-bottom: 6px; }
.pagination {
  display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap;
  gap: 6px; min-height: 35px; padding: 7px 10px; background: #d5d5d5; border-top: 1px solid #bbb;
}
.pagination a, .pagination strong { border: 1px solid #aaa; background: #eee; padding: 2px 6px; }
.large-search { display: flex; align-items: center; gap: 8px; padding: 15px 10px; flex-wrap: wrap; }
.large-search input { flex: 1 1 300px; border: 1px solid #777; padding: 5px; }
.result-title { margin: 0; padding: 8px; border-top: 1px solid #bbb; border-bottom: 1px solid #bbb; font-size: 14px; background: #e2e2e2; }
.empty-state { padding: 34px 16px; text-align: center; }
.about-content { padding: 14px; background: #fff; }
.about-text { white-space: pre-wrap; line-height: 1.5; }
.social-links { margin-top: 18px; padding-top: 10px; border-top: 1px solid #ccc; }
.social-links h2 { margin: 0 0 7px; font-size: 15px; }
.social-links ul { margin: 0; padding-left: 22px; }
.social-links li { margin: 4px 0; }
.watch-title { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.watch-title h1 { margin: 0; font-size: 18px; }
.watch-layout { display: grid; grid-template-columns: minmax(0, 640px) minmax(220px, 1fr); gap: 12px; align-items: start; }
.watch-main { min-width: 0; }
.player-frame { width: 100%; aspect-ratio: 16 / 9; background: #111; border: 1px solid #666; }
.player-frame video { display: block; width: 100%; height: 100%; object-fit: contain; }
.watch-actions {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 7px; border: 1px solid #aaa; border-top: 0; background: #eee;
}
.stars { color: #e66320; font-size: 19px; letter-spacing: -2px; }
.video-info { border: 1px solid #aaa; margin-top: 10px; background: #f4f4f4; }
.info-heading { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; background: #d4d4d4; }
.video-info dl { display: grid; grid-template-columns: 90px minmax(0, 1fr); margin: 0; padding: 8px; }
.video-info dt { font-weight: bold; }
.video-info dd { margin: 0 0 5px; }
.video-info .description { white-space: pre-wrap; }
.episode-nav { display: flex; justify-content: space-between; gap: 15px; margin-top: 9px; }
.episode-nav span { flex: 1; }
.episode-nav span:last-child { text-align: right; }
.related-panel { min-width: 0; }
.related-item { display: flex; gap: 7px; padding: 7px; border-bottom: 1px solid #ccc; }
.related-item > a { flex: 0 0 96px; height: 72px; border: 1px solid #888; background: #111; }
.related-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.related-item h3 { margin: 0 0 3px; font-size: 12px; }
.related-item p { margin: 2px 0; font-size: 10px; color: #555; }
.small-note { padding: 8px; color: #666; font-size: 11px; }
.preview-banner, .processing-note, .flash {
  margin-bottom: 12px; padding: 8px 10px; border: 1px solid #c49b36; background: #fff5c8;
}
.flash { margin-top: 10px; border-color: #6a9d55; background: #e6f5dd; }
.site-footer { border-top: 1px solid #aaa; padding: 14px 5px 24px; text-align: center; font-size: 11px; color: #555; }
.site-footer p { margin: 6px 0; }
.login-box { max-width: 430px; margin: 35px auto; }
.stacked-form, #episode-form { padding: 14px; }
.stacked-form { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: center; }
.stacked-form input { width: 100%; border: 1px solid #777; padding: 5px; }
.stacked-form button { grid-column: 2; justify-self: start; }
.form-error { border: 1px solid #b44; background: #fee; color: #700; padding: 8px; margin: 10px; }
.hidden { display: none !important; }
.admin-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.admin-title h1 { margin: 0; font-size: 19px; }
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 13px; }
.admin-stats div { border: 1px solid #aaa; background: #eee; padding: 9px; text-align: center; }
.admin-stats strong { display: block; font-size: 22px; color: #234a87; }
.admin-stats span { font-size: 11px; }
.admin-shortcuts { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 13px; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; background: #fff; }
.admin-table th, .admin-table td { border: 1px solid #bbb; padding: 6px; text-align: left; vertical-align: top; }
.admin-table th { background: #e1e1e1; }
.actions { min-width: 205px; }
.actions > * { display: inline-block; margin-right: 6px; }
.link-button { border: 0; background: transparent; padding: 0; color: var(--blue); text-decoration: underline; }
.link-button.danger { color: #900; }
.status { display: inline-block; padding: 1px 4px; border: 1px solid #aaa; background: #eee; font-size: 10px; text-transform: uppercase; }
.status-published, .status-ready { background: #dff2d8; border-color: #7b9; }
.status-failed { background: #fdd; border-color: #b77; }
.admin-form-panel { background: #fafafa; }
.form-row { margin-bottom: 13px; }
.form-row label, fieldset legend { display: block; margin-bottom: 4px; font-weight: bold; }
.form-row input:not([type=file]), .form-row textarea, .form-row select {
  width: 100%; padding: 6px; border: 1px solid #888; background: #fff;
}
.form-row textarea { resize: vertical; }
.form-row small { display: block; margin-top: 3px; color: #666; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset { margin: 0 0 13px; padding: 10px; border: 1px solid #aaa; }
fieldset, input[type="file"] { min-width: 0; }
input[type="file"] {
  display: block; width: 100%; overflow: hidden; color: transparent;
}
input[type="file"]::file-selector-button,
input[type="file"]::-webkit-file-upload-button { color: #111; }
.file-name { display: block; margin-top: 3px; color: #444; overflow-wrap: anywhere; }
.upload-progress { margin: 10px 0 3px; }
.progress-track { height: 18px; border: 1px solid #777; background: #fff; overflow: hidden; }
.progress-bar { width: 0; height: 100%; background: #6f92cb; transition: width .15s linear; }
.upload-progress span { display: block; margin-top: 3px; font-size: 11px; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-top: 1px solid #ccc; padding-top: 12px; }
.status-toggle-form { margin: 0 14px 14px; padding-top: 12px; border-top: 1px solid #ccc; }
.about-admin-form { padding: 14px; }
.social-link-list { display: grid; gap: 8px; margin-bottom: 9px; }
.social-link-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(220px, 2fr) auto; gap: 8px; align-items: end; }
.social-link-row label span { display: block; margin-bottom: 3px; font-weight: bold; }
.social-link-row input { width: 100%; padding: 6px; border: 1px solid #888; background: #fff; }
.error-page { text-align: center; padding: 30px 15px; }
.error-code { margin: 0; font-size: 52px; font-weight: bold; color: #999; }

@media (max-width: 800px) {
  .site-shell { width: min(100% - 16px, 960px); }
  .home-columns, .watch-layout { grid-template-columns: 1fr; }
  .related-panel { margin-top: 0; }
  .related-item > a { flex-basis: 128px; height: 96px; }
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  body { font-size: 14px; }
  .site-shell { width: 100%; padding: 0 7px; }
  .masthead { display: block; min-height: 0; }
  .brand { width: min(270px, 78vw); margin: 5px auto 2px; }
  .brand img { margin: auto; max-height: 55px; }
  .header-tools { text-align: center; }
  .utility-links { margin: 3px 0 7px; }
  .search-form { justify-content: center; }
  .search-form input { flex: 1; min-width: 0; }
  .main-tabs { grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 10px; }
  .main-tabs a { border-radius: 5px 5px 0 0; padding: 7px 3px; font-size: 13px; }
  .main-tabs a:nth-child(n+4) { border-radius: 0; }
  .subnav { font-size: 12px; }
  .video-list .video-card { align-items: flex-start; }
  .thumb-link { flex-basis: 126px; height: 95px; }
  .video-card h3 { font-size: 13px; }
  .excerpt { display: none; }
  .watch-title { display: block; }
  .watch-title a { display: inline-block; margin-top: 4px; }
  .watch-actions, .info-heading { align-items: flex-start; flex-direction: column; }
  .video-info dl { grid-template-columns: 94px minmax(0, 1fr); }
  .admin-title { align-items: flex-start; }
  .admin-stats { gap: 5px; }
  .admin-stats div { padding: 6px 2px; }
  .admin-stats strong { font-size: 18px; }
  .stacked-form { grid-template-columns: 1fr; }
  .stacked-form button { grid-column: 1; }
  .two-columns { grid-template-columns: 1fr; gap: 0; }
  .social-link-row { grid-template-columns: 1fr; padding-bottom: 10px; border-bottom: 1px solid #ccc; }
  .social-link-row .remove-social-link { justify-self: start; }
  .admin-table { min-width: 680px; }
}

@media (max-width: 390px) {
  .video-grid { grid-template-columns: 1fr; }
  .video-list { padding: 5px; }
  .video-list .video-card { gap: 7px; }
  .thumb-link { flex-basis: 112px; height: 84px; }
  .meta { font-size: 10px; }
  .related-item > a { flex-basis: 112px; height: 84px; }
  .episode-nav { display: grid; grid-template-columns: 1fr; }
  .episode-nav span:last-child { text-align: left; }
  .admin-title { display: block; }
  .admin-title > :last-child { margin-top: 6px; }
}

@media (pointer: coarse) {
  button, .classic-button, .main-tabs a { min-height: 38px; }
  .utility-links a, .subnav a { display: inline-block; padding: 5px 2px; }
}
