.kb-shared-space[hidden],
.kb-shared-side-panel[hidden],
.kb-shared-entry[hidden] {
  display: none !important;
}

.kb-shared-space {
  --share-ink: #172033;
  --share-muted: #6b7280;
  --share-line: rgba(148, 163, 184, .22);
  --share-purple: #6d4aff;
  --share-purple-soft: #f2efff;
  height: 100%;
  min-height: 540px;
  overflow: auto;
  padding: 2px 2px 36px;
  color: var(--share-ink);
}

.kb-shared-loading,
.kb-shared-empty {
  min-height: 320px;
  display: grid;
  place-items: center;
  text-align: center;
  color: #94a3b8;
}

.kb-shared-empty > div {
  max-width: 420px;
}

.kb-shared-empty i {
  width: 38px;
  height: 38px;
  margin-bottom: 12px;
  color: #b7a9ff;
}

.kb-shared-empty strong {
  display: block;
  color: #475569;
  font-size: 16px;
  margin-bottom: 6px;
}

.kb-shared-empty p {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.7;
}

.kb-shared-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  padding: 22px 24px;
  border: 1px solid rgba(109, 74, 255, .15);
  border-radius: 20px;
  background:
    radial-gradient(circle at 92% 14%, rgba(139, 92, 246, .14), transparent 34%),
    linear-gradient(135deg, #fff 0%, #faf9ff 62%, #f5f2ff 100%);
}

.kb-shared-kicker,
.kb-shared-dialog-kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #7557d8;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.kb-shared-hero h2 {
  margin: 7px 0 6px;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -.035em;
}

.kb-shared-hero p {
  max-width: 650px;
  margin: 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.7;
}

.kb-shared-hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.kb-shared-btn {
  min-height: 36px;
  border: 1px solid rgba(109, 74, 255, .18);
  border-radius: 11px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: #fff;
  color: #5540b8;
  font: inherit;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.kb-shared-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(76, 52, 160, .11);
}

.kb-shared-btn:disabled {
  opacity: .52;
  cursor: not-allowed;
}

.kb-shared-btn.primary {
  border-color: #6d4aff;
  background: #6d4aff;
  color: #fff;
}

.kb-shared-btn.danger {
  border-color: rgba(220, 38, 38, .18);
  color: #b91c1c;
}

.kb-shared-btn.small {
  min-height: 30px;
  padding: 6px 9px;
  border-radius: 9px;
  font-size: 11px;
}

.kb-shared-btn i {
  width: 15px;
  height: 15px;
}

.kb-shared-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 15px 0 12px;
}

.kb-shared-filters {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--share-line);
  border-radius: 12px;
  background: #f8fafc;
}

.kb-shared-filter {
  border: 0;
  border-radius: 9px;
  padding: 7px 11px;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.kb-shared-filter.active {
  background: #fff;
  color: #5b42c4;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .07);
}

.kb-shared-search {
  width: min(280px, 38vw);
  min-width: 170px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--share-line);
  border-radius: 11px;
  background: #fff;
}

.kb-shared-search i {
  width: 14px;
  color: #94a3b8;
}

.kb-shared-search input {
  width: 100%;
  height: 36px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #334155;
  font: inherit;
  font-size: 12px;
}

.kb-shared-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.kb-shared-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--share-line);
  border-radius: 16px;
  padding: 15px;
  background: #fff;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.kb-shared-card:hover,
.kb-shared-card.active {
  border-color: rgba(109, 74, 255, .33);
  box-shadow: 0 12px 30px rgba(51, 38, 120, .09);
  transform: translateY(-1px);
}

.kb-shared-card.important::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 0;
  width: 3px;
  height: 34px;
  border-radius: 0 4px 4px 0;
  background: #f59e0b;
}

.kb-shared-card-top,
.kb-shared-card-meta,
.kb-shared-card-foot {
  display: flex;
  align-items: center;
  gap: 7px;
}

.kb-shared-card-top {
  justify-content: space-between;
}

.kb-shared-card h3 {
  min-width: 0;
  margin: 9px 0 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1e293b;
  font-size: 15px;
  letter-spacing: -.01em;
}

.kb-shared-card-summary {
  min-height: 39px;
  max-height: 39px;
  overflow: hidden;
  color: #64748b;
  font-size: 12px;
  line-height: 1.65;
}

.kb-shared-card-summary * {
  display: inline;
  margin: 0;
  padding: 0;
  font: inherit;
}

.kb-shared-card-meta {
  color: #94a3b8;
  font-size: 11px;
}

.kb-shared-card-meta span:not(:last-child)::after {
  content: '·';
  margin-left: 7px;
  color: #cbd5e1;
}

.kb-shared-card-foot {
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(226, 232, 240, .8);
}

.kb-shared-file-stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #64748b;
  font-size: 11px;
  font-weight: 750;
}

.kb-shared-file-stat i {
  width: 13px;
}

.kb-shared-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 10px;
  font-weight: 850;
}

.kb-shared-badge.important {
  background: #fff7e6;
  color: #b45309;
}

.kb-shared-badge.sync {
  background: #ecfdf5;
  color: #047857;
}

.kb-shared-badge i {
  width: 12px;
  height: 12px;
}

.kb-shared-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #64748b;
  font-size: 11px;
  font-weight: 750;
}

.kb-shared-live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, .1);
}

.kb-shared-live.connected::before {
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, .1);
}

.kb-shared-side-panel {
  padding: 18px 16px;
}

.kb-shared-side-panel h3 {
  margin: 8px 0 6px;
  color: #1e293b;
  font-size: 15px;
}

.kb-shared-side-panel p {
  margin: 0 0 14px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.7;
}

.kb-shared-side-stat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid #eef2f7;
  color: #64748b;
  font-size: 12px;
}

.kb-shared-side-stat strong {
  color: #334155;
}

.kb-shared-dialog {
  width: min(860px, calc(100vw - 28px));
  max-height: min(880px, calc(100vh - 28px));
  border: 0;
  border-radius: 22px;
  padding: 0;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 34px 100px rgba(15, 23, 42, .28);
}

.kb-shared-dialog.detail {
  width: min(980px, calc(100vw - 28px));
}

.kb-shared-dialog.recovery {
  width: min(760px, calc(100vw - 28px));
}

.kb-shared-recovery-note {
  margin: 0 0 12px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.7;
}

.kb-shared-recovery-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.kb-shared-recovery-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 11px;
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 11px;
  background: #fff;
}

.kb-shared-recovery-row span,
.kb-shared-recovery-row small {
  display: block;
  min-width: 0;
}

.kb-shared-recovery-row strong {
  color: #334155;
  overflow-wrap: anywhere;
}

.kb-shared-recovery-row small {
  margin-top: 3px;
  color: #94a3b8;
}

.kb-shared-empty.compact {
  min-height: 130px;
}

.kb-shared-dialog::backdrop {
  background: rgba(15, 23, 42, .48);
  backdrop-filter: blur(3px);
}

.kb-shared-dialog-head,
.kb-shared-dialog-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid #eef2f7;
}

.kb-shared-dialog-foot {
  justify-content: flex-end;
  border-top: 1px solid #eef2f7;
  border-bottom: 0;
}

.kb-shared-dialog-head h2 {
  margin: 4px 0 0;
  color: #1e293b;
  font-size: 20px;
}

.kb-shared-dialog-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: #f8fafc;
  color: #64748b;
  font-size: 22px;
  cursor: pointer;
}

.kb-shared-dialog-body {
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 19px 20px;
}

.kb-shared-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.kb-shared-field {
  display: grid;
  gap: 7px;
}

.kb-shared-field.full {
  grid-column: 1 / -1;
}

.kb-shared-field label,
.kb-shared-field > span {
  color: #475569;
  font-size: 12px;
  font-weight: 850;
}

.kb-shared-input,
.kb-shared-select {
  width: 100%;
  min-height: 40px;
  box-sizing: border-box;
  border: 1px solid #dfe5ee;
  border-radius: 11px;
  padding: 9px 11px;
  outline: 0;
  background: #fff;
  color: #334155;
  font: inherit;
  font-size: 13px;
}

.kb-shared-input:focus,
.kb-shared-select:focus,
.kb-shared-rich-editor:focus {
  border-color: rgba(109, 74, 255, .55);
  box-shadow: 0 0 0 3px rgba(109, 74, 255, .08);
}

.kb-shared-rich-wrap {
  border: 1px solid #dfe5ee;
  border-radius: 13px;
  overflow: hidden;
  background: #fff;
}

.kb-shared-rich-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid #eef2f7;
  background: #f8fafc;
}

.kb-shared-rich-toolbar button {
  min-width: 29px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #475569;
  font: inherit;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.kb-shared-rich-toolbar button:hover {
  background: #ede9fe;
  color: #5b42c4;
}

.kb-shared-rich-editor {
  min-height: 145px;
  max-height: 330px;
  overflow: auto;
  padding: 13px 14px;
  outline: 0;
  color: #334155;
  font-size: 13px;
  line-height: 1.75;
}

.kb-shared-rich-editor:empty::before {
  content: attr(data-placeholder);
  color: #a0aec0;
}

.kb-shared-file-pickers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.kb-shared-file-picker {
  position: relative;
  min-height: 76px;
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 10px;
  border: 1px dashed #c4b5fd;
  border-radius: 12px;
  background: #fbfaff;
  color: #644abf;
  text-align: center;
  cursor: pointer;
}

.kb-shared-file-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.kb-shared-file-picker strong {
  font-size: 12px;
}

.kb-shared-file-picker small {
  color: #8b7abf;
  font-size: 10px;
}

.kb-shared-selected-files {
  margin-top: 8px;
  color: #64748b;
  font-size: 11px;
}

.kb-shared-progress {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
}

.kb-shared-progress-track {
  height: 5px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.kb-shared-progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: #6d4aff;
  transition: width .2s ease;
}

.kb-shared-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr);
  gap: 18px;
}

.kb-shared-detail-rich {
  min-height: 120px;
  color: #334155;
  font-size: 13px;
  line-height: 1.8;
}

.kb-shared-detail-rich > :first-child {
  margin-top: 0;
}

.kb-shared-detail-rich a {
  color: #5b42c4;
}

.kb-shared-detail-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.kb-shared-file-panel {
  border: 1px solid #e6eaf0;
  border-radius: 14px;
  overflow: hidden;
}

.kb-shared-file-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #e9edf3;
  background: #f8fafc;
}

.kb-shared-file-head strong {
  color: #334155;
  font-size: 12px;
}

.kb-shared-file-tree {
  max-height: 400px;
  overflow: auto;
}

.kb-shared-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-bottom: 1px solid #f0f3f7;
  color: #475569;
  font-size: 11px;
}

.kb-shared-file-row:last-child {
  border-bottom: 0;
}

.kb-shared-file-name {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.kb-shared-file-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-shared-file-name i {
  width: 14px;
  flex: 0 0 auto;
  color: #8b7ad8;
}

.kb-shared-file-size {
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.kb-shared-file-download {
  border: 0;
  background: transparent;
  color: #6349c0;
  font: inherit;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.kb-shared-sync-box {
  margin-top: 15px;
  padding: 14px;
  border: 1px solid rgba(16, 185, 129, .18);
  border-radius: 14px;
  background: #f4fdf9;
}

.kb-shared-sync-box h4 {
  margin: 0 0 5px;
  color: #065f46;
  font-size: 13px;
}

.kb-shared-sync-box p {
  margin: 0 0 10px;
  color: #4b7065;
  font-size: 11px;
  line-height: 1.65;
}

.kb-shared-sync-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.kb-shared-token-panel {
  margin-top: 10px;
  padding: 11px;
  border-radius: 11px;
  background: #fff;
  color: #475569;
  font-size: 11px;
}

.kb-shared-token-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(16, 185, 129, .15);
  color: #64748b;
  font-size: 11px;
}

.kb-shared-token-list > strong {
  color: #166534;
}

.kb-shared-token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 9px;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 9px;
  background: #fff;
}

.kb-shared-token-row span,
.kb-shared-token-row small {
  display: block;
  min-width: 0;
}

.kb-shared-token-row b {
  color: #334155;
}

.kb-shared-token-row small {
  margin-top: 3px;
  color: #94a3b8;
}

.kb-shared-token-value,
.kb-shared-command {
  display: block;
  margin-top: 6px;
  padding: 9px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
  user-select: all;
}

.kb-shared-sync-state {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  color: #047857;
  font-size: 11px;
  font-weight: 800;
}

.kb-shared-sync-state.error {
  color: #b91c1c;
}

.kb-shared-embed {
  min-height: 84px;
  border: 1px solid rgba(109, 74, 255, .18);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(135deg, #fff, #faf9ff);
}

.kb-shared-embed-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kb-shared-embed-copy {
  min-width: 0;
}

.kb-shared-embed-copy small {
  display: block;
  margin-bottom: 4px;
  color: #7961cf;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .06em;
}

.kb-shared-embed-copy strong,
.kb-shared-embed-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-shared-embed-copy strong {
  color: #312e50;
  font-size: 13px;
}

.kb-shared-embed-copy span {
  margin-top: 3px;
  color: #7c8495;
  font-size: 11px;
}

.kb-shared-embed-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.kb-shared-embed-search {
  width: 100%;
  box-sizing: border-box;
  border: 0;
  border-bottom: 1px solid #e8e5f8;
  padding: 8px 4px;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
}

.kb-shared-embed-results {
  display: grid;
  gap: 4px;
  margin-top: 7px;
}

.kb-shared-embed-results button {
  border: 0;
  border-radius: 8px;
  padding: 8px;
  background: #f8fafc;
  color: #475569;
  text-align: left;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.kb-shared-embed-results button strong,
.kb-shared-embed-results button span {
  display: block;
}

.kb-shared-embed-results button span {
  margin-top: 2px;
  color: #94a3b8;
}

body.kb-shared-space-open .kb-layout-toggle-right,
body.kb-shared-space-open .kb-panel-resizer-right {
  display: none;
}

@media (max-width: 1080px) {
  .kb-shared-grid {
    grid-template-columns: 1fr;
  }

  .kb-shared-detail-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .kb-shared-hero,
  .kb-shared-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .kb-shared-hero-actions {
    justify-content: flex-start;
  }

  .kb-shared-filters {
    overflow-x: auto;
  }

  .kb-shared-search {
    width: 100%;
  }

  .kb-shared-form-grid,
  .kb-shared-file-pickers {
    grid-template-columns: 1fr;
  }

  .kb-shared-dialog-body {
    padding: 15px;
  }

  .kb-shared-file-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .kb-shared-file-size {
    display: none;
  }
}
