:root {
  --tm-bg: #F8FAFC;           /* Primary Base Layer Canvas — soft off-white, not stark */
  --tm-panel: #FFFFFF;         /* Card/panel surfaces */
  --tm-text: #0F172A;          /* Body text — same navy as the logo card */
  --tm-accent: #0D9488;        /* Teal, matches the logo mark */
  --tm-border: #E2E8F0;
  --tm-muted: #64748B;
  --tm-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; min-width: 0; }

html { overflow-x: hidden; }

body {
  margin: 0;
  background: var(--tm-bg);
  color: var(--tm-text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Long words, URLs, or unbroken strings should wrap instead of
   stretching their container past the viewport on small screens. */
h1, h2, h3, h4, p, a, span, div, li, td, th, blockquote {
  overflow-wrap: break-word;
  word-break: break-word;
}

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

img, video, audio { max-width: 100%; }

.tm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--tm-border);
  background: var(--tm-panel);
  position: relative;
}

.tm-logo {
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tm-logo-img {
  height: 42px;
  width: 42px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  flex-shrink: 0;
}

.tm-nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
}
.tm-nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--tm-text);
}

.tm-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tm-nav a {
  margin-left: 20px;
  font-size: 14px;
  color: var(--tm-muted);
  border-bottom: 2px solid transparent;
  padding-bottom: 4px;
  white-space: nowrap;
}

.tm-nav a:hover, .tm-nav a.active {
  color: var(--tm-text);
  border-bottom-color: var(--tm-accent);
}

@media (max-width: 900px) {
  .tm-header { padding: 14px 18px; }
  .tm-nav-toggle { display: flex; }
  .tm-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--tm-panel);
    border-bottom: 1px solid var(--tm-border);
    padding: 8px 18px 16px;
    gap: 4px;
    z-index: 50;
    max-height: 80vh;
    overflow-y: auto;
  }
  .tm-nav.tm-nav-open { display: flex; }
  .tm-nav a {
    margin-left: 0;
    padding: 10px 0;
    font-size: 15px;
    border-bottom: 1px solid var(--tm-border);
  }
}

/* --- Standalone search bar: always visible on every page, on every
   device — never hidden inside the collapsible mobile nav. --- */
.tm-search-bar {
  background: var(--tm-panel);
  border-bottom: 1px solid var(--tm-border);
  padding: 14px 32px;
}

.tm-search-bar form {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--tm-bg);
  border: 1.5px solid var(--tm-border);
  border-radius: 8px;
  padding: 4px 4px 4px 14px;
  transition: border-color 0.15s;
}

.tm-search-bar form:focus-within {
  border-color: var(--tm-accent);
}

.tm-search-icon {
  flex-shrink: 0;
  color: var(--tm-muted);
}

.tm-search {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--tm-text);
  padding: 10px 0;
  font-size: 15px;
  outline: none;
}

.tm-search-submit {
  flex-shrink: 0;
  background: var(--tm-accent);
  color: #fff;
  border-color: var(--tm-accent);
  padding: 10px 18px;
}

.tm-search-submit:hover {
  opacity: 0.9;
  background: var(--tm-accent);
}

@media (max-width: 600px) {
  .tm-search-bar { padding: 10px 14px; }
  .tm-search-bar form { padding: 3px 3px 3px 12px; }
  .tm-search { font-size: 16px; padding: 11px 0; } /* 16px avoids iOS auto-zoom on focus */
  .tm-search-submit { padding: 10px 14px; font-size: 12px; }
}

.tm-ticker {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 32px;
  background: var(--tm-panel);
  border-bottom: 1px solid var(--tm-border);
  overflow: hidden;
}

.tm-ticker-label {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--tm-accent);
}

.tm-ticker-viewport {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
}

.tm-ticker-track {
  display: inline-flex;
  align-items: center;
  gap: 48px;
  animation: tm-ticker-scroll 22s linear infinite;
  will-change: transform;
}

.tm-ticker-viewport:hover .tm-ticker-track {
  animation-play-state: paused;
}

@keyframes tm-ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.tm-ticker-item {
  display: inline-block;
  font-size: 14px;
  color: var(--tm-text);
  white-space: nowrap;
  flex-shrink: 0;
}

.tm-ticker-item.tm-ticker-static {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tm-ticker-item:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  .tm-ticker { padding: 8px 14px; }
  .tm-ticker-label { font-size: 11px; }
  .tm-ticker-item { font-size: 13px; }
  .tm-ticker-track { animation-duration: 16s; gap: 32px; }
}

main#tm-app {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px;
  min-height: 60vh;
}

@media (max-width: 600px) {
  main#tm-app { padding: 18px 14px; }
  h1 { font-size: 24px; }
  h2 { font-size: 19px; }
  h3 { font-size: 16px; }
}

.tm-card {
  background: var(--tm-panel);
  border: 1px solid var(--tm-border);
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--tm-shadow);
}

@media (max-width: 480px) {
  .tm-card { padding: 14px; }
}

.tm-btn {
  display: inline-block;
  background: transparent;
  border: 1px solid var(--tm-accent);
  color: var(--tm-text);
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  flex-shrink: 0;
}

.tm-btn:hover { background: var(--tm-accent); }

.tm-beat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--tm-border);
}

.tm-beat-row-body {
  min-width: 0;
  flex: 1;
}

.tm-row-thumb {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--tm-bg);
}

.tm-row-thumb-empty {
  background: linear-gradient(135deg, var(--tm-bg), var(--tm-border));
}

.tm-beat-row-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

/* Used only on rows that also have a separate Play button — wraps the
   thumbnail + text so the whole row is clickable except the button,
   which needs its own independent click handler. */
.tm-beat-row-link {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1;
  text-decoration: none;
}

/* Rows with no competing button are the anchor itself (see index.php) —
   .tm-beat-row already provides the flex layout; this just neutralizes
   default link styling when it's rendered as an <a> instead of a <div>. */
a.tm-beat-row {
  text-decoration: none;
  cursor: pointer;
}

a.tm-beat-row:hover,
.tm-beat-row-link:hover {
  background: var(--tm-bg);
}

@media (max-width: 480px) {
  .tm-beat-row { flex-wrap: wrap; }
  .tm-beat-row-body { flex-basis: 100%; }
  .tm-beat-row-link { flex-basis: 100%; }
}

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

.tm-owner-block { display: flex; gap: 20px; align-items: flex-start; }
.tm-owner-block > div { min-width: 0; flex: 1; }
.tm-owner-photo {
  width: 96px; height: 96px; border-radius: 6px;
  object-fit: cover; border: 1px solid var(--tm-border);
  background: var(--tm-bg);
  flex-shrink: 0;
}
.tm-owner-placeholder {
  width: 96px; height: 96px; border-radius: 6px;
  border: 1px dashed var(--tm-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--tm-muted); text-align: center; padding: 4px;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .tm-owner-photo, .tm-owner-placeholder { width: 64px; height: 64px; font-size: 9px; }
}

.tm-player-bar {
  position: sticky; bottom: 0;
  background: var(--tm-panel);
  border-top: 1px solid var(--tm-border);
  padding: 10px 24px;
  display: flex; align-items: center; gap: 16px;
  font-size: 13px;
}

#tm-now-playing {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

@media (max-width: 480px) {
  .tm-player-bar { padding: 10px 14px; gap: 10px; }
}

.tm-footer {
  text-align: center;
  padding: 20px;
  color: var(--tm-muted);
  font-size: 12px;
  border-top: 1px solid var(--tm-border);
}

.tm-post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 480px) {
  .tm-post-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

.tm-post-card {
  background: var(--tm-panel);
  border: 1px solid var(--tm-border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--tm-shadow);
}

.tm-post-card-thumb { display: block; position: relative; aspect-ratio: 16/9; background: var(--tm-bg); }
.tm-post-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tm-post-card-noimg { width: 100%; height: 100%; background: linear-gradient(135deg, var(--tm-bg), var(--tm-panel)); }

.tm-post-card-body { padding: 14px; min-width: 0; }
.tm-post-card-title {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--tm-text);
}
.tm-post-card-excerpt {
  font-size: 13px;
  color: var(--tm-muted);
  margin: 0 0 8px;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .tm-post-card-body {
    padding: 8px 10px 10px;
  }
  .tm-post-card-title {
    font-size: 13px;
    line-height: 1.35;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .tm-post-card-excerpt {
    display: none; /* card is too narrow at 2-up for excerpt text to stay readable */
  }
  .tm-beat-meta {
    font-size: 10px;
  }
}

.tm-tag {
  display: inline-block;
  font-size: 12px;
  color: var(--tm-accent);
  background: var(--tm-bg);
  border: 1px solid var(--tm-border);
  border-radius: 12px;
  padding: 3px 10px;
  margin: 0 6px 6px 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-share-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--tm-border);
}
.tm-share-row a { font-size: 13px; color: var(--tm-accent); }

/* --- Social icons (owner/author profile links) ---
   These are small platform badges, not buttons — kept deliberately
   compact so they indicate presence without competing for attention. */
.tm-social-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.tm-social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--tm-muted);
  flex-shrink: 0;
  transition: color .15s;
}
.tm-social-link:hover {
  color: var(--tm-accent);
}
.tm-social-link svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

@media (max-width: 480px) {
  .tm-social-links { gap: 10px; }
  .tm-social-link { width: 13px; height: 13px; }
  .tm-social-link svg { width: 13px; height: 13px; }
}

/* --- Forms --- */
.tm-field-label {
  display: block;
  font-size: 12px;
  color: var(--tm-muted);
  margin: 10px 0 4px;
}
.tm-input, .tm-textarea {
  width: 100%;
  background: var(--tm-bg);
  border: 1px solid var(--tm-border);
  color: var(--tm-text);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}
.tm-textarea { min-height: 140px; resize: vertical; }

/* --- Category badge --- */
.tm-cat-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: inline-block;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 3px;
  line-height: 1.4;
}

/* --- Video indicator on thumbnails --- */
.tm-video-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 480px) {
  .tm-cat-badge {
    font-size: 8px;
    padding: 2px 6px;
  }
  .tm-video-badge {
    width: 18px;
    height: 18px;
  }
  .tm-video-badge svg {
    width: 11px;
    height: 11px;
  }
}

/* --- Video player on single post page --- */
.tm-video-wrap {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  margin-bottom: 8px;
}
.tm-video-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}
.tm-video-caption {
  max-width: 640px;
  font-size: 13px;
  color: var(--tm-muted);
  margin: 0 0 16px;
  font-style: italic;
}