/* ==========================================================================
   Wiki Styles (Contacts & Places, Grid & Cards, Avatars)
   ========================================================================== */

.wiki-container{
  display:flex;
  flex-direction:column;
  gap:16px;
  width:100%;
  height:100%;
  min-height:0;
}

.wiki-subnav{
  display:flex;
  flex-direction:column;
  gap:12px;
  padding-top:4px;
  padding-bottom:8px;
  border-bottom:none;
  width:100%;
}

.wiki-subnav-top{
  display:flex;
  align-items:center;
  gap:12px;
  width:100%;
}

.wiki-search-box{
  flex:1;
  position:relative;
  display:flex;
  align-items:center;
  gap:12px;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-full);
  padding:0 16px;
  height:48px;
  width:100%;
  box-sizing:border-box;
  min-width:0;
  cursor:text;
  box-shadow:var(--md-sys-elevation-level1);
  transition:all var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-effects);
}

.wiki-search-box:focus-within{
  background:var(--md-sys-color-surface-container-highest);
  border-color:var(--md-sys-color-primary);
  box-shadow:0 0 0 2px var(--accent-subtle), var(--md-sys-elevation-level2);
}

.wiki-search-icon{
  color:var(--md-sys-color-on-surface-variant);
  width:20px;
  height:20px;
  flex-shrink:0;
}

.wiki-search-input{
  background:none;
  border:0;
  outline:none;
  font:var(--md-sys-typescale-body-large);
  color:var(--md-sys-color-on-surface);
  width:100%;
  padding:0;
}

.wiki-search-input::placeholder{
  color:var(--md-sys-color-on-surface-variant);
  opacity:0.8;
}

.wiki-search-clear-btn{
  background:none;
  border:0;
  color:var(--md-sys-color-on-surface-variant);
  cursor:pointer;
  padding:6px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:var(--md-sys-shape-corner-full);
  transition:all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-fast);
}

.wiki-search-clear-btn:hover{
  color:var(--md-sys-color-on-surface);
  background:rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
  transform:scale(1.1);
}

.wiki-controls-wrap{
  display:flex;
  align-items:center;
  gap:8px;
  flex-shrink:0;
  align-self:center;
}

.wiki-categories-bar{
  position:relative;
  display:flex;
  gap:4px;
  align-items:center;
  background:var(--md-sys-color-surface-container-low);
  padding:4px;
  border-radius:var(--md-sys-shape-corner-full);
  border:1px solid var(--md-sys-color-outline-variant);
  box-shadow:var(--md-sys-elevation-level1);
  overflow-x:auto;
  width:100%;
  box-sizing:border-box;
  margin-top:8px;
  scrollbar-width:none;
}
.wiki-categories-bar::-webkit-scrollbar{
  display:none;
}

/* Sliding active indicator for lateral displacement */
.wiki-cat-indicator{
  position:absolute;
  top:4px;
  left:0;
  height:calc(100% - 8px);
  background:var(--md-sys-color-secondary-container);
  border-radius:var(--md-sys-shape-corner-full);
  box-shadow:var(--md-sys-elevation-level1);
  pointer-events:none;
  z-index:1;
  transition:transform 240ms cubic-bezier(0.2, 0, 0, 1),
              width 240ms cubic-bezier(0.2, 0, 0, 1),
              opacity var(--md-sys-motion-duration-short2) ease;
  will-change:transform, width;
  opacity:0;
}

@keyframes wikiFadeDown{
  from{opacity:0; transform:translateY(-4px);}
  to{opacity:1; transform:translateY(0);}
}

/* Directional lateral transitions when switching categories */
@keyframes wikiSlideFromRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes wikiSlideFromLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.wiki-content.wiki-slide-right {
  animation: wikiSlideFromRight 240ms cubic-bezier(0.2, 0, 0, 1);
}

.wiki-content.wiki-slide-left {
  animation: wikiSlideFromLeft 240ms cubic-bezier(0.2, 0, 0, 1);
}

.wiki-cat-pill{
  flex:1;
  justify-content:center;
  text-align:center;
  background:none;
  border:0;
  color:var(--md-sys-color-on-surface-variant);
  padding:0 16px;
  height:40px;
  border-radius:var(--md-sys-shape-corner-full);
  font:var(--md-sys-typescale-label-large);
  font-weight:600;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap:8px;
  white-space:nowrap;
  transition:color var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
  user-select:none;
  box-sizing:border-box;
  position:relative;
  z-index:2;
}
.wiki-cat-pill svg{
  width:18px;
  height:18px;
  flex-shrink:0;
}

.wiki-cat-pill:hover{
  color:var(--md-sys-color-on-surface);
}

.wiki-cat-pill:hover:not(.active){
  background:rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

.wiki-cat-pill:active{
  transform:scale(0.97);
}

.wiki-cat-pill.active{
  color:var(--md-sys-color-on-secondary-container);
  font:var(--md-sys-typescale-label-large);
  font-weight:600;
  background:transparent !important;
  box-shadow:none !important;
}

.wiki-cat-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:20px;
  height:20px;
  padding:0 6px;
  border-radius:var(--md-sys-shape-corner-full);
  font:var(--md-sys-typescale-label-small-emphasized);
  background:var(--md-sys-color-surface-container-highest);
  color:var(--md-sys-color-on-surface-variant);
  line-height:1;
  transition:all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
}
.wiki-cat-pill.active .wiki-cat-badge{
  background:var(--md-sys-color-on-secondary-container);
  color:var(--md-sys-color-secondary-container);
}

.wiki-add-wrap{
  position:relative;
}

.wiki-add-btn{
  position:relative;
  background:var(--md-sys-color-primary);
  color:var(--md-sys-color-on-primary);
  border:0 !important;
  outline:none;
  width:48px;
  height:48px;
  padding:0;
  border-radius:var(--md-sys-shape-corner-full);
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
  box-sizing:border-box;
  box-shadow:var(--md-sys-elevation-level1);
  transition:transform var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-fast),
              opacity var(--md-sys-motion-duration-short2) ease;
}
.wiki-add-btn svg{
  width:22px;
  height:22px;
  flex-shrink:0;
}
.wiki-add-btn::after{
  content:"";
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%, -50%);
  min-width:48px;
  min-height:48px;
  width:100%;
  height:100%;
}

.wiki-add-btn:hover{
  opacity:.92;
  transform:scale(1.05);
  box-shadow:var(--md-sys-elevation-level2);
}

.wiki-add-menu{
  position:absolute;
  top:calc(100% + 6px);
  right:0;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  box-shadow:var(--md-sys-elevation-level3);
  border-radius:var(--md-sys-shape-corner-large);
  padding:8px;
  min-width:200px;
  z-index:100;
  display:none;
  flex-direction:column;
  gap:4px;
}

.wiki-add-menu.show{
  display:flex !important;
}

.wiki-add-menu-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 12px;
  border-radius:var(--md-sys-shape-corner-medium);
  font:var(--md-sys-typescale-label-large);
  color:var(--md-sys-color-on-surface);
  cursor:pointer;
  transition:all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
  background:none;
  border:0;
  width:100%;
  text-align:left;
}

.wiki-add-menu-item:hover{
  background:rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

.wiki-add-item-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color:var(--md-sys-color-on-surface-variant);
  width:18px;
  height:18px;
}

.wiki-content-wrap{
  position:relative;
  display:flex;
  flex-direction:column;
  flex:1;
  min-height:0;
  overflow:hidden;
  width:100%;
  box-sizing:border-box;
}

.wiki-content-wrap:has(.calendar-root),
.wiki-content-wrap:has(.has-calendar){
  overflow:visible;
}

.wiki-scroll-fade{
  position:absolute;
  left:0;
  right:0;
  height:32px;
  pointer-events:none;
  z-index:10;
  opacity:0;
  transition:opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-effects);
}

.wiki-scroll-fade-top{
  top:0;
  background:linear-gradient(to bottom, var(--md-sys-color-surface) 0%, rgba(0,0,0,0) 100%);
}

.wiki-scroll-fade-bottom{
  bottom:0;
  background:linear-gradient(to top, var(--md-sys-color-surface) 0%, rgba(0,0,0,0) 100%);
}

.wiki-content-wrap.can-scroll-up .wiki-scroll-fade-top{
  opacity:1;
}

.wiki-content-wrap.can-scroll-down .wiki-scroll-fade-bottom{
  opacity:1;
}

.wiki-content{
  flex:1;
  overflow-y:auto;
  overflow-x:hidden;
  min-height:0;
  display:flex;
  flex-direction:column;
  padding:8px 6px 20px 6px;
  margin-top:-6px;
  box-sizing:border-box;
}

.wiki-content:has(.calendar-root),
.wiki-content.has-calendar{
  overflow-y:hidden !important;
  padding-bottom:2px !important;
}

.wiki-content:has(.calendar-root) .wiki-grid,
.wiki-content.has-calendar .wiki-grid{
  height:100% !important;
  display:flex !important;
  flex-direction:column !important;
  flex:1 !important;
  min-height:0 !important;
}

.wiki-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(280px, 1fr));
  gap:16px;
  width:100%;
  box-sizing:border-box;
}

@media (max-width: 599px){
  .wiki-grid{
    grid-template-columns:1fr;
    gap:12px;
  }
}

@media (min-width: 600px) and (max-width: 839px){
  .wiki-grid{
    grid-template-columns:repeat(2, 1fr);
    gap:14px;
  }
}

@media (min-width: 840px) and (max-width: 1199px){
  .wiki-grid{
    grid-template-columns:repeat(auto-fill, minmax(260px, 1fr));
    gap:16px;
  }
}

@media (min-width: 1200px){
  .wiki-grid{
    grid-template-columns:repeat(auto-fill, minmax(280px, 1fr));
    gap:20px;
  }
}

/* M3 Elevated Wiki Cards (CornerLargeIncreased 20px) */
.wiki-card{
  background:var(--md-sys-color-surface-container-low);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-large-increased);
  padding:18px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:12px;
  box-shadow:var(--md-sys-elevation-level1);
  transition:transform var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-fast),
              box-shadow var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-effects),
              border-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-effects);
  cursor:pointer;
  position:relative;
  box-sizing:border-box;
  will-change:transform, box-shadow;
  backface-visibility:hidden;
  -webkit-backface-visibility:hidden;
}
.wiki-card:hover{
  border-color:var(--md-sys-color-outline);
  transform:translateY(-3px) scale(1.015);
  box-shadow:var(--md-sys-elevation-level2);
  z-index:5;
}
.wiki-card.pinned,
.wiki-card.starred,
.wiki-card.favorite{
  border-top-left-radius:var(--md-sys-shape-corner-extra-large);
  border-color:var(--md-sys-color-tertiary);
}

.wiki-card-top{
  display:flex;
  align-items:center;
  gap:12px;
  width:100%;
}

.wiki-avatar-box{
  position:relative;
  width:48px;
  height:48px;
  border-radius:var(--md-sys-shape-corner-full);
  flex-shrink:0;
  overflow:hidden;
  background:var(--md-sys-color-primary-container);
  border:2px solid var(--md-sys-color-primary);
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow:var(--md-sys-elevation-level1);
}
.wiki-avatar-img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
  border-radius:var(--md-sys-shape-corner-full);
}
.wiki-avatar-svg{
  width:100%;
  height:100%;
  display:block;
}
.wiki-avatar-overlay{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,.52);
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:0;
  pointer-events:none;
  transition:opacity .18s ease;
  border-radius:var(--md-sys-shape-corner-full);
  color:#fff;
  cursor:pointer;
}
.wiki-avatar-box:hover .wiki-avatar-overlay{
  opacity:1;
  pointer-events:auto;
}
.wiki-avatar-edit-icon{
  width:18px;
  height:18px;
  fill:currentColor;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,.4));
}

.wiki-card-header-body{
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:3px;
  flex:1;
  min-width:0;
}
.wiki-card-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
.wiki-card-title-wrap{
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width:0;
}
.wiki-card-title{
  font:var(--md-sys-typescale-title-medium-emphasized);
  color:var(--md-sys-color-on-surface);
  line-height:1.3;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.wiki-card-subtitle{
  font:var(--md-sys-typescale-body-small);
  color:var(--md-sys-color-on-surface-variant);
  line-height:1.2;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.wiki-badge{
  display:inline-block;
  font:var(--md-sys-typescale-label-small);
  padding:3px 8px;
  border-radius:var(--md-sys-shape-corner-extra-small);
  background:var(--md-sys-color-surface-container-highest);
  color:var(--md-sys-color-on-surface);
  white-space:nowrap;
}
.wiki-card-meta{
  display:flex;
  flex-direction:column;
  gap:4px;
  font:var(--md-sys-typescale-body-small);
  color:var(--md-sys-color-on-surface-variant);
}
.wiki-card-meta:empty{
  display:none;
}
.wiki-meta-row{
  display:flex;
  align-items:center;
  gap:6px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.wiki-card-notes{
  font:var(--md-sys-typescale-body-small);
  line-height:1.45;
  color:var(--md-sys-color-on-surface);
  opacity:.85;
  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
  overflow:hidden;
  padding-top:8px;
  border-top:1px dashed var(--md-sys-color-outline-variant);
  margin-top:auto;
}
.wiki-card-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:6px;
  opacity:.6;
  transition:opacity var(--md-sys-motion-duration-short2) ease;
  flex-shrink:0;
}
.wiki-card:hover .wiki-card-actions{
  opacity:1;
}

/* Wiki Filter Dropdown & Controls */
.wiki-controls-wrap{
  display:flex;
  align-items:center;
  gap:8px;
}

.wiki-filter-wrap,
.wiki-sort-wrap{
  position:relative;
}

.wiki-filter-btn,
.wiki-sort-btn{
  position:relative;
  background:var(--md-sys-color-surface-container-low);
  border:1px solid var(--md-sys-color-outline-variant);
  color:var(--md-sys-color-on-surface-variant);
  width:48px;
  height:48px;
  padding:0;
  border-radius:var(--md-sys-shape-corner-full);
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
  box-sizing:border-box;
  box-shadow:var(--md-sys-elevation-level1);
  transition:all var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-fast);
}
.wiki-filter-btn svg,
.wiki-sort-btn svg{
  width:20px;
  height:20px;
  flex-shrink:0;
}
.wiki-filter-btn::after,
.wiki-sort-btn::after{
  content:"";
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%, -50%);
  min-width:48px;
  min-height:48px;
  width:100%;
  height:100%;
}

.wiki-filter-btn:hover, .wiki-filter-btn.active,
.wiki-sort-btn:hover, .wiki-sort-btn.active{
  background:var(--md-sys-color-surface-container-high);
  color:var(--md-sys-color-on-surface);
  border-color:var(--md-sys-color-outline);
  transform:scale(1.05);
}

.wiki-filter-badge{
  background:var(--invert);
  color:var(--on-invert);
  font-size:11px;
  padding:1px 6px;
  border-radius:10px;
  margin-left:2px;
}
.wiki-filter-btn.active .wiki-filter-badge{
  background:var(--on-invert);
  color:var(--invert);
}

.wiki-filter-menu,
.wiki-sort-menu{
  position:absolute;
  top:calc(100% + 6px);
  right:0;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  box-shadow:var(--md-sys-elevation-level3);
  border-radius:var(--md-sys-shape-corner-large);
  padding:6px;
  min-width:180px;
  max-width:240px;
  z-index:100;
  display:none;
  flex-direction:column;
  gap:2px;
}

.wiki-filter-menu.show,
.wiki-sort-menu.show{
  display:flex;
}

.wiki-filter-item,
.wiki-sort-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:8px 12px;
  border-radius:var(--md-sys-shape-corner-medium);
  font:var(--md-sys-typescale-label-large);
  color:var(--md-sys-color-on-surface);
  cursor:pointer;
  transition:all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
  background:none;
  border:0;
  width:100%;
  text-align:left;
}

.wiki-filter-item:hover,
.wiki-sort-item:hover{
  background:rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

.wiki-filter-item.active,
.wiki-sort-item.active{
  background:var(--md-sys-color-secondary-container);
  color:var(--md-sys-color-on-secondary-container);
  font:var(--md-sys-typescale-label-large-emphasized);
}

.wiki-filter-item-icon,
.wiki-sort-item-icon{
  margin-right:8px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color:var(--md-sys-color-on-surface-variant);
  width:16px;
  height:16px;
}
.wiki-filter-item:hover .wiki-filter-item-icon,
.wiki-filter-item.active .wiki-filter-item-icon,
.wiki-sort-item:hover .wiki-sort-item-icon,
.wiki-sort-item.active .wiki-sort-item-icon{
  color:currentColor;
}

.wiki-filter-item-check,
.wiki-sort-item-check{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  opacity:0;
}

.wiki-filter-item.active .wiki-filter-item-check,
.wiki-sort-item.active .wiki-sort-item-check{
  opacity:1;
}

.wiki-filter-divider,
.wiki-sort-divider{
  height:1px;
  background:var(--md-sys-color-outline-variant);
  margin:4px 0;
}

/* Compartmentalized Sections in 'Tous' mode */
.wiki-section-group{
  display:flex;
  flex-direction:column;
  gap:12px;
  width:100%;
  margin-bottom:24px;
}

.wiki-section-header{
  display:flex;
  align-items:center;
  gap:8px;
  padding:4px 0 8px 0;
  border-bottom:1px solid var(--md-sys-color-outline-variant);
}

.wiki-section-title{
  font:var(--md-sys-typescale-title-small-emphasized);
  letter-spacing:0.04em;
  text-transform:uppercase;
  color:var(--md-sys-color-on-surface-variant);
  display:inline-flex;
  align-items:center;
  gap:6px;
}

.wiki-section-count{
  font:var(--md-sys-typescale-label-small);
  font-weight:600;
  padding:2px 8px;
  border-radius:var(--md-sys-shape-corner-full);
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  color:var(--md-sys-color-on-surface-variant);
}

/* Badges for items */
.wiki-type-badge{
  font:var(--md-sys-typescale-label-small);
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.04em;
  padding:2px 8px;
  border-radius:var(--md-sys-shape-corner-extra-small);
  background:var(--md-sys-color-surface-container-highest);
  color:var(--md-sys-color-on-surface);
  display:inline-block;
}

/* Event cards */
.wiki-event-date-badge{
  font:var(--md-sys-typescale-label-medium);
  font-weight:600;
  color:var(--md-sys-color-on-surface-variant);
  display:inline-flex;
  align-items:center;
  gap:5px;
}

.wiki-participants-tag{
  display:inline-block;
  font:var(--md-sys-typescale-label-small);
  padding:2px 6px;
  border-radius:var(--md-sys-shape-corner-extra-small);
  background:var(--md-sys-color-surface-container-highest);
  color:var(--md-sys-color-on-surface-variant);
  margin-right:4px;
}

/* Document cards */
.wiki-doc-ref{
  font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font:var(--md-sys-typescale-label-small);
  background:var(--md-sys-color-surface-container-highest);
  padding:2px 6px;
  border-radius:var(--md-sys-shape-corner-extra-small);
  color:var(--md-sys-color-on-surface);
}

/* ==========================================================================
   Drive View for Documents (Preview Cards & Detailed List)
   ========================================================================== */

.wiki-docs-view-toggle{
  display:inline-flex;
  align-items:center;
  background:var(--md-sys-color-surface-container-low);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-full);
  padding:3px;
  gap:3px;
}

.wiki-view-mode-btn{
  background:none;
  border:0;
  color:var(--md-sys-color-on-surface-variant);
  width:32px;
  height:32px;
  border-radius:var(--md-sys-shape-corner-full);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
}

.wiki-view-mode-btn:hover{
  color:var(--md-sys-color-on-surface);
  background:rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

.wiki-view-mode-btn.active{
  background:var(--md-sys-color-secondary-container);
  color:var(--md-sys-color-on-secondary-container);
  box-shadow:var(--md-sys-elevation-level1);
}

/* Drive Grid View */
.drive-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(240px, 1fr));
  gap:16px;
  width:100%;
  padding:6px 6px 16px 6px;
  box-sizing:border-box;
}

.drive-card{
  background:var(--md-sys-color-surface-container-low);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-large-increased);
  overflow:visible;
  display:flex;
  flex-direction:column;
  box-shadow:var(--md-sys-elevation-level1);
  transition:transform var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-fast),
              box-shadow var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-effects),
              border-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-effects);
  position:relative;
  cursor:pointer;
  box-sizing:border-box;
}

.drive-card:hover{
  border-color:var(--md-sys-color-outline);
  transform:translateY(-2px);
  box-shadow:var(--md-sys-elevation-level2);
}

.drive-card-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:12px 14px;
  border-bottom:1px solid var(--md-sys-color-outline-variant);
  background:var(--md-sys-color-surface-container-low);
  border-top-left-radius:var(--md-sys-shape-corner-large-increased);
  border-top-right-radius:var(--md-sys-shape-corner-large-increased);
  position:relative;
  user-select:none;
}

.drive-card-top-left{
  display:flex;
  align-items:center;
  gap:9px;
  flex:1;
  min-width:0;
}

.drive-card-type-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
  width:18px;
  height:18px;
}

.drive-card-name{
  font:var(--md-sys-typescale-title-small-emphasized);
  color:var(--md-sys-color-on-surface);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  flex:1;
  min-width:0;
}

.drive-dots-wrapper{
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
}

.drive-dots-btn{
  background:transparent;
  border:none;
  outline:none;
  cursor:pointer;
  width:32px;
  height:32px;
  border-radius:var(--md-sys-shape-corner-full);
  color:var(--md-sys-color-on-surface-variant);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition:all var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
}

.drive-dots-btn:hover{
  background:rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
  color:var(--md-sys-color-on-surface);
}

.drive-menu{
  position:absolute;
  top:calc(100% + 4px);
  right:0;
  min-width:170px;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-large);
  box-shadow:var(--md-sys-elevation-level3);
  padding:4px;
  z-index:100;
  display:flex;
  flex-direction:column;
  gap:2px;
  backdrop-filter:blur(16px);
  -webkit-backdrop-filter:blur(16px);
}

.drive-menu-item{
  display:flex;
  align-items:center;
  gap:8px;
  width:100%;
  padding:8px 12px;
  font:var(--md-sys-typescale-label-large);
  color:var(--md-sys-color-on-surface);
  background:transparent;
  border:none;
  border-radius:var(--md-sys-shape-corner-medium);
  cursor:pointer;
  text-align:left;
  transition:background var(--md-sys-motion-duration-short2) ease, color var(--md-sys-motion-duration-short2) ease;
}

.drive-menu-item:hover{
  background:rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

.drive-menu-item.danger{
  color:var(--md-sys-color-error);
}

.drive-menu-item.danger:hover{
  background:rgba(var(--md-sys-color-error-rgb, 239, 68, 68), 0.1);
}

.drive-menu-sep{
  height:1px;
  background:var(--md-sys-color-outline-variant);
  margin:3px 0;
}

/* Drive Header Meta (Document count) */
.drive-header-meta{
  grid-column:1 / -1;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:4px 2px 8px 2px;
  margin-bottom:6px;
  border-bottom:1px solid var(--md-sys-color-outline-variant);
}

.drive-header-count{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font:var(--md-sys-typescale-label-medium-emphasized);
  color:var(--md-sys-color-on-surface-variant);
}

.drive-card-preview{
  width:100%;
  aspect-ratio:1 / 1;
  height:auto;
  background:var(--md-sys-color-surface-container-lowest);
  border-bottom-left-radius:var(--md-sys-shape-corner-large-increased);
  border-bottom-right-radius:var(--md-sys-shape-corner-large-increased);
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
  overflow:hidden;
}

/* Image Thumbnail */
.drive-thumb-img-wrap{
  width:100%;
  height:100%;
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}

.drive-thumb-img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
  border-bottom-left-radius:var(--md-sys-shape-corner-large-increased);
  border-bottom-right-radius:var(--md-sys-shape-corner-large-increased);
  transition:transform .2s ease;
}

.drive-card:hover .drive-thumb-img{
  transform:scale(1.03);
}

/* Canvas & Page Thumbnail Wrappers (Real Document Previews like Google Drive) */
.drive-thumb-canvas-wrap{
  width:100%;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
  padding:12px;
  box-sizing:border-box;
}

.drive-thumb-canvas{
  max-width:100%;
  max-height:100%;
  object-fit:contain;
  border-radius:var(--md-sys-shape-corner-small);
  box-shadow:var(--md-sys-elevation-level1);
  background:#fff;
  pointer-events:none;
  transition:transform .2s ease, box-shadow .2s ease;
}

.drive-card:hover .drive-thumb-canvas{
  transform:translateY(-1px);
  box-shadow:var(--md-sys-elevation-level2);
}

.drive-thumb-page-wrap{
  width:100%;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
  padding:12px;
  box-sizing:border-box;
}

.drive-thumb-page-img{
  max-width:100%;
  max-height:100%;
  object-fit:contain;
  border-radius:var(--md-sys-shape-corner-small);
  box-shadow:var(--md-sys-elevation-level1);
  background:#fff;
  transition:transform .2s ease, box-shadow .2s ease;
}

.drive-card:hover .drive-thumb-page-img{
  transform:translateY(-1px);
  box-shadow:var(--md-sys-elevation-level2);
}

/* Document Paper Sheet Thumbnail in Square Preview */
.drive-thumb-sheet{
  width:calc(100% - 20px);
  height:calc(100% - 20px);
  margin:10px;
  background:var(--md-sys-color-surface-container-low);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-medium);
  box-shadow:var(--md-sys-elevation-level1);
  padding:12px 14px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  box-sizing:border-box;
  overflow:hidden;
  position:relative;
  transition:transform .2s ease, box-shadow .2s ease;
}

.drive-card:hover .drive-thumb-sheet{
  transform:translateY(-1px);
  box-shadow:var(--md-sys-elevation-level2);
}

.drive-thumb-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:5px;
}

.drive-thumb-tag{
  font-size:9.5px;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.04em;
  color:var(--md-sys-color-on-surface-variant);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:130px;
}

.drive-thumb-badge{
  font-size:9.5px;
  font-weight:700;
  padding:2px 6px;
  border-radius:4px;
  letter-spacing:0.03em;
  text-transform:uppercase;
  flex-shrink:0;
}

.drive-thumb-img-wrap .drive-thumb-badge{
  position:absolute;
  bottom:8px;
  right:8px;
  box-shadow:0 2px 6px rgba(0,0,0,0.2);
}

.badge-pdf{
  background:rgba(239,68,68,0.12);
  color:#ef4444;
  border:1px solid rgba(239,68,68,0.25);
}

.badge-img{
  background:rgba(59,130,246,0.12);
  color:#3b82f6;
  border:1px solid rgba(59,130,246,0.25);
}

.badge-xls, .badge-csv{
  background:rgba(16,185,129,0.12);
  color:#10b981;
  border:1px solid rgba(16,185,129,0.25);
}

.badge-doc{
  background:rgba(37,99,235,0.12);
  color:#2563eb;
  border:1px solid rgba(37,99,235,0.25);
}

.badge-txt{
  background:rgba(107,114,128,0.12);
  color:#6b7280;
  border:1px solid rgba(107,114,128,0.25);
}

.badge-md{
  background:rgba(139,92,246,0.12);
  color:#8b5cf6;
  border:1px solid rgba(139,92,246,0.25);
}

.badge-json{
  background:rgba(245,158,11,0.12);
  color:#f59e0b;
  border:1px solid rgba(245,158,11,0.25);
}

.drive-thumb-title{
  font-size:11.5px;
  font-weight:600;
  color:var(--md-sys-color-on-surface);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  margin-bottom:5px;
}

.drive-thumb-body{
  flex:1;
  min-height:0;
  overflow:hidden;
  position:relative;
}

.drive-thumb-summary{
  font-size:10px;
  line-height:1.4;
  color:var(--md-sys-color-on-surface-variant);
  margin:0;
  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
  overflow:hidden;
  text-overflow:ellipsis;
  word-break:break-word;
}

/* Skeleton preview lines */
.drive-thumb-skeleton{
  display:flex;
  flex-direction:column;
  gap:4px;
  padding-top:2px;
}

.thumb-line{
  height:4.5px;
  background:var(--md-sys-color-outline-variant);
  border-radius:3px;
  opacity:0.6;
}
.thumb-line.w-90{ width:90%; }
.thumb-line.w-75{ width:75%; }
.thumb-line.w-85{ width:85%; }
.thumb-line.w-60{ width:60%; }

.drive-thumb-footer{
  display:flex;
  align-items:center;
  gap:4px;
  margin-top:6px;
  overflow:hidden;
}

.drive-thumb-chip{
  font-size:9px;
  font-weight:500;
  padding:1px 5px;
  border-radius:4px;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  color:var(--md-sys-color-on-surface-variant);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:110px;
}

.drive-thumb-chip.expiry{
  background:rgba(245,158,11,0.08);
  border-color:rgba(245,158,11,0.25);
  color:#d97706;
}

/* Code / Text Monospace Preview */
.drive-thumb-code-wrap{
  flex:1;
  min-height:0;
  overflow:hidden;
  background:var(--md-sys-color-surface-container-high);
  border-radius:4px;
  padding:4px 6px;
  border:1px solid var(--md-sys-color-outline-variant);
}

.drive-thumb-code{
  margin:0;
  font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size:8.5px;
  line-height:1.35;
  color:var(--md-sys-color-on-surface);
  white-space:pre-wrap;
  word-break:break-all;
  overflow:hidden;
  max-height:56px;
}

/* Spreadsheet Preview */
.drive-thumb-table-wrap{
  flex:1;
  min-height:0;
  overflow:hidden;
  border-radius:4px;
  border:1px solid var(--md-sys-color-outline-variant);
  background:var(--md-sys-color-surface);
}

.drive-thumb-table{
  width:100%;
  border-collapse:collapse;
  font-size:8.5px;
  font-family:ui-monospace, SFMono-Regular, Menlo, monospace;
}

.drive-thumb-table th{
  background:var(--md-sys-color-surface-container-high);
  padding:2px 4px;
  border-bottom:1px solid var(--md-sys-color-outline-variant);
  border-right:1px solid var(--md-sys-color-outline-variant);
  font-weight:600;
  color:var(--md-sys-color-on-surface-variant);
  text-align:left;
}

.drive-thumb-table td{
  padding:2px 4px;
  border-bottom:1px solid var(--md-sys-color-outline-variant);
  border-right:1px solid var(--md-sys-color-outline-variant);
  color:var(--md-sys-color-on-surface);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:55px;
}

.drive-thumb-caption{
  font-size:9px;
  color:var(--md-sys-color-on-surface-variant);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  margin-top:4px;
}

.drive-card-preview-placeholder{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:8px;
  color:var(--md-sys-color-on-surface-variant);
  width:100%;
  height:100%;
}

.drive-card-preview-icon{
  width:44px;
  height:44px;
  border-radius:10px;
  background:var(--md-sys-color-surface-container-low);
  border:1px solid var(--md-sys-color-outline-variant);
  display:flex;
  align-items:center;
  justify-content:center;
  color:var(--md-sys-color-on-surface);
}

.drive-file-format-badge{
  font-size:10px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.05em;
  padding:2px 6px;
  border-radius:4px;
  background:var(--md-sys-color-surface-container-high);
  color:var(--md-sys-color-on-surface);
}

/* Drive Table / List View */
.drive-table-wrap{
  width:100%;
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-large);
  overflow-x:auto;
  background:var(--md-sys-color-surface-container-low);
  box-shadow:var(--md-sys-elevation-level1);
}

.drive-table{
  width:100%;
  border-collapse:collapse;
  font:var(--md-sys-typescale-body-medium);
  text-align:left;
}

.drive-table th{
  background:var(--md-sys-color-surface-container-high);
  color:var(--md-sys-color-on-surface-variant);
  font:var(--md-sys-typescale-label-small);
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.04em;
  padding:10px 14px;
  border-bottom:1px solid var(--md-sys-color-outline-variant);
  white-space:nowrap;
}

.drive-table td{
  padding:10px 14px;
  border-bottom:1px solid var(--md-sys-color-outline-variant);
  color:var(--md-sys-color-on-surface);
  vertical-align:middle;
}

.drive-table tr:last-child td{
  border-bottom:none;
}

.drive-table tbody tr{
  cursor:pointer;
  transition:background var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
}

.drive-table tbody tr:hover{
  background:rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

.drive-file-cell{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:180px;
}

.drive-file-cell-text{
  display:flex;
  flex-direction:column;
  min-width:0;
}

.drive-file-cell-name{
  font:var(--md-sys-typescale-body-medium-emphasized);
  color:var(--md-sys-color-on-surface);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.drive-file-cell-sub{
  font:var(--md-sys-typescale-body-small);
  color:var(--md-sys-color-on-surface-variant);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.drive-file-icon{
  width:32px;
  height:32px;
  border-radius:var(--md-sys-shape-corner-small);
  background:var(--md-sys-color-surface-container-highest);
  border:1px solid var(--md-sys-color-outline-variant);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
  color:var(--md-sys-color-on-surface-variant);
}

/* Modal File Dropzone */
.doc-file-dropzone{
  border:2px dashed var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-large-increased);
  padding:24px 16px;
  background:var(--md-sys-color-surface-container-lowest);
  text-align:center;
  cursor:pointer;
  transition:all var(--md-sys-motion-duration-short3) var(--md-sys-motion-spring-fast);
}

.doc-file-dropzone:hover{
  border-color:var(--md-sys-color-primary);
  background:rgba(var(--md-sys-color-primary-rgb), 0.04);
  transform:scale(1.01);
}
.doc-file-dropzone.dragover{
  border-color:var(--md-sys-color-primary);
  background:rgba(var(--md-sys-color-primary-rgb), 0.08);
  transform:scale(1.02);
  box-shadow:0 0 0 4px rgba(var(--md-sys-color-primary-rgb), 0.16);
}

.doc-dropzone-prompt{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:12px 8px;
  gap:6px;
}

.doc-dropzone-icon{
  color:var(--md-sys-color-primary);
  margin-bottom:4px;
  transition:transform var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-fast);
}

.doc-file-dropzone:hover .doc-dropzone-icon{
  transform:translateY(-2px);
}

.doc-dropzone-main-text{
  font:var(--md-sys-typescale-title-small-emphasized);
  color:var(--md-sys-color-on-surface);
}

.doc-dropzone-browse{
  color:var(--md-sys-color-primary);
  text-decoration:underline;
  cursor:pointer;
}

.doc-dropzone-sub-text{
  font:var(--md-sys-typescale-body-small);
  color:var(--md-sys-color-on-surface-variant);
}

.doc-file-chip{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 14px;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-small);
  text-align:left;
}

.doc-file-chip-info{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}

.doc-file-chip-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color:var(--md-sys-color-on-surface-variant);
}

.doc-file-chip-name{
  font:var(--md-sys-typescale-label-large);
  color:var(--md-sys-color-on-surface);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  max-width:260px;
}

.doc-file-chip-size{
  font:var(--md-sys-typescale-label-small);
  color:var(--md-sys-color-on-surface-variant);
  font-family:ui-monospace, monospace;
}

.doc-file-chip-remove{
  background:none;
  border:0;
  color:var(--md-sys-color-on-surface-variant);
  cursor:pointer;
  padding:4px;
  border-radius:var(--md-sys-shape-corner-full);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition:all var(--md-sys-motion-duration-short2) ease;
}

.doc-file-chip-remove:hover{
  color:var(--md-sys-color-error);
  background:rgba(var(--md-sys-color-error-rgb, 239, 68, 68), 0.1);
}

/* AI Analysis status & feedback */
.doc-ai-status{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px 16px;
  background:var(--md-sys-color-secondary-container);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-medium);
  font:var(--md-sys-typescale-body-medium);
  color:var(--md-sys-color-on-secondary-container);
}

.doc-ai-spinner{
  width:18px;
  height:18px;
  border:2px solid var(--md-sys-color-outline-variant);
  border-top-color:var(--md-sys-color-primary);
  border-radius:var(--md-sys-shape-corner-full);
  animation:doc-ai-spin .75s linear infinite;
  flex-shrink:0;
}

@keyframes doc-ai-spin{
  to{ transform:rotate(360deg); }
}

/* AI Key points badges */
.doc-ai-keypoints{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:6px;
}

.doc-keypoint-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 12px;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-small);
  font:var(--md-sys-typescale-label-medium);
}

.doc-keypoint-label{
  font:var(--md-sys-typescale-label-small);
  text-transform:uppercase;
  letter-spacing:0.04em;
  color:var(--md-sys-color-on-surface-variant);
  font-weight:600;
}

.doc-keypoint-val{
  font-weight:600;
  color:var(--md-sys-color-on-surface);
}

/* Summary textarea & header */
.doc-summary-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:6px;
}

.doc-summary-header .wiki-form-label{
  margin-bottom:0;
}

.doc-ai-badge{
  display:inline-flex;
  align-items:center;
  font:var(--md-sys-typescale-label-small-emphasized);
  color:var(--md-sys-color-primary);
  background:var(--md-sys-color-primary-container);
  padding:3px 10px;
  border-radius:var(--md-sys-shape-corner-full);
  letter-spacing:0.03em;
}

.doc-summary-textarea{
  line-height:1.55;
  font:var(--md-sys-typescale-body-medium);
  min-height:110px;
  background:var(--md-sys-color-surface-container-lowest);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-small);
  padding:12px 14px;
  color:var(--md-sys-color-on-surface);
}

.doc-form-title{
  grid-column:span 8;
}

.doc-form-category{
  grid-column:span 4;
}

@media (max-width:540px){
  .doc-form-title,
  .doc-form-category{
    grid-column:span 12;
  }
}

/* Pure Doc Preview Modal (Lightbox - Only Preview & Close Button) */
.doc-pure-modal{
  position:fixed;
  top:0;
  left:0;
  right:0;
  bottom:0;
  z-index:1200;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  box-sizing:border-box;
}

.doc-pure-modal .modal-backdrop{
  position:fixed;
  top:0;
  left:0;
  right:0;
  bottom:0;
  background:rgba(0,0,0,0.85);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
  z-index:1;
  cursor:pointer;
}

.doc-pure-container{
  position:relative;
  z-index:2;
  max-width:92vw;
  max-height:92vh;
  display:flex;
  align-items:center;
  justify-content:center;
}

.doc-pure-close-btn{
  position:absolute;
  top:-20px;
  right:-20px;
  width:40px;
  height:40px;
  border-radius:50%;
  background:#1c1c1e;
  border:1.5px solid rgba(255,255,255,0.25);
  color:#ffffff;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  z-index:20;
  box-shadow:0 4px 16px rgba(0,0,0,0.5);
  transition:transform .15s ease, background .15s ease;
}

.doc-pure-close-btn:hover{
  transform:scale(1.08);
  background:#2c2c2e;
}

.doc-pure-viewer{
  display:flex;
  align-items:center;
  justify-content:center;
  max-width:90vw;
  max-height:90vh;
  border-radius:12px;
  overflow:hidden;
  box-shadow:0 20px 60px rgba(0,0,0,0.5);
  background:transparent;
}

.doc-pure-viewer img{
  max-width:88vw;
  max-height:86vh;
  object-fit:contain;
  display:block;
  border-radius:12px;
}

.doc-pure-viewer iframe{
  width:82vw;
  height:86vh;
  border:none;
  border-radius:12px;
  background:#ffffff;
}

.doc-pure-viewer .doc-preview-text{
  width:72vw;
  max-width:820px;
  max-height:80vh;
  padding:24px;
  margin:0;
  background:var(--md-sys-color-surface-container-low);
  color:var(--md-sys-color-on-surface);
  overflow:auto;
  border-radius:12px;
  font-size:13px;
  line-height:1.6;
  border:1px solid var(--md-sys-color-outline-variant);
  font-family:ui-monospace, SFMono-Regular, monospace;
}

.doc-pure-viewer .drive-card-preview-placeholder{
  padding:48px 36px;
  background:var(--md-sys-color-surface-container-low);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:14px;
  text-align:center;
}

/* Doc Details Modal */
.doc-details-card{
  max-width:520px;
  width:100%;
}

.doc-details-body{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.doc-details-grid{
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:16px 18px;
  background:var(--md-sys-color-surface-container-lowest);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-medium);
}

.doc-details-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  font:var(--md-sys-typescale-body-medium);
}

.doc-details-label{
  color:var(--md-sys-color-on-surface-variant);
  font-weight:500;
}

.doc-details-val{
  color:var(--md-sys-color-on-surface);
  font-weight:600;
  text-align:right;
  word-break:break-all;
}

/* Background Navigation & Scroll Lock when Modal is Active */
body.modal-open{
  overflow:hidden !important;
}

body.modal-open #panelsSlider{
  overflow:hidden !important;
  scroll-snap-type:none !important;
  pointer-events:none !important;
  touch-action:none !important;
}

body.modal-open .modal{
  pointer-events:auto !important;
}

/* Direct Document AI Analysis Banner */
.doc-upload-ai-banner{
  position:relative;
  overflow:hidden;
  display:flex;
  align-items:center;
  gap:14px;
  padding:14px 18px;
  margin:12px 16px 0 16px;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-large);
  box-shadow:var(--md-sys-elevation-level1);
  animation:docBannerIn .2s ease-out;
  transition:border-color .2s ease, background .2s ease;
}
.doc-upload-ai-banner .composer-progress-track{
  display:block;
}

@keyframes docBannerIn{
  from{opacity:0; transform:translateY(-6px);}
  to{opacity:1; transform:translateY(0);}
}

.doc-upload-ai-banner.success{
  border-color:rgba(52, 199, 89, 0.45);
  background:rgba(52, 199, 89, 0.08);
}

.doc-upload-ai-banner.error{
  border-color:var(--md-sys-color-error);
  background:rgba(var(--md-sys-color-error-rgb, 239, 68, 68), 0.08);
}

.doc-upload-ai-spinner{
  width:18px;
  height:18px;
  border:2px solid var(--md-sys-color-outline-variant);
  border-top-color:var(--md-sys-color-primary);
  border-radius:var(--md-sys-shape-corner-full);
  animation:doc-ai-spin .75s linear infinite;
  flex-shrink:0;
}

.doc-upload-ai-icon{
  color:var(--success, #34c759);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
}

.doc-upload-ai-text{
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width:0;
}

.doc-upload-ai-title{
  font-size:13px;
  font-weight:600;
  color:var(--md-sys-color-on-surface);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.doc-upload-ai-sub{
  font-size:11.5px;
  color:var(--md-sys-color-on-surface-variant);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.wiki-empty-add-btn{
  margin-top:10px;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-small);
  padding:6px 14px;
  font-size:12.5px;
  font-weight:600;
  color:var(--md-sys-color-on-surface);
  cursor:pointer;
  transition:border-color .15s ease, background .15s ease;
}

.wiki-empty-add-btn:hover{
  border-color:var(--md-sys-color-outline);
  background:var(--md-sys-color-surface-container-highest);
}

/* ==========================================================================
   Composer Slash Commands Menu (/contact, /lieu, /document)
   ========================================================================== */
.composer-slash-menu{
  position:absolute;
  bottom:calc(100% + 8px);
  left:0;
  right:0;
  max-height:280px;
  overflow-y:auto;
  background:var(--md-sys-color-surface-container-high);
  backdrop-filter:blur(24px);
  -webkit-backdrop-filter:blur(24px);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-large);
  box-shadow:var(--md-sys-elevation-level3);
  z-index:200;
  padding:6px;
  box-sizing:border-box;
  animation:slashMenuIn .15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slashMenuIn{
  from{opacity:0; transform:translateY(6px) scale(0.99);}
  to{opacity:1; transform:translateY(0) scale(1);}
}

.composer-slash-header{
  padding:8px 12px 4px 12px;
  font:var(--md-sys-typescale-label-small);
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.04em;
  color:var(--md-sys-color-on-surface-variant);
}

.composer-slash-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 12px;
  border-radius:var(--md-sys-shape-corner-medium);
  cursor:pointer;
  transition:background var(--md-sys-motion-duration-short2) var(--md-sys-motion-spring-effects);
  user-select:none;
}

.composer-slash-item:hover,
.composer-slash-item.active{
  background:rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

.composer-slash-item-icon{
  width:28px;
  height:28px;
  border-radius:var(--md-sys-shape-corner-small);
  background:var(--md-sys-color-surface-container-highest);
  border:1px solid var(--md-sys-color-outline-variant);
  display:flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
  color:var(--md-sys-color-on-surface);
}

.composer-slash-item-info{
  display:flex;
  flex-direction:column;
  min-width:0;
  flex:1;
}

.composer-slash-item-title{
  font:var(--md-sys-typescale-body-medium-emphasized);
  color:var(--md-sys-color-on-surface);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.composer-slash-item-meta{
  font:var(--md-sys-typescale-body-small);
  color:var(--md-sys-color-on-surface-variant);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.composer-slash-item-badge{
  font:var(--md-sys-typescale-label-small);
  padding:2px 8px;
  border-radius:var(--md-sys-shape-corner-extra-small);
  background:var(--md-sys-color-surface-container-highest);
  color:var(--md-sys-color-on-surface-variant);
  flex-shrink:0;
}

.composer-slash-empty{
  padding:16px 12px;
  text-align:center;
  font:var(--md-sys-typescale-body-medium);
  color:var(--md-sys-color-on-surface-variant);
}

/* ==========================================================================
   Document Universal Previewers (PDF, CSV, Code/JSON, Audio, Video)
   ========================================================================== */
.doc-preview-pdf-container{
  display:flex;
  flex-direction:column;
  width:84vw;
  max-width:1100px;
  height:88vh;
  border-radius:var(--md-sys-shape-corner-extra-large);
  overflow:hidden;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  box-shadow:var(--md-sys-elevation-level3);
}

.doc-preview-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 20px;
  background:var(--md-sys-color-surface-container-low);
  border-bottom:1px solid var(--md-sys-color-outline-variant);
  flex-shrink:0;
}

.doc-preview-toolbar-title{
  font:var(--md-sys-typescale-title-small-emphasized);
  color:var(--md-sys-color-on-surface);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.doc-preview-toolbar-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-shrink:0;
}

.doc-preview-action-btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-full);
  padding:6px 14px;
  font:var(--md-sys-typescale-label-large);
  color:var(--md-sys-color-on-surface);
  text-decoration:none;
  cursor:pointer;
  transition:background var(--md-sys-motion-duration-short2) ease, border-color var(--md-sys-motion-duration-short2) ease;
}

.doc-preview-action-btn:hover{
  background:rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

.doc-preview-action-btn.icon-only{
  padding:6px 10px;
}

.doc-preview-nav-group{
  display:flex;
  align-items:center;
  gap:6px;
}

.doc-preview-page-pill{
  font:var(--md-sys-typescale-label-medium);
  color:var(--md-sys-color-on-surface);
  padding:4px 12px;
  background:var(--md-sys-color-surface-container-lowest);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius:var(--md-sys-shape-corner-full);
  display:inline-flex;
  align-items:center;
  gap:4px;
}

.doc-preview-zoom-group{
  display:inline-flex;
  align-items:center;
  gap:4px;
}

.doc-preview-pdf-viewport{
  flex:1;
  overflow:auto;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#202124;
  padding:20px;
  position:relative;
  min-height:300px;
}

.doc-preview-pdf-loading{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:12px;
  color:var(--md-sys-color-on-surface-variant);
  font:var(--md-sys-typescale-body-medium);
}

.doc-preview-pdf-canvas-wrap{
  display:inline-flex;
  justify-content:center;
  align-items:center;
  box-shadow:0 12px 40px rgba(0,0,0,0.55);
  border-radius:6px;
  overflow:hidden;
  background:#ffffff;
  max-width:100%;
  max-height:100%;
  flex-shrink:0;
  margin:auto;
}

.doc-preview-pdf-canvas{
  display:block;
  max-width:100% !important;
  max-height:100% !important;
  width:100% !important;
  height:100% !important;
  object-fit:contain;
}

.doc-preview-sheet-wrap{
  flex:1;
  overflow-y:auto;
  padding:32px 16px;
  background:#1e1e22;
  display:flex;
  justify-content:center;
  min-height:0;
}

.doc-preview-sheet-paper{
  background:#ffffff;
  color:#111827;
  width:100%;
  max-width:720px;
  padding:36px;
  border-radius:var(--md-sys-shape-corner-medium);
  box-shadow:var(--md-sys-elevation-level2);
  font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height:fit-content;
}

.doc-preview-sheet-badge{
  display:inline-block;
  font:var(--md-sys-typescale-label-small);
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.05em;
  color:#4f46e5;
  background:#eef2ff;
  border:1px solid #c7d2fe;
  padding:3px 8px;
  border-radius:var(--md-sys-shape-corner-extra-small);
  margin-bottom:12px;
}

.doc-preview-sheet-title{
  font:var(--md-sys-typescale-headline-small);
  color:#111827;
  margin:0 0 10px 0;
}

.doc-preview-sheet-meta{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  font:var(--md-sys-typescale-body-small);
  color:#6b7280;
  margin-bottom:18px;
}

.doc-preview-sheet-divider{
  height:1px;
  background:#e5e7eb;
  margin-bottom:20px;
}

.doc-preview-sheet-text{
  font:var(--md-sys-typescale-body-large);
  line-height:1.65;
  color:#374151;
  white-space:pre-wrap;
  word-break:break-word;
}

.doc-preview-csv-wrap{
  display:flex;
  flex-direction:column;
  width:84vw;
  max-width:1100px;
  max-height:86vh;
  border-radius:var(--md-sys-shape-corner-extra-large);
  overflow:hidden;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  box-shadow:var(--md-sys-elevation-level3);
}

.doc-preview-table-container{
  overflow:auto;
  flex:1;
}

.doc-preview-csv-table{
  width:100%;
  border-collapse:collapse;
  font:var(--md-sys-typescale-body-medium);
  text-align:left;
}

.doc-preview-csv-table th{
  position:sticky;
  top:0;
  background:var(--md-sys-color-surface-container-high);
  padding:10px 16px;
  font:var(--md-sys-typescale-label-small);
  font-weight:600;
  color:var(--md-sys-color-on-surface-variant);
  border-bottom:1px solid var(--md-sys-color-outline-variant);
  white-space:nowrap;
  z-index:2;
}

.doc-preview-csv-table td{
  padding:10px 16px;
  border-bottom:1px solid var(--md-sys-color-outline-variant);
  color:var(--md-sys-color-on-surface);
  white-space:nowrap;
}

.doc-preview-csv-table tr:hover td{
  background:rgba(var(--md-sys-color-on-surface-rgb), var(--md-sys-state-hover-layer));
}

.doc-preview-csv-table td.row-num,
.doc-preview-csv-table th.row-num{
  color:var(--md-sys-color-on-surface-variant);
  width:40px;
  text-align:center;
  font-family:ui-monospace, SFMono-Regular, monospace;
}

.doc-preview-code-wrap{
  display:flex;
  flex-direction:column;
  width:80vw;
  max-width:960px;
  max-height:86vh;
  border-radius:var(--md-sys-shape-corner-extra-large);
  overflow:hidden;
  background:var(--md-sys-color-surface-container-high);
  border:1px solid var(--md-sys-color-outline-variant);
  box-shadow:var(--md-sys-elevation-level3);
}

.doc-preview-code-content{
  padding:18px 22px;
  margin:0;
  overflow:auto;
  font-family:ui-monospace, SFMono-Regular, Menlo, monospace;
  font:var(--md-sys-typescale-body-medium);
  line-height:1.6;
  color:var(--md-sys-color-on-surface);
  background:var(--md-sys-color-surface-container-lowest);
  flex:1;
}

.doc-preview-media-wrap{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:var(--md-sys-color-surface-container-high);
  border-radius:var(--md-sys-shape-corner-extra-large);
  border:1px solid var(--md-sys-color-outline-variant);
  box-shadow:var(--md-sys-elevation-level3);
  max-width:88vw;
}

.doc-preview-media-wrap video{
  max-width:84vw;
  max-height:80vh;
  border-radius:var(--md-sys-shape-corner-medium);
  outline:none;
}

.doc-preview-media-wrap audio{
  width:420px;
  max-width:84vw;
  outline:none;
}

/* ==========================================================================
   M3 Expressive Infos / Wiki Responsive Adaptations
   ========================================================================== */

@media (max-width: 599px) {
  .wiki-subnav-top {
    gap: 8px;
  }
  .wiki-search-box {
    height: 40px;
    padding: 0 12px;
  }
  .wiki-search-input {
    font-size: 0.9375rem;
  }
  .wiki-controls-wrap {
    gap: 4px;
  }
  .wiki-filter-btn,
  .wiki-sort-btn,
  .wiki-add-btn,
  .wiki-view-mode-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .wiki-categories-bar {
    padding: 2px;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .wiki-cat-pill {
    flex: 0 0 auto;
    padding: 0 12px;
    height: 36px;
    font-size: 0.8125rem;
  }
  .wiki-cat-badge {
    font-size: 11px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
  }

  .wiki-card {
    padding: 14px;
    border-radius: var(--md-sys-shape-corner-large);
  }
}

/* Document Source Filter Chips & Google Drive Integration */
.drive-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.doc-source-filters {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-full);
  gap: 2px;
}

.doc-source-chip {
  appearance: none;
  background: transparent;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  padding: 4px 12px;
  font: var(--md-sys-typescale-label-medium);
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized);
  user-select: none;
}

.doc-source-chip:hover {
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface-container-high);
}

.doc-source-chip.active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
  box-shadow: var(--md-sys-elevation-level1);
}

.doc-sync-drive-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--md-sys-shape-corner-full);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-label-medium);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized);
}

.doc-sync-drive-btn:hover {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}

.doc-sync-drive-btn.syncing svg,
#wikiSyncDriveBtn.syncing svg {
  animation: docSpin 1s linear infinite;
}

@keyframes docSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.drive-thumb-badge.badge-drive {
  background: #1a73e8;
  color: #ffffff;
}

.wiki-badge.wiki-badge-drive {
  background: rgba(26, 115, 232, 0.12);
  color: #1a73e8;
  border: 1px solid rgba(26, 115, 232, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.vcf-dropzone:hover, .vcf-dropzone.dragover {
  border-color: var(--md-sys-color-primary) !important;
  background: var(--md-sys-color-primary-container) !important;
}
