/* ── Jobs view: list, player, results ─────────────────── */

.jobs { max-width: 1200px; margin: 0 auto; padding: 6px 20px 60px; }

.panel { padding: 0; }
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.panel-note { color: var(--faint); font-size: 10.5px; }

.prog { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ── error bar ── */

.joberr {
  display: flex; align-items: baseline; gap: 12px;
  margin: 0 0 10px; font-size: 11.5px; color: var(--text); flex-wrap: wrap;

  &.calm { color: var(--muted); & .joberr-msg::before { content: "· "; } }
}
.joberr-msg { flex: 1; min-width: 200px; &::before { content: "! "; } }

/* ── job transport ── */

.jobctl {
  display: inline-flex; gap: 6px; align-items: center; margin-left: auto;
  & button[hidden] { display: none; }
}

/* ── job list ── */

.joblist { display: flex; flex-direction: column; gap: 2px; }

/* ── day dividers ── */

.day-label {
  padding: 18px 0 6px; font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--dim); user-select: none;

  &:first-child { padding-top: 0; }
}

/* ── individual job row ── */

.job {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--r-ctl);
  border: 1px solid transparent;
  font-size: 12px; color: var(--muted); cursor: pointer;
  transition: color .12s;

  &:hover {
    color: var(--text); background: var(--panel);
    & .jthumb { opacity: 1; }
  }

  &.is-open {
    color: var(--text); background: var(--panel2);
    border-color: var(--line);
    border-bottom-left-radius: 0; border-bottom-right-radius: 0;
    & .jthumb { opacity: 1; }
  }

  & .jprompt {
    flex: 1; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; color: inherit;
  }
  & .jstat { font-size: 11px; color: var(--faint); white-space: nowrap; }
  & .blocks { flex: none; font-size: 11.5px; }
}

/* ── job thumbnail ── */

.jthumb {
  width: 30px; height: 30px; flex: none; overflow: hidden;
  opacity: .8; transition: opacity .12s; border-radius: 6px;
  background-image:
    linear-gradient(45deg, var(--chk-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--chk-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--chk-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--chk-b) 75%);
  background-color: var(--chk-a);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;

  & img { width: 100%; height: 100%; object-fit: contain; display: block; }
  &.empty-thumb { opacity: .35; }
}

/* ── inline detail panel (inserted after the open job row) ── */

#jobDetail {
  background: var(--panel2); border: 1px solid var(--line);
  border-top: 0; border-radius: 0 0 var(--r-ctl) var(--r-ctl);
  padding: 16px; margin-bottom: 4px;
  display: grid; grid-template-columns: 1fr 240px; gap: 16px;
  grid-template-rows: auto;
}

/* head spans full width */
.jd-head {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; min-height: 24px;
}

/* player + gallery in the left column */
#jobDetail > .joberr { grid-column: 1 / -1; }
#jobDetail > .player { grid-column: 1; grid-row: 3; }
#jobDetail > .gallery { grid-column: 1; grid-row: 3; }

/* side column: settings + layers + actions */
.jd-side {
  grid-column: 2; grid-row: 3;
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0;
}

/* compact settings key-value pairs */
.jd-info {
  display: flex; flex-wrap: wrap; gap: 2px 0;
}

.jd-kv {
  display: flex; align-items: baseline; gap: 4px;
  font-size: 11px; white-space: nowrap; width: 100%;
  padding: 2px 0;

  & .k {
    font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
    color: var(--dim); min-width: 52px;
  }
  & .v { color: var(--muted); }
}

.jd-actions {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: auto;
}

/* ── layer siblings ── */

.jd-layers {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}

.layer-thumb {
  width: 36px; height: 36px; border-radius: 6px; overflow: hidden;
  cursor: pointer; position: relative;
  border: 1px solid var(--line); opacity: .7;
  transition: opacity .12s;
  background: var(--panel);

  &:hover { opacity: 1; }
  &.active { opacity: 1; border-color: var(--acc); }

  & img { width: 100%; height: 100%; object-fit: contain; display: block; }
}

.layer-no {
  position: absolute; bottom: 1px; right: 3px;
  font-size: 8px; color: var(--faint); line-height: 1;
}

/* ── player ── */

.player { margin-bottom: 0; }

.stage {
  position: relative; overflow: hidden; border-radius: var(--r-card);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  display: grid; place-items: center;
  min-height: 160px; height: 36vh;

  & img {
    display: block; max-width: 100%; max-height: 36vh;
    object-fit: contain; transform-origin: 0 0; will-change: transform;
  }

  &.blank { background: #000; background-image: none; }
  &.grabbing { cursor: grabbing; }
}

#playerImg.pixel { image-rendering: pixelated; }

.notyet {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: 10px; letter-spacing: .22em; color: #555; pointer-events: none;
}

.stage-status {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 20px; pointer-events: none;
  font-size: 15px; letter-spacing: .06em; color: var(--ink);
  text-transform: uppercase; background: rgba(0, 0, 0, .45); z-index: 4;
  animation: textglow 2.4s ease-in-out infinite;

  &::after { content: ""; animation: dots 1.5s steps(4, end) infinite; }
}

@keyframes dots {
  0% { content: ""; } 25% { content: "."; }
  50% { content: ".."; } 75% { content: "..."; }
}

.buffer {
  margin-top: 6px; font-size: 11px; color: var(--dim);
  letter-spacing: -.5px; white-space: nowrap; overflow: hidden;
  & .on { color: var(--muted); }
}

/* ── transport ── */

.transport {
  display: flex; align-items: center; gap: 12px; margin-top: 8px;
  & .play { flex: none; }
  & .framebar {
    flex: 1; min-width: 60px; margin: 0; height: 14px;
    cursor: ew-resize; touch-action: none;
  }
}

.fps {
  background: none; border: 0; color: var(--faint);
  font-family: var(--mono); font-size: 10.5px; flex: none; cursor: pointer;
  &:focus { outline: none; color: var(--text); }
  & option { background: var(--panel); color: var(--text); }
}

/* ── frame bar ── */

.framebar {
  display: flex; gap: 1px; height: 16px; border-radius: 4px;
  overflow: hidden; cursor: pointer; align-items: stretch; user-select: none;

  & i {
    flex: 1 1 0; min-width: 1px; background: var(--dim); position: relative;

    &[data-s="ok"] { background: var(--acc); }
    &[data-s="fail"] {
      background: var(--dim);
      background-image: repeating-linear-gradient(45deg,
        var(--text) 0 1px, transparent 1px 3px);
    }
    &.now { animation: framepulse .9s steps(2, end) infinite; }
    &.at::after {
      content: ""; position: absolute; inset: -3px -1px;
      border: 1px solid var(--text); pointer-events: none;
    }
  }
}

@keyframes framepulse {
  0%, 49% { background: var(--acc); }
  50%, 100% { background: var(--dim); }
}

/* ── gallery ── */

.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 3px; margin-bottom: 0;

  & .cell {
    overflow: hidden; aspect-ratio: 1; border-radius: 6px;
    background-size: 12px 12px;
    background-position: 0 0, 0 6px, 6px -6px, -6px 0;
    opacity: .85; transition: opacity .12s;
    &:hover { opacity: 1; }
    & img { width: 100%; height: 100%; object-fit: contain; display: block; }
  }
}

/* ── responsive: stack on narrow screens ── */

@media (max-width: 700px) {
  #jobDetail {
    grid-template-columns: 1fr; gap: 12px;
  }
  #jobDetail > .player,
  #jobDetail > .gallery { grid-column: 1; grid-row: auto; }
  .jd-side { grid-column: 1; grid-row: auto; }

  .stage { height: 30vh; min-height: 140px; }
  .stage img { max-height: 30vh; }

  .transport { gap: 10px; }
  .transport .ghost, .transport .play { font-size: 14px; padding: 6px 2px; }
  .framebar { height: 22px; }
  .job { padding: 8px 0; }
  .jstat { font-size: 11px; }
  .tablewrap { margin: 0 -14px; padding: 0 14px; }
  .topups { gap: 10px; }
  .topups .topup { font-size: 14px; padding: 12px 6px; flex: 1 1 40%; }
}
