/* media pane — the living room TV hub and remote. Tokens and shared primitives
   only. Layout unique to this surface; @media breakpoints mirror the app. */

.pane-media {
  align-items: start;
}

/* ---------- now playing hero ------------------------------------------------ */
.media-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
}

.media-art {
  width: 88px;
  height: 88px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
}
.media-art .ic {
  width: 34px;
  height: 34px;
  stroke-width: 1.25;
}

.media-now {
  min-width: 0;
}
.media-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-title {
  margin-top: 3px;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.media-meta {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

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

/* ---------- transport ------------------------------------------------------- */
.media-transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.media-key {
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
}
.media-key .ic {
  width: 18px;
  height: 18px;
}
.media-play {
  width: 52px;
  height: 52px;
  border-color: var(--line-2);
  background: var(--surface-2);
}
.media-play.is-playing {
  color: var(--accent);
}
.media-play:hover:not(:disabled) {
  border-color: var(--accent);
}

/* ---------- volume ---------------------------------------------------------- */
.media-volume {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.media-mute {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 999px;
}
.media-range {
  flex: 1;
  min-width: 0;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}
.media-range:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.vol-pct {
  min-width: 40px;
  text-align: right;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- source ---------------------------------------------------------- */
.media-source {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.media-source > span {
  font-size: 12px;
  color: var(--text-2);
  flex: none;
}
.media-source .input {
  max-width: 260px;
}

/* ---------- activities ------------------------------------------------------ */
.media-activities {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.media-activity {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
}
.media-activity .ic {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

/* ---------- detail control tab --------------------------------------------- */
.media-control-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.media-control-note {
  font-size: 12px;
  color: var(--muted);
  margin-left: 2px;
}
.media-control-remote {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 24px;
}
.media-compact-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 8px;
}
.media-compact-row .btn {
  height: 44px;
  justify-content: center;
}

/* ---------- advanced -------------------------------------------------------- */
.media-entity > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
  list-style: none;
}
.media-entity:first-of-type > summary {
  border-top: 0;
}
.media-entity > summary::-webkit-details-marker {
  display: none;
}
.media-entity > summary .chev {
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--muted);
  transition: transform var(--fast) var(--ease);
}
.media-entity[open] > summary .chev {
  transform: rotate(90deg);
}
.media-entity-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-entity-id {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-entity > summary .diag-value {
  margin-left: auto;
  flex: none;
}
.media-attr-grid {
  padding: 4px 0 8px 21px;
}
.media-foot {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
  max-width: 72ch;
}

/* ---------- remote overlay -------------------------------------------------- */
.remote-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg-deep) 72%, transparent);
}
.remote-panel {
  width: min(880px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  padding: 24px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  background: var(--surface);
  overscroll-behavior: contain;
}
.remote-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.remote-head h2 {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.remote-head .icon-btn {
  margin-left: auto;
  width: 36px;
  height: 36px;
  flex: none;
}
.remote-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 24px;
}
.remote-col {
  min-width: 0;
}
.remote-section {
  margin-top: 14px;
}
.remote-section-label {
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--muted);
}
.remote-grid {
  display: grid;
  gap: 8px;
}
.remote-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.remote-grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.remote-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.remote-wide {
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 8px;
  min-width: 0;
  white-space: normal;
  text-align: center;
  line-height: 1.2;
}
.remote-wide .ic {
  width: 15px;
  height: 15px;
  flex: none;
}
.remote-acts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.remote-act {
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 12px;
}
.remote-act .ic {
  width: 13px;
  height: 13px;
  color: var(--accent);
  flex: none;
}

.remote-dpad {
  display: grid;
  grid-template-columns: repeat(3, 68px);
  grid-template-rows: repeat(3, 68px);
  gap: 8px;
  justify-content: center;
  margin: 0 auto;
}
.remote-key {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
    transform var(--fast) var(--ease);
}
.remote-key:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--accent);
}
.remote-key:active:not(:disabled) {
  transform: scale(0.97);
}
.remote-key:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.remote-key .ic {
  width: 22px;
  height: 22px;
}
.remote-key.up { grid-area: 1 / 2; }
.remote-key.left { grid-area: 2 / 1; }
.remote-key.ok {
  grid-area: 2 / 2;
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}
.remote-key.right { grid-area: 2 / 3; }
.remote-key.down { grid-area: 3 / 2; }

.remote-numbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.remote-numbers .btn {
  height: 48px;
  font-family: var(--mono);
  font-size: 15px;
}

.remote-text {
  display: flex;
  gap: 8px;
}
.remote-text .input {
  flex: 1;
  min-width: 0;
  height: 44px;
}
.remote-text .btn {
  height: 44px;
  flex: none;
}

.remote-panel .notice {
  margin-top: 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- responsive ------------------------------------------------------ */
@media (max-width: 900px) {
  .media-hero {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 16px;
  }
  .media-hero-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
  .media-hero-actions .btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
  }
}

@media (max-width: 760px) {
  .media-art {
    width: 64px;
    height: 64px;
  }
  .media-art .ic {
    width: 26px;
    height: 26px;
  }
  .media-title {
    font-size: 21px;
  }
  .media-transport {
    gap: 6px;
    justify-content: space-between;
  }
  .media-key {
    width: 46px;
    height: 46px;
  }
  .media-play {
    width: 54px;
    height: 54px;
  }
  .media-source {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .media-source .input {
    max-width: none;
    width: 100%;
    height: 40px;
  }
  .media-activity {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
  }
  .media-control-remote {
    gap: 16px;
  }
  .media-entity-id {
    display: none;
  }
  .media-attr-grid {
    padding-left: 0;
  }

  .remote-overlay {
    padding: 10px;
  }
  .remote-panel {
    max-height: calc(100dvh - 20px);
    padding: 16px;
    border-radius: var(--r-lg);
  }
  .remote-dpad {
    grid-template-columns: repeat(3, 58px);
    grid-template-rows: repeat(3, 58px);
    gap: 6px;
  }
  .remote-key {
    min-height: 52px;
  }
  .remote-grid.cols-3,
  .remote-grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .remote-grid.cols-3 .remote-wide,
  .remote-grid.cols-4 .remote-wide {
    min-height: 46px;
  }
  .remote-act {
    justify-content: center;
  }
  .remote-text {
    flex-wrap: wrap;
  }
  .remote-text .input {
    flex: 1 1 100%;
  }
  .remote-text .btn {
    flex: 1 1 100%;
  }
}

@media (max-width: 420px) {
  .media-activity {
    flex-basis: 100%;
  }
  .remote-acts {
    grid-template-columns: 1fr;
  }
}
