/* Task-centred shell: body stays fixed; only explicit work regions scroll. */
.is-workspace-session {
  width: 100%;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.is-workspace-session .app-view,
.is-workspace-session .sort-view,
.is-workspace-session .free-sort-view {
  animation: workspace-enter 180ms ease-out both;
}

.is-hub-open > .app-view,
.is-hub-open > .sort-view,
.is-hub-open > .free-sort-view {
  display: none !important;
}

.hub-view {
  width: min(100%, 980px);
  height: 100vh;
  height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
}

.is-hub-open .hub-view {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.hub-header {
  display: flex;
  min-height: 176px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: calc(34px + env(safe-area-inset-top, 0px)) 28px 26px;
  background: var(--ink);
  color: white;
}

.hub-header .eyebrow {
  color: #8eddbf;
}

.hub-header h1 {
  margin: 0;
  font-size: clamp(42px, 8vw, 68px);
  letter-spacing: -0.065em;
  line-height: 0.95;
}

.hub-header p:last-child {
  margin: 13px 0 0;
  color: #aebdb6;
  font-size: 13px;
}

.hub-task-list {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px 28px;
}

.hub-task-list > button {
  display: grid;
  width: 100%;
  min-height: 128px;
  grid-template-columns: 42px minmax(0, 1fr) minmax(90px, auto) 28px;
  gap: 18px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 20px 2px;
  text-align: left;
  transition: background 150ms ease, padding 150ms ease;
  animation: hub-task-enter 280ms ease-out both;
}

.hub-task-list > button:nth-child(2) {
  animation-delay: 45ms;
}

.hub-task-list > button:nth-child(3) {
  animation-delay: 90ms;
}

.hub-task-list > button:hover,
.hub-task-list > button:focus-visible {
  background: rgb(25 113 90 / 6%);
  padding-right: 10px;
  padding-left: 10px;
}

.hub-task-index {
  color: #8d9892;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
}

.hub-task-copy,
.hub-task-copy > * {
  display: block;
}

.hub-task-copy > small {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.hub-task-copy > strong {
  margin-bottom: 6px;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -0.045em;
}

.hub-task-copy > span {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
}

.hub-task-status {
  display: grid;
  justify-items: end;
  border-right: 2px solid var(--accent);
  padding-right: 12px;
}

.hub-task-status b {
  max-width: 140px;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hub-task-status small {
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 9px;
}

.hub-task-list > button > i {
  color: var(--accent);
  font-size: 23px;
  font-style: normal;
  transition: transform 150ms ease;
}

.hub-task-list > button:hover > i,
.hub-task-list > button:focus-visible > i {
  transform: translateX(4px);
}

.hub-footer {
  display: flex;
  min-height: calc(54px + var(--safe-bottom));
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 10px;
  padding: 10px 28px calc(10px + var(--safe-bottom));
}

.hub-footer i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.workspace-home-button {
  display: grid;
  width: 42px;
  min-width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 50%;
  background: transparent;
  color: white;
  cursor: pointer;
  font-size: 20px;
}

.workspace-home-button:hover,
.workspace-home-button:focus-visible {
  background: rgb(255 255 255 / 10%);
}

.workflow-stepper {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  border-bottom: 1px solid var(--line);
  list-style: none;
  padding: 0 2px 14px;
}

.workflow-stepper li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #8a9590;
  font-size: 10px;
  font-weight: 800;
}

.workflow-stepper li:not(:last-child)::after {
  position: absolute;
  z-index: 0;
  top: 50%;
  right: 8px;
  left: 40px;
  height: 1px;
  background: var(--line);
  content: "";
}

.workflow-stepper b {
  position: relative;
  z-index: 1;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.workflow-stepper li[aria-current="step"] {
  color: var(--accent-deep);
}

.workflow-stepper li[aria-current="step"] b {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.workflow-panels {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.workflow-panels > section {
  animation: workspace-enter 180ms ease-out both;
}

.workflow-instruction {
  max-width: 58ch;
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.workflow-import-summary {
  margin: 14px 0 0;
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 800;
}

.workflow-review {
  margin: 0;
  border-top: 1px solid var(--line);
}

.workflow-review > div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.workflow-review dt {
  color: var(--ink-soft);
  font-size: 11px;
}

.workflow-review dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.workflow-actions {
  display: flex;
  min-height: calc(68px + var(--safe-bottom));
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 8px 0 var(--safe-bottom);
}

.workflow-actions button {
  min-width: 126px;
  min-height: 48px;
}

.is-workspace-session .reference-view:not([hidden]) {
  display: grid;
  height: 100vh;
  height: 100svh;
  min-height: 0;
  grid-template-rows: auto 4px auto minmax(0, 1fr);
  overflow: hidden;
  padding-bottom: 0;
}

.reference-view > .reference-taskbar {
  grid-row: 3;
}

.reference-view > .reference-empty-state,
.reference-view > .reference-create-panel,
.reference-view > .reference-operation {
  min-height: 0;
  grid-row: 4;
}

.reference-empty-state {
  overflow: auto;
}

.reference-create-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.reference-create-panel > header {
  padding-bottom: 14px;
}

.reference-create-panel .workflow-panels {
  padding: 20px 2px;
}

.reference-operation {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.reference-workspace,
.reference-list-panel,
.reference-capture-panel {
  min-height: 0;
}

.reference-list-panel,
.reference-capture-panel {
  overflow: auto;
  overscroll-behavior: contain;
}

.reference-list-back {
  display: none;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--accent-deep);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  padding: 0;
  text-align: left;
}

.sort-view[data-mode="setup"],
.sort-view[data-mode="empty"] {
  display: flex;
  height: 100vh;
  height: 100svh;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

.sort-view[data-mode="setup"] .sort-topbar,
.sort-view[data-mode="empty"] .sort-topbar,
.sort-view[data-mode="setup"] > .sort-job-switcher,
.sort-view[data-mode="empty"] > .sort-job-switcher {
  flex: 0 0 auto;
}

.sort-view[data-mode="empty"] .sort-empty-state {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
}

.sort-view[data-mode="setup"] .sort-setup-panel {
  display: grid;
  width: min(100%, 1180px);
  min-height: 0;
  flex: 1 1 auto;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  margin: 0 auto;
  overflow: hidden;
  padding: 18px 24px 0;
}

.sort-workflow-stepper {
  padding-top: 4px;
}

.sort-setup-panel .sort-setup-grid,
.sort-setup-panel > .sort-analysis {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px 2px;
}

.sort-setup-panel .sort-setup-grid {
  display: block;
}

.sort-setup-panel[data-workflow-step="1"] [data-sort-step]:not([data-sort-step="1"]),
.sort-setup-panel[data-workflow-step="2"] [data-sort-step]:not([data-sort-step="2"]),
.sort-setup-panel[data-workflow-step="3"] [data-sort-step]:not([data-sort-step="3"]) {
  display: none !important;
}

.sort-setup-panel[data-workflow-step="3"] .sort-setup-grid {
  display: none;
}

.sort-setup-panel[data-workflow-step="3"] > .sort-analysis:not([hidden]) {
  display: block;
  margin-top: 0;
}

.sort-setup-panel .sort-import-column,
.sort-setup-panel .sort-plan-form {
  width: min(100%, 820px);
  margin: 0 auto;
}

.sort-plan-form-actions .sort-create-button {
  display: none;
}

.sort-workflow-actions {
  margin: 0 -24px;
  padding-right: 24px;
  padding-left: 24px;
}

@keyframes workspace-enter {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

@keyframes hub-task-enter {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
}
