* {
  box-sizing: border-box;
}

:root {
  --bg: #0b0f14;
  --bg-2: #101720;
  --panel: #111821;
  --panel-2: #16212c;
  --border: #223041;
  --text: #f3f0e8;
  --muted: #9fb0c3;
  --accent: #2dd4bf;

  /* Cresamor gold — used for the redesigned Home experience & nav */
  --gold: #d4af37;
  --gold-soft: #f0d98c;
  --gold-dim: rgba(212, 175, 55, 0.18);
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg), var(--bg-2) 55%, #0c1118);
  color: var(--text);
}

.hidden {
  display: none !important;
}

header {
  display: none;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 20, 0.95);
}

body.app-active header {
  display: block;
}

#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

#topbar h1 {
  margin: 0;
  letter-spacing: 0.04em;
  font-size: 1.6rem;
}

#user-badge {
  color: var(--muted);
  font-size: 0.95rem;
}

h1,
h2 {
  margin-top: 0;
}

main {
  min-height: 100vh;
}

#login-screen {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 1rem;
}

body.app-active #login-screen {
  display: none !important;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.auth-card h2 {
  margin-bottom: 1rem;
}

.auth-card input {
  width: 100%;
  margin-bottom: 0.8rem;
}

#login-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#login-btn {
  background: linear-gradient(180deg, var(--gold), #a9862a);
  color: #1a1405;
  font-weight: 700;
  border: none;
}

#login-btn:hover {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
}

/* Non-blocking toast -- originally built for the session-expiration fix
   (replacing stacked alert()s for a real 401), now the one shared
   mechanism for any brief non-blocking message (also used by the
   One-Button Highlight save-failure path). Auto-dismissed by app.js's
   showToast(); fixed position so it never shifts layout underneath it. */
#app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--gold);
  color: var(--gold-soft);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  font-weight: 600;
  max-width: 90vw;
  text-align: center;
}

/* One-Button Highlight: idle/active/saving states for the single toggle
   button that replaced Start Clip/End Clip/Save Highlight. Sized well
   past the platform touch-target minimum (44px) for mobile. */
#highlight-toggle-btn {
  min-height: 44px;
  min-width: 160px;
  font-weight: 700;
  border: none;
  background: linear-gradient(180deg, var(--gold), #a9862a);
  color: #1a1405;
  transition: background 0.15s ease;
}

/* :not(.highlight-active):not(.highlight-saving) -- without this, a bare
   #highlight-toggle-btn:hover rule (id + 1 pseudo-class) outweighs
   #highlight-toggle-btn.highlight-active (id + 1 class, equal-weight
   selector but fewer of them) and silently reverts the button to gold
   the instant the pointer that just clicked Start Highlight is still
   sitting over it -- caught live in manual testing, not theoretical: the
   recording indicator vanished under the cursor immediately after the
   tap that's supposed to trigger it. */
#highlight-toggle-btn:hover:not(:disabled):not(.highlight-active):not(.highlight-saving) {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
}

/* Active/recording state -- deliberately a different hue (not just a
   darker gold) so "you are currently clipping" is unmistakable at a
   glance, not just readable from the text. Reuses this project's
   existing error/destructive red (#e05252, see .video-delete-btn:hover)
   rather than inventing a new color. */
#highlight-toggle-btn.highlight-active {
  background: linear-gradient(180deg, #e05252, #a63a3a);
  color: #fff;
}

#highlight-toggle-btn.highlight-active:hover {
  background: linear-gradient(180deg, #eb6b6b, #e05252);
}

#highlight-toggle-btn.highlight-saving {
  background: linear-gradient(180deg, #3a4048, #262b31);
  color: var(--muted);
  cursor: not-allowed;
}

#highlight-toggle-btn:disabled {
  cursor: not-allowed;
}

/* Personal-highlight rename/delete affordances in the "Current Video
   Highlights" list -- kept minimal (matches this project's existing
   confirm()-before-delete convention, e.g. deleteLocalRecording()), not a
   new UI system. */
.highlight-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.highlight-item-btn {
  flex: 1;
}

.highlight-item-action-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
}

.highlight-item-action-btn:hover {
  border-color: var(--gold);
  color: var(--gold-soft);
}

.highlight-item-action-btn.highlight-delete-btn:hover {
  border-color: #e05252;
  color: #e05252;
}

#app-shell {
  min-height: 100vh;
  padding: 1rem;
}

#film-room {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 1rem;
}

#video-section,
#side-panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* FIXED VIDEO VIEWPORT */
#video-wrapper {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  background: black;
  overflow: hidden;
  border-radius: 10px;
}

/* VIDEO STAYS INSIDE THE BOX */
#film-player {
  width: 100%;
  height: 100%;
  display: block;
  background: black;
  object-fit: contain;
}

#draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#playback-controls,
#highlight-tools,
#draw-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

button,
input,
select {
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font: inherit;
}

button {
  background: linear-gradient(180deg, #16212c, #101820);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  background: linear-gradient(180deg, #1b2a37, #12202b);
  border-color: var(--accent);
}

input,
select {
  background: #0f1720;
  color: var(--text);
}

#coach-tools,
#upload-section,
#personal-upload-section,
#notes-panel {
  margin-top: 1rem;
}

#side-panel section {
  margin-bottom: 1.5rem;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

li {
  margin-bottom: 0.5rem;
}

.video-item-btn,
.highlight-item-btn {
  width: 100%;
  text-align: left;
}

.video-item-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.video-item-btn.video-unavailable {
  opacity: 0.6;
  font-style: italic;
}

.video-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.video-item .video-item-btn {
  flex: 1;
}

/* Forces the error line onto its own row below the button/badges —
   .video-item is a flex row (button + retry/delete buttons side by
   side); without flex-basis: 100% this would just sit inline next to
   them instead of reading as a caption underneath. */
.video-item-error {
  flex: 1 0 100%;
  font-size: 0.75rem;
  /* Matches .video-delete-btn:hover's existing error-red precedent. */
  color: #e05252;
  padding-left: 0.2rem;
}

.video-delete-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
}

.video-delete-btn:hover {
  border-color: #e05252;
  color: #e05252;
}

.video-delete-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.video-retry-btn,
.video-change-team-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
}

.video-retry-btn:hover,
.video-change-team-btn:hover {
  border-color: var(--gold);
  color: var(--gold-soft);
}

.video-retry-btn:disabled,
.video-change-team-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.highlight-item-btn small {
  display: block;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* FULLSCREEN MODE */
#video-section:fullscreen,
#video-section:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  border-radius: 0;
  border: none;
  padding: 0;
  background: black;
  position: relative;
}

#video-section:fullscreen #video-wrapper,
#video-section:-webkit-full-screen #video-wrapper {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
}

#video-section:fullscreen #film-player,
#video-section:-webkit-full-screen #film-player {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#video-section:fullscreen #playback-controls,
#video-section:-webkit-full-screen #playback-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 0.9rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0),
    rgba(0, 0, 0, 0.88)
  );
  margin: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#video-section:fullscreen #highlight-tools,
#video-section:fullscreen #upload-section,
#video-section:fullscreen #personal-upload-section,
#video-section:-webkit-full-screen #highlight-tools,
#video-section:-webkit-full-screen #upload-section,
#video-section:-webkit-full-screen #personal-upload-section {
  display: none !important;
}

@media (max-width: 900px) {
  #film-room {
    grid-template-columns: 1fr;
  }

  #topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  #app-shell {
    padding: 0.75rem;
  }

  #video-section,
  #side-panel {
    padding: 0.75rem;
  }
}

.app-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 15, 20, 0.95);
  padding: 0.75rem 0;
}

.tab-btn {
  flex: 1;
}

.tab-btn.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold);
  color: var(--gold-soft);
}

.app-tabs {
  overflow-x: auto;
  scrollbar-width: thin;
}

.app-screen {
  display: none;
}

.app-screen.active {
  display: block;
}

#messages-screen,
#highlights-screen {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}

#messages-layout {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  gap: 1rem;
  align-items: start;
}

/* ---------- Direct Messaging Phase 2: inbox ---------- */

#messages-inbox {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 70vh;
  overflow-y: auto;
  min-width: 0;
}

#messages-inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

#messages-inbox-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

#new-message-btn {
  flex-shrink: 0;
}

.messages-inbox-section-label {
  margin: 0.5rem 0 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.messages-inbox-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.messages-inbox-empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.4rem 0;
}

/* Tap target sized for touch, not hover — rows are clickable regardless
   of pointer type. */
.messages-inbox-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.5rem;
  border-radius: 10px;
  cursor: pointer;
  min-width: 0;
}

.messages-inbox-item:hover,
.messages-inbox-item-selected {
  background: var(--gold-dim, rgba(212, 175, 55, 0.12));
}

.messages-inbox-item-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.messages-inbox-item-name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.messages-inbox-item-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages-inbox-item-unread .messages-inbox-item-name {
  color: var(--gold-soft, var(--gold));
}

.messages-inbox-item-time {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.messages-inbox-item-context {
  font-size: 0.72rem;
  color: var(--muted);
}

.messages-inbox-item-preview {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  color: var(--muted);
}

.messages-inbox-item-unread .messages-inbox-item-preview {
  color: var(--text);
}

.messages-inbox-unread-badge {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--gold, #d4af37);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- active conversation pane (shared by Team Chat + DMs) ---------- */

#messages-active-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#messages-active-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

#messages-active-context {
  margin: 0.15rem 0 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

#messages-active-placeholder {
  color: var(--muted);
  text-align: center;
  padding: 3rem 1rem;
}

/* Direct-message sender distinction — "own" vs "theirs," not "coach" vs
   "everyone else" (that distinction has no meaning for a 1:1 thread).
   Same visual treatment (right/accent vs left/dark) as the existing
   coach/player styling below, just relabeled for a DM context. */
.own-message {
  align-self: flex-end;
}

.own-message .message-username {
  text-align: right;
}

.own-message .message-bubble {
  background: var(--accent);
  color: #06100f;
  border-top-right-radius: 4px;
}

.their-message {
  align-self: flex-start;
}

.their-message .message-bubble {
  background: #1d2a38;
  color: var(--text);
  border-top-left-radius: 4px;
}

/* ---------- New Message recipient picker ---------- */

#new-message-recipient-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  max-height: 50vh;
  overflow-y: auto;
}

.new-message-recipient-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.4rem;
  border-bottom: 1px solid var(--gold-dim, rgba(212, 175, 55, 0.15));
  cursor: pointer;
}

.new-message-recipient-item:last-child {
  border-bottom: none;
}

.new-message-recipient-item:hover {
  background: var(--gold-dim, rgba(212, 175, 55, 0.1));
}

.new-message-recipient-item small {
  color: var(--muted);
}

/* ---------- Messages nav tab unread bubble ---------- */

.nav-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 0.35rem;
  border-radius: 999px;
  background: var(--gold, #d4af37);
  color: #000;
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: middle;
}

/* ---------- Direct Messaging Phase 3: floating AIM-style windows ----------
   Deliberately outside every .app-screen (see index.html) so they stay
   visible across tab navigation. New windows accumulate from the
   bottom-right corner outward (flex-end + normal DOM order), wrapping
   upward (wrap-reverse) if there isn't room for another row, rather than
   ever covering the composer bar. */

#dm-windows-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: flex-end;
  flex-wrap: wrap-reverse;
  gap: 0.75rem;
  max-width: calc(100vw - 2rem);
}

.dm-window {
  width: 300px;
  height: 380px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--gold-dim, rgba(212, 175, 55, 0.35));
  border-radius: 12px 12px 4px 4px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.dm-window.dm-window-focused {
  border-color: var(--gold, #d4af37);
}

.dm-window.dm-window-disabled {
  opacity: 0.75;
}

.dm-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: var(--gold-dim, rgba(212, 175, 55, 0.14));
  border-bottom: 1px solid var(--gold-dim, rgba(212, 175, 55, 0.25));
}

.dm-window-header-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.dm-window-title {
  font-weight: 600;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-window-context {
  font-size: 0.68rem;
  color: var(--muted);
}

.dm-window-controls {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

/* Real controls, sized for a fingertip even though this surface is
   desktop-only today — cheap to get right, never assume mouse-only. */
.dm-window-controls button {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  line-height: 1;
}

.dm-window-thread {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.6rem;
  background: rgba(0, 0, 0, 0.18);
}

.dm-window-thread .message-row {
  max-width: 82%;
}

.dm-window-disabled-banner {
  margin: 0;
  padding: 0.45rem 0.6rem;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid var(--border);
}

.dm-window-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem;
  border-top: 1px solid var(--border);
}

.dm-window-form input {
  flex: 1;
  min-width: 0;
}

.dm-minimized-tab {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--gold-dim, rgba(212, 175, 55, 0.35));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  max-width: 200px;
}

.dm-minimized-tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  color: var(--text);
}

.dm-minimized-tab-badge {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--gold, #d4af37);
  color: #000;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dm-minimized-tab-close-btn {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  line-height: 1;
  font-size: 0.7rem;
}

@media (max-width: 700px) {
  /* Never squeeze desktop floating windows onto a phone -- opening a DM
     on a narrow viewport uses #dm-mobile-overlay instead (see
     directMessages.js's isMobileViewport() gate at open time). This is
     also a defensive fallback if a window somehow stayed open across a
     live resize past the breakpoint: it disappears rather than
     overlapping the mobile layout, even though nothing in this app
     currently migrates an open window's presentation live. */
  #dm-windows-container {
    display: none;
  }
}

/* ---------- Direct Messaging Phase 3: mobile full-screen DM overlay ---------- */

#dm-mobile-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  flex-direction: column;
  background: var(--bg, #0b0f14);
}

#dm-mobile-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 20, 0.95);
}

#dm-mobile-back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
}

#dm-mobile-header-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#dm-mobile-title {
  margin: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#dm-mobile-context {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

#dm-mobile-thread {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}

#dm-mobile-thread .message-row {
  max-width: 88%;
}

#dm-mobile-disabled-banner {
  margin: 0;
  padding: 0.6rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  background: rgba(0, 0, 0, 0.25);
}

#dm-mobile-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: rgba(11, 15, 20, 0.95);
}

#dm-mobile-input {
  flex: 1;
  min-width: 0;
}

#message-thread {
  min-height: 360px;
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 12px;
}

.message-row {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}

.message-username {
  margin: 0 0 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.message-bubble {
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  line-height: 1.35;
}

/* LEFT SIDE */
.coach-message {
  align-self: flex-start;
}

.coach-message .message-bubble {
  background: #1d2a38;
  color: var(--text);
  border-top-left-radius: 4px;
}

/* RIGHT SIDE */
.player-message {
  align-self: flex-end;
}

.player-message .message-username {
  text-align: right;
}

.player-message .message-bubble {
  background: var(--accent);
  color: #06100f;
  border-top-right-radius: 4px;
}

#message-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  position: sticky;
  bottom: 0;
  z-index: 15;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  padding: 0.75rem 0 calc(0.25rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
}

#message-input {
  width: 100%;
}

@media (max-width: 700px) {
  #message-form {
    grid-template-columns: 1fr;
  }

  .message-row {
    max-width: 88%;
  }

  /* Phase 2 foundation only — a real mobile master/detail or full-screen
     DM overlay is Phase 3/4 work per the approved plan; for now the
     inbox and active pane simply stack, each independently scrollable,
     so nothing is unusably cramped in the meantime. */
  #messages-layout {
    grid-template-columns: 1fr;
  }

  #messages-inbox {
    max-height: 260px;
  }

  .own-message,
  .their-message {
    max-width: 88%;
  }
}

#video-section:fullscreen #draw-canvas,
#video-section:-webkit-full-screen #draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
}

#video-section:fullscreen #film-player,
#video-section:-webkit-full-screen #film-player {
  position: relative;
  z-index: 1;
}

#video-section:fullscreen #video-wrapper,
#video-section:-webkit-full-screen #video-wrapper {
  position: relative;
}

#video-section:fullscreen #draw-canvas {
  pointer-events: auto;
}

#video-section:fullscreen #coach-tools,
#video-section:-webkit-full-screen #coach-tools {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 40;

  display: flex !important;
  flex-direction: column;
  gap: 0.5rem;

  background: rgba(0, 0, 0, 0.72);
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

#video-section:fullscreen #draw-tools,
#video-section:-webkit-full-screen #draw-tools {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#video-section:fullscreen #notes-panel,
#video-section:-webkit-full-screen #notes-panel {
  display: none;
}

#draw-tools button.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

#video-loading-overlay,
#reel-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

#video-loading-overlay.hidden,
#reel-loading-overlay.hidden {
  display: none;
}

#video-status-message {
  position: absolute;
  inset: 0;
  /* Fully opaque, not the loading overlay's translucent rgba(0,0,0,0.75) —
     the loading overlay's own loadstart listener can re-show itself right
     after this renders (removeAttribute("src") + load() still fires
     loadstart before error), so this has to fully cover it regardless of
     that race, not just win a z-index/timing contest. */
  background: #05060a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 21;
  text-align: center;
  padding: 1rem;
}

#video-status-message.hidden {
  display: none;
}

#video-status-message p {
  color: white;
  font-size: 1rem;
  max-width: 320px;
}

/* Same fully-opaque-and-higher-z-index approach as #video-status-message
   above, and for the identical reason: a spurious loadstart (the browser's
   own default handling of the player's empty <source src="">, or
   removeAttribute("src") + load() for a blocked video) can re-show the
   loading spinner underneath regardless of what JS thinks the visible
   state should be — visually covering it is what actually wins that race,
   not trying to prevent the event from firing in the first place. */
#video-empty-state {
  position: absolute;
  inset: 0;
  background: #05060a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 22;
  text-align: center;
  padding: 1rem;
}

#video-empty-state.hidden {
  display: none;
}

#video-empty-state p {
  color: var(--muted);
  font-size: 1rem;
  max-width: 320px;
}

.loading-content {
  text-align: center;
  color: white;
  font-size: 1rem;
  letter-spacing: 1px;
  width: 220px;
}

.loading-spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top: 3px solid var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Shared by the Film-player overlay, the reel overlay, and the manual
   upload progress block — Sprint 3 real loading/upload feedback. */
.video-progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
  margin: 0.6rem 0 0.4rem;
}

.video-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--gold-soft));
  transition: width 0.2s ease;
}

.video-progress-percent {
  font-weight: 700;
  margin: 0 0 0.2rem;
}

.video-progress-sub {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0 0 0.2rem;
  letter-spacing: normal;
}

.video-progress-eta {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0;
  letter-spacing: normal;
  min-height: 1em;
}

#manual-upload-progress {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

#manual-upload-progress p {
  margin: 0;
}

#manual-upload-progress .video-progress-track {
  margin: 0.5rem 0;
}

/* ==========================================================================
   HOME SCREEN — Cresamor gold/dark redesign
   ========================================================================== */

#home-layout {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}

#home-layout > section {
  grid-column: span 12;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

@media (min-width: 960px) {
  #profile-block {
    grid-column: span 12;
  }
  #hero-card {
    grid-column: span 7;
  }
  #featured-reel {
    grid-column: span 5;
  }
  #continue-watching {
    grid-column: span 12;
  }
  #messages-preview {
    grid-column: span 5;
  }
  #upcoming-events {
    grid-column: span 3;
  }
  #recent-activity {
    grid-column: span 4;
  }
}

/* ---------- Profile block ---------- */

#profile-block {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
}

#profile-picture-placeholder {
  width: 76px;
  height: 76px;
  min-width: 76px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--gold), #8a6d1f);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: #1a1405;
  border: 2px solid var(--gold-soft);
}

#profile-info {
  flex: 1;
  min-width: 180px;
}

#profile-info h2 {
  margin: 0 0 0.3rem;
  font-size: 1.4rem;
}

#profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

#profile-meta span::after {
  content: "•";
  margin-left: 0.6rem;
  color: var(--border);
}

#profile-meta span:last-child::after {
  content: "";
}

#edit-profile-btn {
  border-color: var(--gold);
  color: var(--gold-soft);
}

#edit-profile-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#edit-profile-form h3 {
  margin: 0 0 0.2rem;
}

.edit-profile-actions {
  display: flex;
  gap: 0.6rem;
}

#save-profile-btn {
  border-color: var(--gold);
  color: var(--gold-soft);
}

.mock-note {
  color: var(--muted);
  font-size: 0.8rem;
  font-style: italic;
  margin: 0.3rem 0 0;
}

/* ---------- Profile photo upload (Sprint 3) ---------- */

#edit-profile-photo-section {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

#edit-profile-photo-preview {
  width: 64px;
  height: 64px;
  min-width: 64px;
  border-radius: 50%;
  background-color: #0f1720;
  background-size: cover;
  background-position: center;
  border: 2px solid var(--gold-dim);
}

#edit-profile-photo-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #16212c, #101820);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.file-upload-btn:hover {
  background: linear-gradient(180deg, #1b2a37, #12202b);
  border-color: var(--gold);
}

#edit-profile-photo-status {
  width: 100%;
  margin: 0;
}

/* ---------- Hero card ---------- */

#hero-card {
  background: linear-gradient(150deg, #1c1710, var(--panel) 55%, var(--panel-2));
  border: 1px solid var(--gold-dim);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: space-between;
}

#hero-tagline {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--gold-soft);
  letter-spacing: 0.02em;
}

#hero-details {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.hero-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

#watch-now-btn {
  align-self: flex-start;
  background: linear-gradient(180deg, var(--gold), #a9862a);
  color: #1a1405;
  font-weight: 700;
  border: none;
}

#watch-now-btn:hover {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
}

/* ---------- Featured reel ---------- */

#featured-reel h2,
#continue-watching h2,
#messages-preview h2,
#upcoming-events h2,
#recent-activity h2 {
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

#reel-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: black;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

#reel-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: pointer;
}

#reel-video.hidden {
  display: none;
}

#reel-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  color: var(--muted);
}

#reel-title {
  position: absolute;
  left: 0.75rem;
  bottom: 0.6rem;
  margin: 0;
  padding: 0.3rem 0.7rem;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 8px;
  font-size: 0.85rem;
  pointer-events: none;
}

#reel-thumbnails {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

/* Mobile (default): video on top, horizontal-scrolling thumbnail strip
   below — this is exactly Sprint 1's original mobile behavior, unchanged. */
#reel-body {
  display: block;
}

/* Desktop: video ~70% width with a thumbnail column on the right, per
   Sprint 3's layout spec. Native <video> `controls` already includes a
   fullscreen button, so "Full Screen still available" needs no extra work. */
@media (min-width: 900px) {
  #reel-body {
    display: grid;
    grid-template-columns: 70% 1fr;
    gap: 0.75rem;
    align-items: start;
  }

  #reel-stage {
    margin-bottom: 0;
    aspect-ratio: 16 / 9;
  }

  #reel-thumbnails {
    flex-direction: column;
    overflow-x: visible;
    overflow-y: auto;
    height: 100%;
  }

  .reel-thumb-btn {
    width: 100%;
    height: 72px;
    flex: 0 0 auto;
  }
}

.reel-thumb-btn {
  flex: 0 0 auto;
  width: 84px;
  height: 48px;
  border-radius: 8px;
  background-color: #0f1720;
  background-size: cover;
  background-position: center;
  border: 2px solid var(--border);
  padding: 0;
  cursor: pointer;
}

.reel-thumb-btn.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold);
}

.reel-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-soft);
  font-weight: 700;
  background: linear-gradient(160deg, #22190a, var(--panel-2));
}

/* ---------- Continue watching ---------- */

#continue-watching-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

#continue-watching-thumb {
  width: 90px;
  height: 56px;
  border-radius: 8px;
  background: linear-gradient(160deg, #1c1710, var(--panel-2));
  border: 1px solid var(--border);
  flex: 0 0 auto;
}

#continue-watching-info {
  flex: 1;
  min-width: 160px;
}

#continue-watching-title {
  margin: 0 0 0.4rem;
}

#continue-watching-progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

#continue-watching-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-soft));
  border-radius: 999px;
}

#continue-watching-resume-btn {
  border-color: var(--gold);
  color: var(--gold-soft);
}

/* ---------- Messages preview ---------- */

#messages-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

#messages-preview-header h2 {
  margin: 0;
}

#view-all-messages-btn {
  font-size: 0.8rem;
  padding: 0.45rem 0.7rem;
  border-color: var(--gold);
  color: var(--gold-soft);
}

.message-preview-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.message-preview-item:last-child {
  border-bottom: none;
}

.message-preview-avatar {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--gold), #8a6d1f);
  color: #1a1405;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-preview-body {
  flex: 1;
  min-width: 0;
}

.message-preview-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.message-preview-sender {
  font-weight: 600;
}

.message-preview-category {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.message-preview-text {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-badge {
  position: absolute;
  right: 0;
  top: 0.6rem;
  background: var(--gold);
  color: #1a1405;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

/* ---------- Upcoming events ---------- */

.upcoming-event-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.upcoming-event-item:last-child {
  border-bottom: none;
}

.event-type-badge {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--gold-dim);
  color: var(--gold-soft);
  border: 1px solid var(--gold-dim);
}

.event-details strong {
  display: block;
  font-size: 0.92rem;
}

.event-details small {
  color: var(--muted);
}

/* ---------- Recent activity ---------- */

.activity-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.activity-text {
  flex: 1;
}

.mock-tag {
  color: var(--muted);
  font-size: 0.78rem;
}

.activity-time {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.empty-state {
  color: var(--muted);
  font-style: italic;
  list-style: none;
  padding: 0.5rem 0;
}

/* ---------- Placeholder screens ---------- */

.placeholder-screen {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  color: var(--muted);
}

.placeholder-screen h2 {
  color: var(--text);
}

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
  #profile-block {
    flex-direction: column;
    align-items: flex-start;
  }

  #home-layout > section {
    padding: 1rem;
  }

  .message-preview-text {
    white-space: normal;
  }
}

/* ==========================================================================
   FILM CAPTURE MODAL
   ========================================================================== */

#record-section {
  margin-top: 0.75rem;
}

#record-film-btn {
  background: linear-gradient(180deg, var(--gold), #a9862a);
  color: #1a1405;
  font-weight: 700;
  border: none;
  width: 100%;
}

#record-film-btn:hover {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
}

#capture-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 7, 10, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#capture-modal.hidden {
  display: none;
}

#capture-modal-inner {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--gold-dim);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#capture-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}

.capture-step.hidden {
  display: none;
}

.capture-step h3 {
  margin-top: 0;
  color: var(--gold-soft);
}

.capture-step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.capture-step-actions button {
  flex: 1;
  min-width: 120px;
}

#capture-record-btn,
#capture-upload-btn,
#capture-continue-to-record-btn {
  background: linear-gradient(180deg, var(--gold), #a9862a);
  color: #1a1405;
  font-weight: 700;
  border: none;
}

#capture-confirm-team-list {
  margin-top: 0.5rem;
}

.capture-team-btn {
  width: 100%;
  text-align: left;
  margin-bottom: 0.4rem;
}

/* ---------- Phase 4: camera-first entry + assign-team step ---------- */

#capture-native-buttons button,
#capture-desktop-start button {
  width: 100%;
}

#capture-native-back-btn {
  background: linear-gradient(180deg, var(--gold), #a9862a);
  color: #1a1405;
  font-weight: 700;
  border: none;
}

#capture-skip-team-btn {
  width: 100%;
  margin-top: 0.75rem;
}

#capture-device-select {
  width: 100%;
  margin-bottom: 0.75rem;
}

#capture-device-preview,
#capture-preview-video,
#capture-review-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: black;
  border-radius: 10px;
  object-fit: contain;
}

#capture-record-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-variant-numeric: tabular-nums;
}

#capture-record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e5484d;
  animation: pulse-rec 1.2s infinite;
}

#capture-record-dot.hidden {
  display: none;
}

@keyframes pulse-rec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Real-Time Sideline Replay: inline sync status on the Review step,
   replacing the old full-screen upload/done steps — the coach stays on
   Review (instant replay) while this updates in place. */
#capture-review-status {
  margin-top: 1rem;
}

#capture-review-status.hidden {
  display: none;
}

#capture-review-status-text {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

#capture-review-status-fill {
  background: linear-gradient(90deg, var(--gold), var(--gold-soft));
}

#capture-native-status,
#manual-upload-status {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Lifecycle badges — Film Room list entries still local/syncing (not yet
   the server's synced-and-processed row). */
.video-item-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  border: 1px solid var(--muted);
  color: var(--muted);
}

.video-item-badge.badge-syncing {
  border-color: var(--gold);
  color: var(--gold-soft);
}

@media (max-width: 600px) {
  #capture-modal-inner {
    padding: 1rem;
    max-height: 95vh;
  }
}

/* ==========================================================================
   TEAMS MVP
   ========================================================================== */

/* ---------- Forgot/reset-password screens (same centered-card layout as
   #login-screen; belt-and-suspenders hidden post-login just like it). ---------- */

#forgot-password-screen,
#reset-password-screen {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 1rem;
}

body.app-active #forgot-password-screen,
body.app-active #reset-password-screen {
  display: none !important;
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  padding: 0.4rem 0;
  width: 100%;
  text-align: center;
}

.link-btn:hover {
  background: none;
  border: none;
  color: var(--gold-soft);
}

#invitation-preview {
  margin-bottom: 1rem;
  border-color: var(--gold-dim);
}

#invitation-preview h2 {
  color: var(--gold-soft);
}

#invitation-preview-error {
  color: #e88;
  text-align: center;
  max-width: 420px;
  margin: 0 auto 1rem;
}

#forgot-password-confirmation,
#reset-password-error,
#invite-form-error,
#login-error {
  margin-top: 0.75rem;
  color: var(--muted);
}

#reset-password-error,
#login-error {
  color: #e88;
}

/* ---------- Teams screen: list + detail/roster ---------- */

#teams-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.team-list-item,
.team-roster-item,
.team-invitation-item,
.my-pending-invitation-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.team-list-item-info,
.team-roster-item-info,
.team-invitation-item-info,
.my-pending-invitation-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.team-list-item-meta,
.team-roster-item-meta,
.team-invitation-item-meta,
.my-pending-invitation-item-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

#my-pending-invitations-section {
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gold-dim);
}

.invitation-status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  width: fit-content;
}

.invitation-status-pending {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-soft, #d4af37);
}

.invitation-status-accepted {
  background: rgba(107, 191, 143, 0.15);
  color: #6bbf8f;
}

.invitation-status-expired,
.invitation-status-revoked {
  background: rgba(232, 136, 136, 0.15);
  color: #e88;
}

#team-invitations-section {
  margin-top: 1.5rem;
}

.team-roster-revoke-btn {
  border-color: #e88;
  color: #e88;
}

.team-roster-revoke-btn:hover {
  border-color: #e88;
  background: rgba(232, 136, 136, 0.12);
}

#team-detail-view {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}

#team-detail-meta {
  color: var(--muted);
  margin-bottom: 1rem;
}

#team-detail-actions {
  margin-bottom: 1.5rem;
}

/* ---------- Create-team / invite modals — same skeleton as #capture-modal ---------- */

#create-team-modal,
#invite-modal,
#invitation-confirm-modal,
#video-team-modal,
#upload-destination-modal,
#schedule-day-modal,
#schedule-event-modal,
#new-message-modal,
#team-highlights-publish-modal,
#personal-upload-team-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 7, 10, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#create-team-modal.hidden,
#invite-modal.hidden,
#invitation-confirm-modal.hidden,
#video-team-modal.hidden,
#upload-destination-modal.hidden,
#schedule-day-modal.hidden,
#schedule-event-modal.hidden,
#new-message-modal.hidden,
#team-highlights-publish-modal.hidden,
#personal-upload-team-modal.hidden {
  display: none;
}

#create-team-modal-inner,
#invite-modal-inner,
#invitation-confirm-modal-inner,
#video-team-modal-inner,
#upload-destination-modal-inner,
#schedule-day-modal-inner,
#schedule-event-modal-inner,
#new-message-modal-inner,
#team-highlights-publish-modal-inner,
#personal-upload-team-modal-inner {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--gold-dim);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#create-team-close-btn,
#invite-close-btn,
#video-team-close-btn,
#upload-destination-close-btn,
#schedule-day-close-btn,
#schedule-event-close-btn,
#new-message-close-btn,
#team-highlights-publish-close-btn,
#personal-upload-team-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}

#create-team-modal-inner input,
#invite-modal-inner input,
#invite-modal-inner select,
#video-team-modal-inner select,
#upload-destination-modal-inner select,
#schedule-event-modal-inner input,
#schedule-event-modal-inner select,
#schedule-event-modal-inner textarea {
  width: 100%;
  margin-bottom: 0.8rem;
}

#schedule-event-modal-inner textarea {
  resize: vertical;
  font-family: inherit;
}

#invite-team-name-label {
  color: var(--muted);
  margin-top: -0.5rem;
}

#invite-modal-inner label,
#video-team-modal-inner label,
#upload-destination-modal-inner label,
#schedule-event-modal-inner label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

/* ---------- Schedule: team context, view toggle, Calendar grid, Agenda ---------- */

#schedule-team-context {
  margin-bottom: 1rem;
}

#schedule-team-select {
  width: 100%;
  max-width: 320px;
}

#schedule-view-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.schedule-view-btn {
  opacity: 0.6;
}

.schedule-view-btn.active {
  opacity: 1;
  border-color: var(--gold, #d4af37);
}

#schedule-add-event-btn {
  margin-left: auto;
}

#schedule-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

#schedule-calendar-month-label {
  font-weight: 600;
}

#schedule-calendar-prev-btn,
#schedule-calendar-next-btn {
  min-width: 44px;
  min-height: 44px;
}

#schedule-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

#schedule-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

/* Tap target sized for touch, not hover — day cells are buttons, not
   divs with a hover-only affordance. */
.schedule-calendar-day {
  min-height: 56px;
  padding: 4px;
  border: 1px solid var(--gold-dim, rgba(212, 175, 55, 0.25));
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  overflow: hidden; /* a busy day's dot row must clip, never stretch the row */
}

/* Desktop/tablet: give the 6-week grid a real height instead of shrink-wrapping
   its rows to the dot row's content, so cells read as calendar squares instead
   of spreadsheet rows. grid-auto-rows: 1fr splits that height evenly across
   however many week-rows actually render (5 or 6), so every row stays equal
   height regardless of how many events land in it. Deliberately gated behind
   a min-width so phones/tablets keep the original content-sized rows instead
   of inheriting a desktop-scaled height that wouldn't fit their viewport. */
@media (min-width: 700px) {
  #schedule-calendar-grid {
    height: calc(100vh - 420px);
    min-height: 420px;
    grid-auto-rows: 1fr;
  }

  .schedule-calendar-day {
    min-height: 0;
  }
}

.schedule-calendar-day.schedule-day-outside-month {
  opacity: 0.35;
}

.schedule-calendar-day.schedule-day-today {
  border-color: var(--gold, #d4af37);
  border-width: 2px;
}

.schedule-calendar-day-number {
  font-size: 0.85rem;
}

.schedule-calendar-day-dot-row {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.schedule-calendar-day-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold, #d4af37);
}

.schedule-calendar-day-dot.schedule-day-dot-canceled {
  background: var(--muted);
}

#schedule-agenda-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.schedule-agenda-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--gold-dim, rgba(212, 175, 55, 0.15));
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.schedule-agenda-item-details {
  min-width: 0; /* allows the long-title/location truncation below to actually engage */
  flex: 1;
}

.schedule-agenda-item-details strong,
.schedule-agenda-item-details small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-agenda-item.schedule-event-canceled {
  opacity: 0.55;
}

.schedule-agenda-item.schedule-event-canceled strong {
  text-decoration: line-through;
}

#schedule-day-events-list,
#schedule-day-modal-inner .schedule-agenda-item {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Temporary mobile debug panel — see index.html for why this exists.
   Fixed, high z-index so it sits above everything including fullscreen
   video; toggle button stays a small out-of-the-way tap target until
   opened. Remove this block along with the panel markup once removed. */
#debug-toggle-btn {
  position: fixed;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 9999;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: none;
  background: var(--gold, #d4af37);
  color: #000;
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

#debug-panel {
  position: fixed;
  left: 0.5rem;
  right: 0.5rem;
  bottom: 3.25rem;
  z-index: 9999;
  max-height: 45vh;
  display: flex;
  flex-direction: column;
  background: #111;
  border: 1px solid #444;
  border-radius: 8px;
  overflow: hidden;
}

#debug-panel.hidden {
  display: none;
}

#debug-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: #1c1c1c;
  color: #eee;
  font-size: 0.8rem;
}

#debug-panel-header span {
  flex: 1;
}

#debug-panel-header button {
  background: none;
  border: 1px solid #555;
  color: #eee;
  border-radius: 4px;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
}

#debug-log-output {
  flex: 1;
  min-height: 8rem;
  resize: none;
  border: none;
  background: #0a0a0a;
  color: #7fffa0;
  font-family: monospace;
  font-size: 0.72rem;
  padding: 0.5rem;
  white-space: pre-wrap;
}

/* ---------- Team Highlights: team context, feed, publish picker ---------- */

#team-highlights-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#team-highlights-team-context {
  margin: 0.75rem 0 1rem;
}

#team-highlights-team-select {
  width: 100%;
  max-width: 320px;
}

#team-highlights-feed {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.team-highlight-card {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--gold-dim, rgba(212, 175, 55, 0.18));
  border-radius: 14px;
  padding: 0.75rem;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
}

.team-highlight-thumb {
  width: 84px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--bg-2);
  background-size: cover;
  background-position: center;
}

.team-highlight-info {
  flex: 1;
  min-width: 0;
}

.team-highlight-info p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.team-highlight-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

#team-highlights-publish-picker-list,
#personal-upload-team-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
  max-height: 50vh;
  overflow-y: auto;
}

#team-highlights-publish-picker-list li,
#personal-upload-team-list li {
  margin-bottom: 0.4rem;
}

#team-highlights-publish-picker-list button,
#personal-upload-team-list button {
  width: 100%;
  text-align: left;
}

.upload-hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.3rem 0 0;
}

@media (max-width: 600px) {
  .team-highlight-card {
    flex-wrap: wrap;
  }

  .team-highlight-actions {
    flex-direction: row;
    width: 100%;
  }
}

@media (max-width: 600px) {
  #create-team-modal-inner,
  #invite-modal-inner {
    padding: 1rem;
    max-height: 95vh;
  }
}