:root {
  --accent: #2196f3;
  --ink: #555555;
  --muted: #757575;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --footer-bg: #2d2d2d;
  --container: 1100px;
  --font: "Roboto", Arial, Helvetica, sans-serif;
  --font-display: "Roboto Slab", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 15px;
}

/* ——— Header (mts_sense-like) ——— */
#site-header {
  background: var(--surface);
}

#header {
  background-color: #1e88e5;
  background-size: cover;
  background-position: center;
  min-height: 110px;
  display: flex;
  align-items: center;
  padding: 18px 0;
}

.logo-wrap {
  padding: 0 4px;
}

#logo,
#footer-logo {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.2;
}

#logo a,
#footer-logo a {
  color: #fff;
  text-decoration: none;
}

#logo a:hover,
#footer-logo a:hover {
  text-decoration: none;
  opacity: 0.95;
}

#header .site-description {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
}

.navigation-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  padding: 0;
  min-height: 46px;
}

#primary-navigation {
  flex: 1;
  min-width: 0;
}

.toggle-mobile-menu {
  display: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  padding: 10px 14px;
  cursor: pointer;
}

.navigation.mobile-menu-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.navigation ul.menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.navigation ul.menu-row-2 {
  border-top: 1px solid #eee;
}

.navigation ul.menu > li > a {
  display: block;
  padding: 14px 12px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.navigation ul.menu > li.current-menu-item > a,
.navigation ul.menu > li > a:hover {
  color: var(--accent);
  text-decoration: none;
}

.widget_search {
  flex: 0 0 auto;
  padding-right: 4px;
}

.search-form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  align-items: center;
  border: 1px solid #ddd;
  border-radius: 2px;
  overflow: hidden;
  background: #fff;
}

.search-form input[type="search"] {
  border: 0;
  padding: 8px 10px;
  width: 160px;
  font: inherit;
  outline: none;
}

.search-form .sbutton {
  border: 0;
  background: var(--accent);
  color: #fff;
  width: 36px;
  height: 34px;
  cursor: pointer;
  font-size: 14px;
}

/* ——— Page / content ——— */
#page {
  padding: 24px 0 40px;
}

.article,
#content_box {
  max-width: var(--container);
  margin: 0 auto;
}

.article {
  padding: 0 15px;
}

#content_box {
  padding: 0;
}

.featured-category-title {
  margin: 0 0 16px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 18px;
  color: #333;
  border-left: 4px solid var(--accent);
  padding-left: 10px;
}

.featured-category-title a {
  color: #333;
  text-decoration: none;
}

.featured-category-title a:hover {
  color: var(--accent);
}

.posts-grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px 18px;
}

.latestPost {
  background: var(--surface);
  border-radius: 2px;
  overflow: hidden;
}

.latestPost .post-image {
  display: block;
  text-decoration: none;
}

.featured-thumbnail {
  aspect-ratio: 16 / 9;
  background: #cfd8dc;
  overflow: hidden;
  position: relative;
}

.featured-thumbnail-portrait {
  aspect-ratio: 9 / 16;
  max-height: 320px;
}

.featured-thumbnail img,
.thumb-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

/* Facebook native player (no iframe — no FB end suggestions) */
.fb-watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.25rem;
  align-items: start;
}

.fb-video-shell {
  position: relative;
  background: #000;
  border-radius: 2px;
  overflow: hidden;
  aspect-ratio: 9 / 16;
  max-width: 420px;
  margin: 0 auto;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

#fb-video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

.fb-status {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  min-height: 1.2em;
}

.fb-status.is-error {
  color: #c62828;
  font-weight: 700;
}

.fb-end-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: rgba(15, 23, 32, 0.88);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 16px;
}

.fb-end-overlay[hidden] {
  display: none !important;
}

.fb-end-overlay p {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.fb-end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.fb-end-btn {
  border: 1px solid #fff;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
}

.fb-end-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
}

.fb-playlist-panel {
  background: var(--surface);
  border: 1px solid #e5e5e5;
  border-radius: 2px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  padding: 0.9rem;
  max-height: min(80vh, 720px);
  overflow: auto;
}

.fb-playlist-panel h2 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}

.fb-playlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.fb-playlist button {
  width: 100%;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 8px;
  align-items: center;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 6px;
  font: inherit;
  cursor: pointer;
  color: var(--ink);
}

.fb-playlist button:hover,
.fb-playlist button.active {
  background: #e3f2fd;
  border-color: var(--accent);
}

.fb-pl-thumb {
  aspect-ratio: 9 / 16;
  max-height: 72px;
  overflow: hidden;
  border-radius: 4px;
  background: #cfd8dc;
}

.fb-pl-thumb img,
.fb-pl-thumb .thumb-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fb-pl-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.fb-pl-index {
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 860px) {
  .fb-watch-layout {
    grid-template-columns: 1fr;
  }

  .fb-playlist-panel {
    max-height: 40vh;
  }
}

/* legacy embed styles kept unused */
.fb-embed-wrap {
  max-width: 420px;
  margin: 0 auto;
  background: #000;
  border-radius: 2px;
  overflow: hidden;
  aspect-ratio: 9 / 16;
}

.fb-embed-wrap iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

.latestPost .post-image:hover .featured-thumbnail img {
  transform: scale(1.04);
}

.latestPost .post-image:hover .featured-thumbnail {
  box-shadow: inset 0 0 0 4px var(--accent);
}

.latestPost header {
  padding: 10px 2px 4px;
}

.latestPost .title a {
  color: #555;
  text-decoration: none;
}

.latestPost .title a:hover {
  color: var(--accent);
}

.latestPost .meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.latestPost.is-hidden {
  display: none;
}

/* ——— Single / watch ——— */
.single_post > header {
  margin-bottom: 14px;
}

.single-title {
  margin: 0 0 8px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 30px;
  color: #444;
  line-height: 1.25;
}

.post-info {
  color: var(--muted);
  font-size: 13px;
}

.post-info .thecategory a {
  color: var(--accent);
  font-weight: 700;
}

.episode-title,
#fb-episode-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fb-pl-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.latestPost .title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.episode-title.is-error {
  color: #c62828;
}

.player-wrap {
  background: #000;
  border-radius: 2px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

#video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.related-episodes {
  margin-top: 28px;
}

.related-grid .latestPost {
  cursor: pointer;
}

.related-grid .latestPost.is-playing {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.related-grid .latestPost.is-playing .title a {
  color: var(--accent);
}

.related-grid button.ep-card {
  all: unset;
  display: block;
  width: 100%;
  cursor: pointer;
}

.related-grid button.ep-card .title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: #555;
  margin: 0;
  padding: 10px 2px 4px;
  line-height: 1.35;
}

.related-grid .ep-index {
  color: var(--muted);
  font-size: 12px;
  padding: 0 2px 8px;
}

.back-link {
  margin-top: 22px;
  font-weight: 700;
}

/* ——— Footer ——— */
#site-footer {
  background: var(--footer-bg);
  color: #bbb;
  padding: 28px 0 20px;
  margin-top: 20px;
}

#site-footer .footer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#site-footer .site-description {
  margin-top: 4px;
  color: #999;
  font-size: 13px;
}

#site-footer .toplink {
  color: #fff;
  font-size: 22px;
  text-decoration: none;
  line-height: 1;
  padding: 4px 8px;
}

#site-footer .copyrights {
  padding-top: 14px;
}

#copyright-note {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

#copyright-note a {
  color: #ddd;
}

#copyright-note a:hover {
  color: var(--accent);
}

/* ——— Responsive ——— */

/* Prefer full-bleed content; avoid nested overflow */
html,
body {
  overflow-x: hidden;
}

/* iPad portrait / small tablet: collapse nav (links wrap badly at ~768–900) */
@media (max-width: 1023px) {
  #header {
    min-height: 88px;
    padding: 14px 0;
  }

  .posts-grid-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 14px;
  }

  .single-title {
    font-size: clamp(1.35rem, 4vw, 1.75rem);
  }

  .toggle-mobile-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 72px;
    margin: 0;
    border-radius: 2px;
  }

  .navigation-wrap {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 0 10px;
    min-height: 0;
  }

  #primary-navigation {
    flex: 0 0 auto;
    order: 1;
  }

  .widget_search {
    flex: 1 1 auto;
    order: 2;
    min-width: 0;
    padding-right: 0;
  }

  .search-form fieldset {
    width: 100%;
  }

  .search-form input[type="search"] {
    width: 100%;
    flex: 1;
    min-width: 0;
    font-size: 16px; /* avoid iOS zoom on focus */
  }

  .navigation.mobile-menu-wrapper {
    display: none;
    width: 100%;
    order: 3;
    flex-basis: 100%;
  }

  .navigation.mobile-menu-wrapper.is-open {
    display: flex;
  }

  .navigation ul.menu {
    flex-direction: column;
  }

  .navigation ul.menu > li > a {
    padding: 12px 10px;
    min-height: 44px;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
  }
}

/* Phone */
@media (max-width: 640px) {
  .container,
  .article {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  #header {
    min-height: 72px;
    padding: 12px 0;
    background-position: center right 20%;
  }

  #logo {
    font-size: 20px;
  }

  #header .site-description {
    font-size: 12px;
    line-height: 1.35;
    max-width: 92%;
  }

  #page {
    padding: 16px 0 28px;
  }

  .posts-grid-container {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .featured-category-title {
    font-size: 16px;
    margin-bottom: 12px;
  }

  .latestPost .title {
    font-size: 15px;
  }

  .related-grid button.ep-card .title {
    font-size: 14px;
  }

  .player-wrap {
    border-radius: 0;
    margin-left: calc(-1 * max(12px, env(safe-area-inset-left)));
    margin-right: calc(-1 * max(12px, env(safe-area-inset-right)));
    width: calc(100% + max(12px, env(safe-area-inset-left)) + max(12px, env(safe-area-inset-right)));
    max-width: none;
  }

  #site-footer {
    padding: 22px 0 calc(16px + env(safe-area-inset-bottom));
  }

  #site-footer .footer-header {
    flex-direction: column;
    gap: 10px;
  }

  #copyright-note {
    flex-direction: column;
    gap: 6px;
  }
}

/* Large phone landscape / small phablet: 2-col related cards */
@media (min-width: 480px) and (max-width: 640px) {
  .related-grid.posts-grid-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop restore: ensure hamburger hidden */
@media (min-width: 1024px) {
  .toggle-mobile-menu {
    display: none;
  }

  .navigation.mobile-menu-wrapper {
    display: block;
  }

  .posts-grid-container {
    grid-template-columns: repeat(3, 1fr);
  }
}
