/*
 * Light-mode stage refinement
 *
 * The pearl studio artwork is intentionally very bright.  Without a local
 * contrast treatment it becomes a flat white rectangle and the glass controls
 * lose their hierarchy.  This layer only affects the authenticated light
 * stage; dark mode and all generation/session logic remain untouched.
 */

:root[data-theme="light"] body.jr-authenticated .workspace-main > .panel-right {
  background:
    linear-gradient(180deg, rgba(236, 245, 247, .88), rgba(215, 229, 232, .76)) !important;
  border-color: rgba(39, 84, 83, .16) !important;
  box-shadow:
    0 26px 68px rgba(62, 91, 96, .16),
    inset 0 1px 0 rgba(255, 255, 255, .92) !important;
}

:root[data-theme="light"] body.jr-authenticated .workspace-main > .panel-right::before {
  opacity: .34 !important;
  filter: saturate(.58) contrast(1.02) brightness(1.04) blur(1.5px) !important;
  background:
    radial-gradient(90% 72% at 50% 12%, rgba(255, 255, 255, .86), transparent 72%),
    linear-gradient(180deg, rgba(242, 249, 250, .90) 0%, rgba(226, 239, 242, .72) 48%, rgba(198, 218, 222, .66) 100%) !important;
}

:root[data-theme="light"] body.jr-authenticated .workspace-main > .panel-right::after {
  position: absolute;
  z-index: 0;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(175, 199, 204, .18), transparent 16%, transparent 84%, rgba(175, 199, 204, .16)),
    linear-gradient(180deg, transparent 58%, rgba(175, 199, 204, .16));
  border-radius: inherit;
  content: "";
  pointer-events: none;
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-primary {
  border-color: rgba(35, 87, 84, .30) !important;
  background: rgba(224, 237, 239, .58) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .96),
    0 22px 50px rgba(55, 87, 91, .22),
    0 0 0 6px rgba(255, 255, 255, .22) !important;
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-media {
  background: #dce9ec !important;
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-media::before {
  z-index: 0 !important;
  background:
    linear-gradient(180deg, rgba(228, 240, 243, .02), rgba(192, 216, 221, .12) 52%, rgba(110, 153, 164, .34)),
    url("../../assets/workspace-light-studio.jpg") center 48% / cover no-repeat !important;
  filter: saturate(.84) contrast(1.16) brightness(.88) !important;
  transform: scale(1.022) !important;
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-media::after {
  position: absolute;
  z-index: 1;
  inset: 0;
  background:
    radial-gradient(ellipse 58% 46% at 50% 44%, rgba(249, 253, 253, .16), transparent 70%),
    linear-gradient(90deg, rgba(116, 162, 171, .18), transparent 18%, transparent 82%, rgba(116, 162, 171, .16)),
    linear-gradient(180deg, rgba(230, 242, 244, .03), transparent 28%, transparent 68%, rgba(82, 132, 145, .24));
  border-radius: inherit;
  content: "";
  pointer-events: none;
}

:root[data-theme="light"] body.jr-authenticated #workspace-stage-video {
  z-index: 2 !important;
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-empty {
  z-index: 3 !important;
  background: linear-gradient(180deg, rgba(234, 245, 246, .10), rgba(180, 208, 214, .16)) !important;
  color: #15322e !important;
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-empty::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(58%, 580px);
  height: min(48%, 184px);
  border: 1px solid rgba(255, 255, 255, .64);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .30), rgba(235, 246, 247, .16)),
    radial-gradient(80% 120% at 50% 0%, rgba(255, 255, 255, .30), transparent 75%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .95),
    0 16px 34px rgba(43, 83, 86, .14),
    0 0 0 6px rgba(255, 255, 255, .09);
  backdrop-filter: blur(10px) saturate(1.06);
  -webkit-backdrop-filter: blur(10px) saturate(1.06);
  content: "";
  pointer-events: none;
  transform: translate(-50%, -50%);
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-empty > span,
:root[data-theme="light"] body.jr-authenticated .workspace-stage-empty h2,
:root[data-theme="light"] body.jr-authenticated .workspace-stage-empty p {
  position: relative;
  z-index: 1;
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-empty > span {
  color: #087455 !important;
  text-shadow: 0 1px 10px rgba(255, 255, 255, .78) !important;
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-empty h2 {
  color: #12332e !important;
  text-shadow: 0 1px 14px rgba(255, 255, 255, .88) !important;
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-empty p {
  color: #55736d !important;
  text-shadow: 0 1px 10px rgba(255, 255, 255, .66) !important;
}

/* Keep the empty state cinematic: give the stage a little more air before
   the first generation, while preserving the taller film strip once real
   tasks exist. */
@media (min-width: 721px) {
  :root[data-theme="light"] body.jr-authenticated .workspace-main > .panel-right:not(:has(.task-card)) {
    grid-template-rows: minmax(0, 1fr) 52px 108px !important;
  }

  :root[data-theme="light"] body.jr-authenticated .workspace-main > .panel-right:not(:has(.task-card)) .result-scroll {
    height: 108px !important;
    min-height: 108px !important;
  }
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-empty > span,
:root[data-theme="light"] body.jr-authenticated .workspace-stage-empty h2,
:root[data-theme="light"] body.jr-authenticated .workspace-stage-empty p {
  transform: translateY(-5px);
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-progress {
  border-color: rgba(34, 93, 82, .22) !important;
  background: rgba(248, 253, 252, .88) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .98),
    0 14px 32px rgba(48, 83, 82, .15) !important;
  backdrop-filter: blur(22px) saturate(1.16) !important;
  -webkit-backdrop-filter: blur(22px) saturate(1.16) !important;
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-toolbar {
  border-color: rgba(30, 87, 79, .18) !important;
  background: rgba(246, 252, 251, .86) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .96), 0 12px 26px rgba(49, 81, 82, .13) !important;
  color: #183630 !important;
}

:root[data-theme="light"] body.jr-authenticated .workspace-stage-toolbar button,
:root[data-theme="light"] body.jr-authenticated .workspace-stage-toolbar a {
  border-color: rgba(28, 91, 79, .16) !important;
  background: rgba(255, 255, 255, .66) !important;
  color: #31534c !important;
}

:root[data-theme="light"] body.jr-authenticated .result-head {
  background: rgba(239, 247, 248, .94) !important;
  border-top: 1px solid rgba(255, 255, 255, .78) !important;
  color: #173832 !important;
}

:root[data-theme="light"] body.jr-authenticated .result-scroll,
:root[data-theme="light"] body.jr-authenticated .result-scroll:has(.task-card) {
  background: linear-gradient(180deg, rgba(226, 239, 241, .86), rgba(235, 245, 246, .94)) !important;
}

:root[data-theme="light"] body.jr-authenticated .result-scroll .idle-hint {
  align-self: stretch !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  height: 84px !important;
  min-height: 84px !important;
  margin: 0 !important;
  padding: 16px 22px !important;
  border: 1px solid rgba(48, 100, 96, .14) !important;
  border-radius: 16px !important;
  background: rgba(248, 252, 252, .78) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .92), 0 10px 24px rgba(55, 89, 91, .08) !important;
  text-align: left !important;
}

:root[data-theme="light"] body.jr-authenticated .result-scroll .idle-hint h3 {
  margin: 0 0 5px !important;
  font-size: 14px !important;
}

:root[data-theme="light"] body.jr-authenticated .result-scroll .idle-hint p {
  max-width: none !important;
  margin: 0 !important;
  font-size: 10px !important;
  line-height: 1.55 !important;
}

@media (max-width: 720px) {
  :root[data-theme="light"] body.jr-authenticated .workspace-stage-media::before {
    background-position: 52% 48% !important;
    filter: saturate(.74) contrast(1.08) brightness(.92) !important;
  }
  :root[data-theme="light"] body.jr-authenticated .workspace-stage-media::after {
    background:
      radial-gradient(ellipse 76% 50% at 50% 48%, rgba(249, 253, 253, .18), transparent 74%),
      linear-gradient(180deg, rgba(227, 241, 243, .06), transparent 38%, rgba(145, 181, 188, .20));
  }

  :root[data-theme="light"] body.jr-authenticated .workspace-stage-empty::before {
    width: min(82%, 440px);
    height: min(50%, 176px);
    border-radius: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root[data-theme="light"] body.jr-authenticated .workspace-main > .panel-right::before {
    transition: none !important;
  }
}

/* Result strip overlap guard --------------------------------------------
 * The compact empty-state rows used to give `.result-head` only 32–34px.
 * The title, filter tabs and status pill are taller than that, so they could
 * paint into the film strip below (especially on a fresh workspace). Keep
 * the row sized to its controls and let the stage absorb the remaining
 * height. This is layout-only; task state and generation logic are unchanged.
 */
body.jr-authenticated .workspace-main > .panel-right {
  grid-template-rows: minmax(0, 1fr) 52px 108px !important;
}

body.jr-authenticated .workspace-main > .panel-right .result-head {
  min-height: 52px !important;
  height: auto !important;
  box-sizing: border-box !important;
  align-items: center !important;
  overflow: visible !important;
  padding: 7px 14px !important;
}

body.jr-authenticated .workspace-main > .panel-right .result-tabs {
  min-height: 38px !important;
  align-items: center !important;
  flex-shrink: 0 !important;
}

body.jr-authenticated .workspace-main > .panel-right .result-scroll {
  height: auto !important;
  min-height: 108px !important;
  box-sizing: border-box !important;
}

@media (max-width: 720px) {
  body.jr-authenticated .workspace-main > .panel-right {
    grid-template-rows: minmax(0, 1fr) 84px 108px !important;
  }

  body.jr-authenticated .workspace-main > .panel-right .result-head {
    min-height: 84px !important;
    height: auto !important;
    flex-wrap: wrap !important;
    align-content: center !important;
    gap: 6px !important;
    padding: 10px 12px !important;
  }

  body.jr-authenticated .workspace-main > .panel-right .result-tabs {
    order: 3 !important;
    width: 100% !important;
    margin: 0 !important;
    justify-content: space-between !important;
  }

  body.jr-authenticated .workspace-main > .panel-right .result-scroll {
    height: 108px !important;
    min-height: 108px !important;
  }
}
