/* =========================================================
   BRIX · CURATED KNOWLEDGE
   VIEWPORT WORKSTATION LAYOUT
   ---------------------------------------------------------
   Desktop / landscape:
   Search + Record + Sources left, Results right.
   Whole workstation fits inside viewport; Results scroll.
   Portrait tablet / mobile:
   Natural stacked flow with page scrolling.
   ========================================================= */

.ck-workstation{
  min-width:0;
  height:calc(100dvh - 24px);
  min-height:560px;
  display:grid;
  grid-template-rows:auto minmax(0,1fr) auto;
  overflow:hidden;
}

.ck-header{
  flex:0 0 auto;
}

.ck-main{
  min-width:0;
  min-height:0;
  display:grid;
  grid-template-columns:minmax(330px,36%) minmax(0,64%);
  gap:12px;
  padding:12px 14px;
  overflow:hidden;
}

.ck-left{
  min-width:0;
  min-height:0;
  display:grid;
  grid-template-rows:auto minmax(0,1fr) auto;
  gap:10px;
  overflow:hidden;
}

.ck-panel,
.ck-right{
  min-width:0;
  border:1px solid var(--mb-line);
  border-radius:9px;
  background:var(--mb-panel2);
}

.ck-panel{
  padding:12px;
}

.ck-panel-title{
  color:#fff;
  font-size:.76rem;
  font-weight:600;
  letter-spacing:.01em;
}

.ck-search-panel{
  flex:0 0 auto;
}

.ck-search-help{
  margin:5px 0 10px;
  color:var(--mb-muted);
  font-size:.62rem;
  line-height:1.4;
}

.ck-search-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) 92px;
  gap:8px;
}

.ck-search-row input{
  width:100%;
  min-width:0;
  height:40px;
  border:1px solid rgba(255,255,255,.22);
  border-radius:7px;
  background:#06141d;
  color:#fff;
  padding:0 12px;
  outline:none;
  font-size:.72rem;
}

.ck-search-row input:focus{
  border-color:rgba(255,138,0,.72);
  box-shadow:0 0 0 2px rgba(255,138,0,.08);
}

.ck-search-row button{
  height:40px;
  border:1px solid rgba(255,138,0,.7);
  border-radius:7px;
  background:rgba(255,138,0,.11);
  color:#fff;
  cursor:pointer;
  font-size:.66rem;
}

.ck-search-row button:hover{
  color:var(--mb-orange);
  border-color:var(--mb-orange);
}

.ck-status{
  min-height:15px;
  margin-top:8px;
  color:var(--mb-faint);
  font-size:.57rem;
  line-height:1.3;
}

.ck-status.is-error{
  color:#ffb36b;
}

/* Selected record */
.ck-record-panel{
  min-height:0;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.ck-detail{
  min-height:0;
  margin-top:8px;
  overflow:auto;
  padding-right:3px;
}

.ck-detail .mb-detail-empty{
  min-height:90px;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  color:var(--mb-faint);
  font-size:.64rem;
  line-height:1.45;
}

.ck-detail .mb-detail-type{
  color:var(--mb-orange);
  font-size:.56rem;
  margin-bottom:5px;
}

.ck-detail h2{
  margin:0 0 10px;
  color:#fff;
  font-size:.9rem;
  line-height:1.3;
}

.ck-detail .mb-detail-location{
  color:var(--mb-muted);
  font-size:.63rem;
  line-height:1.55;
}

.ck-detail .mb-detail-description{
  margin-top:10px;
  color:var(--mb-muted);
  font-size:.62rem;
  line-height:1.45;
}

.ck-detail .mb-tags{
  display:flex;
  flex-wrap:wrap;
  gap:5px;
  margin-top:10px;
}

.ck-detail .mb-tag{
  font-size:.53rem;
}

/* Source documents */
.ck-source-panel{
  flex:0 0 auto;
}

.ck-source-documents{
  margin-top:8px;
}

.ck-source-empty{
  color:var(--mb-faint);
  font-size:.6rem;
  line-height:1.4;
}

.ck-source-card{
  border:1px solid var(--mb-soft);
  border-radius:7px;
  background:rgba(255,255,255,.018);
  padding:9px;
}

.ck-source-name{
  color:#fff;
  font-size:.66rem;
  font-weight:600;
}

.ck-source-meta{
  margin-top:3px;
  color:var(--mb-faint);
  font-size:.56rem;
  line-height:1.35;
}

.ck-source-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:7px;
  margin-top:8px;
}

.ck-source-actions a{
  min-height:31px;
  border:1px solid rgba(255,138,0,.48);
  border-radius:6px;
  background:rgba(255,138,0,.07);
  color:#fff;
  text-decoration:none;
  font-size:.57rem;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:5px 7px;
}

.ck-source-actions a:hover{
  color:var(--mb-orange);
  border-color:var(--mb-orange);
}

/* Results workstation */
.ck-right{
  min-height:0;
  display:grid;
  grid-template-rows:auto minmax(0,1fr);
  overflow:hidden;
}

.ck-results-head{
  min-width:0;
  padding:11px 12px 9px;
  border-bottom:1px solid var(--mb-line);
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:10px;
}

.ck-filters{
  max-width:65%;
  justify-content:flex-end;
}

.ck-results{
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  border:0;
  border-radius:0;
  background:transparent;
  padding:7px;
}

.ck-results .mb-result{
  padding:10px 11px;
}

.ck-results .mb-result.is-selected{
  background:rgba(255,138,0,.06);
  box-shadow:inset 2px 0 0 rgba(255,138,0,.75);
}

.ck-footer{
  flex:0 0 auto;
}

/* Hide old visible collection/viewer surfaces entirely.
   IDs remain mounted only so the existing engine stays undisturbed. */
#ck-library-stage[hidden],
#ck-viewer-stage[hidden]{
  display:none !important;
}

/* =========================================================
   MID-WIDTH / LANDSCAPE TABLET
   Still fit-to-viewport.
   ========================================================= */
@media(max-width:1100px) and (min-width:821px){
  .ck-main{
    grid-template-columns:minmax(300px,39%) minmax(0,61%);
    gap:10px;
    padding:10px 12px;
  }

  .ck-panel{
    padding:10px;
  }

  .ck-search-row{
    grid-template-columns:minmax(0,1fr) 82px;
  }

  .ck-filters{
    max-width:58%;
  }
}

/* =========================================================
   PORTRAIT TABLET / MOBILE
   Stacked natural flow. Results drop below left.
   Page scrolling is intentional here.
   ========================================================= */
@media(max-width:820px){
  html,
  body{
    height:auto;
    min-height:100%;
    overflow:auto;
  }

  .ck-workstation{
    height:auto;
    min-height:100vh;
    display:block;
    overflow:visible;
  }

  .ck-main{
    display:flex;
    flex-direction:column;
    gap:10px;
    padding:10px;
    overflow:visible;
  }

  .ck-left{
    display:flex;
    flex-direction:column;
    gap:10px;
    overflow:visible;
  }

  .ck-record-panel{
    min-height:180px;
    overflow:visible;
  }

  .ck-detail{
    overflow:visible;
  }

  .ck-right{
    min-height:460px;
    display:block;
    overflow:visible;
  }

  .ck-results{
    max-height:none;
    overflow:visible;
  }

  .ck-results-head{
    align-items:flex-start;
    flex-direction:column;
  }

  .ck-filters{
    max-width:none;
    justify-content:flex-start;
  }
}

@media(max-width:520px){
  .ck-search-row{
    grid-template-columns:1fr;
  }

  .ck-search-row button{
    height:38px;
  }

  .ck-source-actions{
    grid-template-columns:1fr;
  }

  .ck-main{
    padding:8px;
  }
}
