/* YouTube (module reel): app skin. Rules moved verbatim from styles.css (C1); the variables are the app identity, posture themes re-map the shell only. */
/* P9 scheme tokens: light = the colours these rules always used, dark = YouTube in its own dark theme. */
:root {
  --youtube-blue-text: #065fd4;
  --youtube-line: #ddd;
  --youtube-orange-text: #c00;
  --youtube-shade: rgba(0,0,0,0.08);
  --youtube-shade-2: rgba(0,0,0,0.05);
  --youtube-surface: #fff;
  --youtube-surface-2: #f1f3f5;
  --youtube-surface-3: #f2f2f2;
  --youtube-surface-4: #e8eaed;
  --youtube-text: #0f0f0f;
  --youtube-tint-blue: #def1ff;
}
[data-scheme="dark"] {
  --youtube-blue-text: #3ea6ff;
  --youtube-line: #383838;
  --youtube-orange-text: #ff7f6e;
  --youtube-shade: rgba(255, 255, 255, 0.096);
  --youtube-shade-2: rgba(255, 255, 255, 0.06);
  --youtube-surface: #0f0f0f;
  --youtube-surface-2: #272727;
  --youtube-surface-3: #272727;
  --youtube-surface-4: #212224;
  --youtube-text: #f1f1f1;
  --youtube-tint-blue: #152028;
}
.module-body[data-module="reel"] {
  --app-font: "Roboto", "Open Sans", Arial, sans-serif;
  --app-accent: #cc0000;
  --app-bg: #ffffff;
  --app-surface: #f1f3f5;
  --app-radius: 12px;
}

/* ---------- Reel / video platform ---------- */
.reel-layout { display: flex; flex-direction: column; gap: 14px; }
.reel-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.reel-search { flex: 1; min-width: 220px; display: flex; align-items: center; gap: 8px; padding: 8px 11px; background: var(--youtube-surface); border: 1px solid var(--border); border-radius: 6px; color: var(--muted); }
.reel-search input { flex: 1; border: none; outline: none; background: none; font-size: 13px; }
.reel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.reel-card { text-align: left; display: flex; flex-direction: column; gap: 9px; padding: 0; border-radius: 8px; }
.reel-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--thumb); border-radius: 8px; overflow: hidden; }
.reel-thumb::after { content: ""; position: absolute; inset: 0; background: var(--youtube-shade); }
.reel-duration { position: absolute; right: 6px; bottom: 6px; z-index: 1; background: rgba(0,0,0,0.82); color: #fff; font-size: 10px; font-weight: 600; padding: 2px 5px; border-radius: 3px; }
.reel-card-copy { display: flex; flex-direction: column; gap: 2px; }
.reel-card-copy strong { font-size: 13px; line-height: 1.3; }
.reel-card-copy small { font-size: 11px; color: var(--muted); }
.reel-card:hover .reel-thumb { filter: brightness(1.05); }
.reel-detail { max-width: 1000px; }
.reel-back { margin-bottom: 10px; }
.reel-player { position: relative; aspect-ratio: 16 / 9; background: var(--thumb); border-radius: 8px; display: grid; place-items: center; overflow: hidden; }
.reel-player::after { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 60% at 50% 50%, var(--youtube-shade-2), rgba(0,0,0,0.35)); }
.reel-play { position: relative; z-index: 1; width: 68px; height: 68px; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.5); border-radius: 50%; }
.reel-title { font-size: 22px; margin-top: 14px; }
.reel-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.reel-description { font-size: 13.5px; margin-top: 10px; max-width: 75ch; }
.reel-detail-actions { display: flex; gap: 8px; margin-top: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.reel-related-title { font-size: 14px; margin: 16px 0 10px; }

/* ---------- Youtube additions ---------- */
.reel-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.reel-tab { padding: 9px 14px; font-size: 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.reel-tab.is-active { color: var(--youtube-text); border-bottom-color: #c00; font-weight: 600; }
.reel-stats { font-size: 11.5px; color: var(--muted); }
.reel-toolbar .reel-search button { flex: none; }
.reel-shorts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.reel-short { position: relative; aspect-ratio: 9 / 16; max-height: 380px; border-radius: 10px; background: var(--thumb); overflow: hidden; text-align: left; }
.reel-short-play { position: absolute; top: 12px; right: 12px; color: #fff; background: rgba(0,0,0,0.45); border-radius: 50%; width: 40px; height: 40px; display: grid; place-items: center; }
.reel-short-copy { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 2px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
.reel-short-copy strong { font-size: 13px; }
.reel-short-copy small { font-size: 10.5px; opacity: 0.85; }
.reel-short-detail { max-width: 420px; }
.reel-short-player { position: relative; aspect-ratio: 9 / 16; max-height: 560px; border-radius: 10px; background: var(--thumb); display: grid; place-items: center; }
.reel-channel-page { max-width: 1100px; }
.reel-channel-head { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--youtube-surface); }
.reel-channel-banner { height: 120px; background: var(--banner); }
.reel-channel-info { display: flex; align-items: center; gap: 16px; padding: 16px; }
.reel-channel-info div { flex: 1; }
.reel-channel-info h2 { font-size: 20px; }
.reel-channel-info p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.reel-channel-info small { font-size: 11px; color: var(--faint); }
.reel-channel-row { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.reel-channel-link { display: flex; align-items: center; gap: 9px; margin-right: auto; }
.reel-channel-link strong { font-size: 13px; }
.reel-channel-link:hover strong { text-decoration: underline; }
.reel-action { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; font-size: 12px; color: var(--muted); background: var(--youtube-surface-2); border-radius: 999px; }
.reel-action:hover { background: var(--youtube-surface-4); color: var(--text); }
.reel-action.is-on { color: var(--youtube-blue-text); background: var(--youtube-tint-blue); }
.reel-comments { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.reel-comments h3 { font-size: 14px; margin-bottom: 10px; }
.reel-comments .composer-inline { margin-top: 12px; }

/* --- C5 YouTube: channel-as-persona, views, replies, shorts, playlists, sidebar rail (desktop), bottom bar (phone) */
.reel-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.reel-tab { display: inline-flex; align-items: center; gap: 6px; }
.reel-tab span:last-child { white-space: nowrap; }
.reel-card-row { display: flex; gap: 10px; align-items: flex-start; }
.reel-card-avatar { flex: none; }
.reel-card-copy { min-width: 0; }
.reel-card-copy strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reel-card-copy small { display: block; }
.reel-thumb { display: block; width: 100%; }  /* the card is a button (align-items: center): an empty thumb would collapse to 0 px */
.reel-card { align-items: stretch; }
.reel-description-box { margin-top: 10px; font-size: 13px; background: var(--app-surface); border-radius: var(--app-radius); padding: 10px 12px; }
.reel-description-box summary { cursor: pointer; font-weight: 600; list-style: none; }
.reel-description-box[open] summary { margin-bottom: 8px; }
.reel-pill-group { display: inline-flex; align-items: center; border-radius: 999px; background: var(--youtube-surface-2); overflow: hidden; }
.reel-pill-group .reel-action { background: transparent; border-radius: 0; }
.reel-pill-group .reel-action:hover { background: var(--youtube-surface-4); }
.reel-comments-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.reel-comments-head h3 { margin: 0; }
.reel-sort { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.reel-sort select { font-size: 12px; border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; background: var(--youtube-surface); }
.reel-comments .comment { display: flex; gap: 10px; margin-bottom: 12px; }
.reel-comments .comment-body { flex: 1; min-width: 0; }
.reel-comments .comment.is-reply { margin-left: 42px; margin-bottom: 8px; }
.reel-comments .comment-actions { display: flex; align-items: center; gap: 10px; min-height: 20px; }
.reel-comments .text-btn { font-size: 12px; color: var(--muted); }
.reel-comments .text-btn[aria-pressed="true"] { color: var(--youtube-blue-text); font-weight: 600; }
.reel-reply-form { margin-top: 6px; }
.reel-note { font-size: 11px; color: var(--faint); }
.reel-channel-text { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.reel-channel-text strong { font-size: 13px; }
.reel-channel-text small { font-size: 11px; color: var(--muted); }
.reel-channel-link:hover .reel-channel-text strong { text-decoration: underline; }
.reel-channel-avatar { flex: none; }
.reel-handle { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.reel-channel-info { align-items: flex-start; }
.reel-channel-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 14px 0; }
.reel-channel-tab { padding: 9px 14px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; }
.reel-channel-tab.is-active { color: var(--youtube-text); border-bottom-color: #c00; font-weight: 600; }
.reel-playlist { margin-bottom: 18px; }
.reel-playlist h3 { font-size: 15px; margin-bottom: 10px; }
.reel-playlist h3 small { font-size: 12px; color: var(--muted); font-weight: 400; }
/* dan/lab#122: own playlists (create, rename, reorder, remove, add from a video page) */
.reel-playlist-new { margin-bottom: 14px; max-width: 520px; }
.reel-playlist-rename { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.reel-playlist-rename input { flex: 1 1 200px; min-width: 0; font-size: 15px; font-weight: 600; padding: 6px 8px; border: 1px solid var(--line, var(--youtube-line)); border-radius: 6px; }
.reel-playlist-rename small { color: var(--muted); }
.reel-playlist-delete { margin-left: auto; color: var(--youtube-orange-text); }
.reel-playlist-videos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.reel-playlist-row { display: flex; align-items: center; gap: 6px; }
.reel-playlist-row .text-btn { min-width: 44px; min-height: 44px; }
.reel-playlist-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; cursor: pointer; padding: 4px; color: inherit; font: inherit; }
.reel-playlist-open span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reel-playlist-thumb { width: 96px; aspect-ratio: 16 / 9; flex: none; border-radius: 6px; background: var(--thumb) center / cover no-repeat, #222; }
.reel-playlist-add { display: inline-flex; align-items: center; gap: 4px; }
.reel-playlist-add select { max-width: 180px; border-radius: 18px; padding: 6px 8px; border: 1px solid var(--line, var(--youtube-line)); }

/* Desktop: a left sidebar rail with the sections; the content column keeps the grid. */
@media (min-width: 900px) {
  .reel-layout { display: grid; grid-template-columns: 150px minmax(0, 1fr); column-gap: 18px; align-items: start; }
  .reel-tabs { flex-direction: column; border-bottom: none; gap: 2px; position: sticky; top: 8px; }
  .reel-tab { padding: 10px 12px; border-bottom: none; border-left: 3px solid transparent; border-radius: 0 8px 8px 0; font-size: 13px; }
  .reel-tab.is-active { border-left-color: #c00; border-bottom-color: transparent; background: var(--youtube-surface-2); }
}

/* Phone (390 px): the sections become a bottom tab bar, as in the real app. */
@media (max-width: 600px) {
  .reel-layout { gap: 10px; }
  .reel-tabs { order: 9; position: sticky; bottom: 0; z-index: 2; justify-content: space-around; background: var(--youtube-surface); border-top: 1px solid var(--border); border-bottom: none; padding: 4px 0 6px; margin: 0 -16px; }
  .reel-tab { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 10.5px; border-bottom: none; }
  .reel-tab.is-active { border-bottom: none; color: var(--youtube-text); }
  .reel-grid { grid-template-columns: 1fr; gap: 18px; }
  .reel-comments .comment.is-reply { margin-left: 24px; }
  .reel-channel-info { flex-wrap: wrap; }
  .reel-detail-actions { overflow-x: auto; flex-wrap: nowrap; }
}

/* the upload form wraps on phones instead of pushing the file picker past the right edge (demo-shots, 390 px) */
.reel-upload { flex-wrap: wrap; }
.reel-upload input[name] { flex: 1 1 160px; min-width: 0; }
.reel-upload .upload-widget, .reel-upload .upload-pick, .reel-upload input[type="file"] { min-width: 0; max-width: 100%; }
/* the like/dislike pill must not shrink inside the scrolling action row (its overflow:hidden cut Dislike off at 390) */
.reel-detail-actions > * { flex: 0 0 auto; }

/* --- T1 fidelity: chips, Shorts shelf, watch page with an Up next column, comment likes ------------------------- */
.reel-chips { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none; }
.reel-chip { flex: none; border: 0; border-radius: 8px; padding: 6px 12px; background: var(--youtube-surface-3); color: var(--youtube-text); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.reel-chip.is-on { background: #0f0f0f; color: #fff; }
.reel-shelf { margin: 22px 0; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.reel-shelf h3 { display: flex; align-items: center; gap: 8px; font-size: 20px; margin: 0 0 12px; }
.reel-shelf h3 .ico { color: #f00; }
.reel-shelf-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 210px); gap: 12px; overflow-x: auto; }
.reel-shelf-row .reel-short { max-height: 370px; }
.reel-watch { max-width: none; }
.reel-secondary .reel-related-title { font-size: 16px; margin: 18px 0 10px; }
.reel-upnext { display: flex; flex-direction: column; gap: 10px; }
.reel-next { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 8px; text-align: left; border: 0; background: none; padding: 0; cursor: pointer; font: inherit; }
.reel-next .reel-thumb { aspect-ratio: 16 / 9; border-radius: 8px; }
.reel-next-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.reel-next-copy strong { font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reel-next-copy small { font-size: 12px; color: var(--muted); }
.reel-description-box { background: var(--youtube-surface-3); border-radius: 12px; padding: 10px 12px; margin-top: 12px; }
.reel-description-box summary { cursor: pointer; list-style: none; font-size: 14px; }
.reel-desc-more { font-weight: 600; }
.reel-description-box[open] .reel-desc-more { display: none; }
.comment-actions .reel-c-like, .comment-actions .reel-c-dislike { display: inline-flex; align-items: center; gap: 4px; color: var(--youtube-text); margin-right: 10px; }
.comment-actions small { color: var(--muted); font-size: 12px; }
.ico.flip-v { transform: scaleY(-1); }
.reel-channel-text strong { display: inline-flex; align-items: center; gap: 4px; }
@media (min-width: 1100px) {
  .reel-watch { display: grid; grid-template-columns: minmax(0, 1fr) 380px; column-gap: 24px; align-items: start; }
  .reel-secondary .reel-related-title { margin-top: 44px; }
}
@media (max-width: 600px) {
  .reel-next { grid-template-columns: 1fr; }
  .reel-shelf-row { grid-auto-columns: 44%; }
}

/* P9 dark scheme: the module tokens above, YouTube in its own dark theme */
[data-scheme="dark"] .module-body[data-module="reel"] {
  --app-accent: #f96b5a;
  --app-bg: #0f0f0f;
  --app-surface: #272727;
}
