/* ============================================================================
   Prism — application layout
   ==========================================================================*/

/* One shell width and one gutter for the whole page. The topbar centres an
   inner bar while .layout carries its own padding, so the inner bar has to be
   narrowed by the gutters or the header sits wider than the panels below. */
:root {
  --shell-max: 1440px;
  --shell-pad: clamp(12px, 3vw, 28px);
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 12px var(--shell-pad) 0;
}
.topbar__inner {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(var(--shell-max) - var(--shell-pad) * 2);
  margin: 0 auto;
  padding: 9px 10px 9px 16px;
  border-radius: 999px;
}

.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand__mark { width: 26px; height: 26px; filter: drop-shadow(0 2px 5px rgba(0,0,0,.22)); }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__text strong { font-size: 15px; font-weight: 680; letter-spacing: -.02em; }
.brand__text span { font-size: 10.5px; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }

.topbar__status {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}
.topbar__status::-webkit-scrollbar { display: none; }

.topbar__actions { display: flex; gap: 7px; flex: none; }

.icon-sun, .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="light"] .icon-moon { display: block; }
:root:not([data-theme]) .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .icon-moon { display: none; }
  :root:not([data-theme]) .icon-sun { display: block; }
}

/* ---------------------------------------------------------------- layout */
.layout {
  display: grid;
  grid-template-columns: minmax(300px, 348px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 18px var(--shell-pad) 64px;
}

/* --------------------------------------------------------- settings panel */
.panel {
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 100px);
  border-radius: var(--radius-xl);
  overflow: hidden;
}
.panel__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--track) transparent;
}
.panel__scroll::-webkit-scrollbar { width: 8px; }
.panel__scroll::-webkit-scrollbar-thumb { background: var(--track); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
.panel__foot {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--glass-hairline);
}
.panel__foot .btn { flex: 1; }
.panel__foot .btn--primary { padding: 12px 18px; font-size: 14.5px; }

.group { display: flex; flex-direction: column; gap: 10px; }
.group__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 680;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-3);
}
.group__hint { font-size: 11.5px; line-height: 1.45; color: var(--ink-3); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

details.advanced { border-top: 1px solid var(--glass-hairline); padding-top: 14px; }
details.advanced > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  list-style: none;
  font-size: 11px;
  font-weight: 680;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-3);
}
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .25s var(--ease-glide);
}
details.advanced[open] > summary::before { transform: rotate(45deg); }
details.advanced > .group { margin-top: 14px; }

/* ------------------------------------------------------------- workspace */
.workspace { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 40px 24px;
  border-radius: var(--radius-xl);
  cursor: pointer;
  text-align: center;
  transition: transform .28s var(--ease-spring), box-shadow .28s;
}
.dropzone:hover { transform: translateY(-2px); }
.dropzone__ring {
  position: absolute;
  inset: 10px;
  z-index: 1;
  border-radius: calc(var(--radius-xl) - 8px);
  border: 1.6px dashed var(--field-edge);
  transition: border-color .25s, background .25s, opacity .25s;
  pointer-events: none;
}
.dropzone__icon {
  width: 40px; height: 40px;
  fill: none; stroke: url(#prism-grad) var(--spectrum-2);
  stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round;
  opacity: .85;
  transition: transform .3s var(--ease-spring);
}
.dropzone:hover .dropzone__icon { transform: translateY(-3px); }
.dropzone__title { font-size: 16.5px; font-weight: 640; letter-spacing: -.015em; }
.dropzone__hint { font-size: 12.5px; color: var(--ink-3); }
.dropzone .link { color: var(--spectrum-2); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

.dropzone.is-dragging { transform: scale(1.012); }
.dropzone.is-dragging .dropzone__ring {
  border-color: var(--spectrum-2);
  border-style: solid;
  background: color-mix(in oklab, var(--spectrum-2) 10%, transparent);
}
.dropzone.is-compact { padding: 20px 24px; }
.dropzone.is-compact .dropzone__icon { width: 26px; height: 26px; }
.dropzone.is-compact .dropzone__title { font-size: 14px; }
.dropzone.is-compact .dropzone__hint { display: none; }

/* ----------------------------------------------------------------- queue */
.queue-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 6px;
}
.queue-bar__info { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.queue-bar__info strong { font-size: 13.5px; font-weight: 620; }
.queue-bar__info span { font-size: 12px; color: var(--ink-3); }
.queue-bar__actions { display: flex; gap: 7px; flex: none; }
.queue-bar .btn { padding: 7px 14px; font-size: 13px; }

.queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }

.job {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  animation: job-in .38s var(--ease-glide) both;
}
@keyframes job-in { from { opacity: 0; transform: translateY(9px) scale(.985); } }

.job.is-done { box-shadow: inset 0 1px 0 0 var(--glass-inner-top), inset 0 0 0 1px color-mix(in oklab, var(--ok) 32%, transparent), var(--glass-shadow); }
.job.is-error { box-shadow: inset 0 1px 0 0 var(--glass-inner-top), inset 0 0 0 1px color-mix(in oklab, var(--bad) 38%, transparent), var(--glass-shadow); }

.job__head { display: flex; align-items: center; gap: 12px; min-width: 0; }

.job__icon {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  flex: none;
  border-radius: 12px;
  background: linear-gradient(150deg, color-mix(in oklab, var(--spectrum-1) 28%, transparent), color-mix(in oklab, var(--spectrum-2) 26%, transparent));
  border: 1px solid var(--field-edge);
}
.job__icon svg { width: 19px; height: 19px; fill: none; stroke: var(--ink-1); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .82; }

.job__id { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.job__name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.job__meta { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.job__badges { display: flex; gap: 6px; flex: none; align-items: center; }
.job__head .icon-btn { width: 28px; height: 28px; flex: none; }
.job__head .icon-btn svg { width: 14px; height: 14px; }

.job__route {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border-radius: var(--radius-md);
  background: var(--track);
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}
.job__route code { font-family: var(--font-mono); font-size: 11.5px; }
.job__route .arrow { color: var(--ink-3); }
.job__route strong { font-weight: 640; color: var(--ink-1); }

.job__progress { display: flex; align-items: center; gap: 11px; }
.bar {
  position: relative;
  flex: 1 1 auto;
  height: 7px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--spectrum-1), var(--spectrum-2) 60%, var(--spectrum-3));
  transition: width .3s var(--ease-glide);
}
.bar.is-indeterminate > span {
  width: 34% !important;
  animation: slide 1.25s var(--ease-glide) infinite;
}
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(330%); } }

.job__pct {
  flex: none;
  min-width: 42px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 560;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.job__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.job__status { font-size: 12px; color: var(--ink-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job__status.is-error { color: var(--bad); white-space: normal; }
.job__foot .btn { padding: 7px 15px; font-size: 13px; flex: none; }

.job__log {
  max-height: 128px;
  overflow: auto;
  margin: 0;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--track);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--ink-3);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ----------------------------------------------------------------- sheet */
.sheet {
  width: min(620px, calc(100vw - 32px));
  max-height: min(80vh, 760px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-xl);
  color: var(--ink-1);
  overflow: hidden;
}
.sheet::backdrop { background: rgba(6,8,16,.44); backdrop-filter: blur(4px); }
.sheet__body { padding: 24px 26px 8px; overflow-y: auto; max-height: calc(80vh - 84px); }
.sheet form { padding: 12px 26px 20px; display: flex; justify-content: flex-end; }
.sheet h3 { font-size: 17px; margin-bottom: 10px; }
.sheet h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 18px 0 8px; }
.sheet p { font-size: 13.5px; color: var(--ink-2); line-height: 1.6; }
.sheet ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); line-height: 1.65; }
.sheet code { font-family: var(--font-mono); font-size: 12px; background: var(--track); padding: 1px 5px; border-radius: 5px; }
.caps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ---------------------------------------------------------------- toasts */
.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(460px, calc(100vw - 32px));
}
.toast {
  padding: 11px 17px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 550;
  text-align: center;
  animation: toast-in .32s var(--ease-spring) both;
  pointer-events: auto;
  max-width: 100%;
}
.toast.is-error { color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.94); } }
.toast.is-leaving { animation: toast-out .26s var(--ease-glide) both; }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.96); } }

/* ------------------------------------------------------------ responsive */
@media (max-width: 940px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .panel { position: static; max-height: none; order: 2; }
  .panel__scroll { overflow: visible; max-height: none; }
  .workspace { order: 1; }
  .brand__text span { display: none; }
}

@media (max-width: 560px) {
  :root { --shell-pad: 10px; }
  .topbar { padding: 8px var(--shell-pad) 0; }
  .topbar__inner { padding: 8px 8px 8px 12px; }
  .layout { padding: 12px var(--shell-pad) 48px; gap: 12px; }
  .row-2 { grid-template-columns: 1fr; }
  .job__foot { flex-direction: column; align-items: stretch; }
  .job__foot .btn { width: 100%; }
}
